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(agent): recommend market skills during agent creation (#16016)

AmAzing-3f79eefcf7f8
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index cd5d0bd2020..abeccb53bfa 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -120,6 +120,16 @@
"createModal.groupPlaceholder": "Describe what this group should do...",
"createModal.groupTitle": "What should your group do?",
"createModal.placeholder": "Describe what your agent should do...",
+ "createModal.skillSuggestion.actions.createAnyway": "Create Agent Anyway",
+ "createModal.skillSuggestion.actions.createAnywayHint": "Skill not a fit?",
+ "createModal.skillSuggestion.actions.install": "Add Skill",
+ "createModal.skillSuggestion.actions.openSkills": "Open Skills",
+ "createModal.skillSuggestion.actions.tryInLobeAI": "Try in LobeAI",
+ "createModal.skillSuggestion.description": "Even though this is phrased as a role, the reusable part is the workflow. Install it once, then use it across Agents.",
+ "createModal.skillSuggestion.installError": "Skill wasn't added. Retry, or create an Agent anyway.",
+ "createModal.skillSuggestion.installed.description": "You can now use this Skill in LobeAI or add it to any Agent.",
+ "createModal.skillSuggestion.installed.title": "Skill added",
+ "createModal.skillSuggestion.title": "This can use a Skill",
"createModal.title": "What should your agent do?",
"createTask.assignee": "Assignee",
"createTask.collapse": "Hide input",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index a6a49355d5d..392d429ee47 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -120,6 +120,16 @@
"createModal.groupPlaceholder": "描述此分组的用途…",
"createModal.groupTitle": "你的分组应该做什么?",
"createModal.placeholder": "描述你的智能体应该做什么…",
+ "createModal.skillSuggestion.actions.createAnyway": "仍然创建助理",
+ "createModal.skillSuggestion.actions.createAnywayHint": "感觉技能不合适?",
+ "createModal.skillSuggestion.actions.install": "添加技能",
+ "createModal.skillSuggestion.actions.openSkills": "打开技能",
+ "createModal.skillSuggestion.actions.tryInLobeAI": "在 LobeAI 中试用",
+ "createModal.skillSuggestion.description": "虽然你用角色来描述它,但可复用的是背后的工作流。安装一次技能后,可以在多个助理中使用。",
+ "createModal.skillSuggestion.installError": "技能未添加成功。你可以重试,或仍然创建助理。",
+ "createModal.skillSuggestion.installed.description": "你现在可以在 LobeAI 中使用这个技能,也可以把它添加到任意助理。",
+ "createModal.skillSuggestion.installed.title": "技能已添加",
+ "createModal.skillSuggestion.title": "这可以使用技能",
"createModal.title": "你的智能体应该做什么?",
"createTask.assignee": "负责人",
"createTask.collapse": "隐藏输入",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index da7cee81ce0..850c042de9a 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -330,6 +330,19 @@ export default {
'createModal.groupPlaceholder': 'Describe what this group should do...',
'createModal.groupTitle': 'What should your group do?',
'createModal.placeholder': 'Describe what your agent should do...',
+ 'createModal.skillSuggestion.actions.createAnyway': 'Create Agent Anyway',
+ 'createModal.skillSuggestion.actions.createAnywayHint': 'Skill not a fit?',
+ 'createModal.skillSuggestion.actions.install': 'Add Skill',
+ 'createModal.skillSuggestion.actions.openSkills': 'Open Skills',
+ 'createModal.skillSuggestion.actions.tryInLobeAI': 'Try in LobeAI',
+ 'createModal.skillSuggestion.description':
+ 'Even though this is phrased as a role, the reusable part is the workflow. Install it once, then use it across Agents.',
+ 'createModal.skillSuggestion.installed.description':
+ 'You can now use this Skill in LobeAI or add it to any Agent.',
+ 'createModal.skillSuggestion.installed.title': 'Skill added',
+ 'createModal.skillSuggestion.installError':
+ "Skill wasn't added. Retry, or create an Agent anyway.",
+ 'createModal.skillSuggestion.title': 'This can use a Skill',
'createModal.title': 'What should your agent do?',
'claudeCodeInstallGuide.actions.openDocs': 'Open Install Guide',
'claudeCodeInstallGuide.actions.openSystemTools': 'Open System Tools',
diff --git a/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.test.tsx b/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.test.tsx
index e42affde917..753079715a2 100644
--- a/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.test.tsx
+++ b/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.test.tsx
@@ -16,6 +16,10 @@ vi.mock('react-router-dom', () => ({
useNavigate: () => mocks.navigate,
}));
+vi.mock('@/features/Workspace/useWorkspaceAwareNavigate', () => ({
+ useWorkspaceAwareNavigate: () => mocks.navigate,
+}));
+
vi.mock('@/components/ChatGroupWizard', () => ({
ChatGroupWizard: () => null,
}));
@@ -36,14 +40,21 @@ vi.mock('@/routes/(main)/home/_layout/hooks/useCreateModal', () => ({
CreateAgentModal: ({
open,
onCreateBlank,
+ onOpenSkills,
}: {
onCreateBlank: () => Promise<void> | void;
+ onOpenSkills?: (identifier: string) => void;
open: boolean;
}) =>
open ? (
- <button type="button" onClick={() => void onCreateBlank()}>
- Create Blank
- </button>
+ <>
+ <button type="button" onClick={() => void onCreateBlank()}>
+ Create Blank
+ </button>
+ <button type="button" onClick={() => onOpenSkills?.('product-requirements-writer')}>
+ Open Skills
+ </button>
+ </>
) : null,
}));
@@ -134,4 +145,15 @@ describe('AgentModalProvider', () => {
expect(mocks.refreshAgentList).toHaveBeenCalled();
});
});
+
+ it('opens the Skills tab from the create modal skill completion state', async () => {
+ renderProvider();
+
+ fireEvent.click(screen.getByText('Open create agent modal'));
+ fireEvent.click(screen.getByText('Open Skills'));
+
+ expect(mocks.navigate).toHaveBeenCalledWith(
+ '/settings/skill?tab=skill&skill=product-requirements-writer',
+ );
+ });
});
diff --git a/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.tsx b/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.tsx
index ea8d8e784fb..9b588847a71 100644
--- a/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.tsx
+++ b/src/routes/(main)/home/_layout/Body/Agent/ModalProvider.tsx
@@ -99,6 +99,14 @@ const CreateModalRenderer = memo<CreateModalRendererProps>(({ open, type, groupI
}
}, [type, storeCreateAgent, navigate, refreshAgentList, sendAsGroup, groupId]);
+ const handleOpenSkills = useCallback(
+ (identifier: string) => {
+ onClose();
+ navigate(`/settings/skill?tab=skill&skill=${encodeURIComponent(identifier)}`);
+ },
+ [navigate, onClose],
+ );
+
return (
<CreateAgentModal
agentId={inboxAgentId}
@@ -106,6 +114,7 @@ const CreateModalRenderer = memo<CreateModalRendererProps>(({ open, type, groupI
type={type}
onClose={onClose}
onCreateBlank={handleCreateBlank}
+ onOpenSkills={handleOpenSkills}
onSubmit={handleSubmit}
/>
);
diff --git a/src/routes/(main)/home/_layout/hooks/agentSkillSuggestion.test.ts b/src/routes/(main)/home/_layout/hooks/agentSkillSuggestion.test.ts
new file mode 100644
index 00000000000..75ee6807e77
--- /dev/null
+++ b/src/routes/(main)/home/_layout/hooks/agentSkillSuggestion.test.ts
@@ -0,0 +1,37 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import {
+ buildAgentSkillSuggestionQueries,
+ searchAgentSkillSuggestion,
+} from './agentSkillSuggestion';
+
+const marketApiMocks = vi.hoisted(() => ({
+ searchSkill: vi.fn(),
+}));
+
+vi.mock('@/services/marketApi', () => ({
+ marketApiService: {
+ searchSkill: marketApiMocks.searchSkill,
+ },
+}));
+
+describe('agent skill suggestion', () => {
+ beforeEach(() => {
+ marketApiMocks.searchSkill.mockReset();
+ });
+
+ it('builds market search queries only from fixed skill categories', () => {
+ expect(buildAgentSkillSuggestionQueries('帮我创建一个简历优化助手')).toEqual(['resume review']);
+ });
+
+ it('does not use free-form agent prompts as market search queries', async () => {
+ const prompt = '帮我创建一个 Acme 客户续约 SOP 检查清单,包含内部报价策略';
+
+ expect(buildAgentSkillSuggestionQueries(prompt)).toEqual([]);
+
+ const result = await searchAgentSkillSuggestion(prompt);
+
+ expect(result).toBeUndefined();
+ expect(marketApiMocks.searchSkill).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/routes/(main)/home/_layout/hooks/agentSkillSuggestion.ts b/src/routes/(main)/home/_layout/hooks/agentSkillSuggestion.ts
new file mode 100644
index 00000000000..fe028412816
--- /dev/null
+++ b/src/routes/(main)/home/_layout/hooks/agentSkillSuggestion.ts
@@ -0,0 +1,129 @@
+import { marketApiService } from '@/services/marketApi';
+import type { DiscoverSkillItem } from '@/types/discover';
+import { SkillSorts } from '@/types/discover';
+
+const MAX_QUERY_COUNT = 3;
+const MAX_RESULT_COUNT = 3;
+
+const QUERY_RULES: Array<{ pattern: RegExp; query: string }> = [
+ { pattern: /简历|履历|resume|cv/i, query: 'resume review' },
+ {
+ pattern: /代码审查|code\s*review|pull\s*request|pr\s*review|review.*code/i,
+ query: 'code review',
+ },
+ {
+ pattern: /prd|产品需求|需求文档|产品经理|product\s*(requirement|manager)/i,
+ query: 'product requirements',
+ },
+ { pattern: /调研|研究|资料收集|research/i, query: 'research' },
+ { pattern: /旅行|旅游|行程|travel|trip/i, query: 'travel planning' },
+ { pattern: /翻译|translate|translation/i, query: 'translation' },
+ { pattern: /写作|文案|文章|公众号|copywriting|writing/i, query: 'writing' },
+ { pattern: /会议|纪要|meeting|minutes/i, query: 'meeting notes' },
+ { pattern: /邮件|email|mail/i, query: 'email writing' },
+ { pattern: /数据|表格|excel|csv|analysis|analytics/i, query: 'data analysis' },
+ { pattern: /ui|ux|前端|界面|设计|frontend|design/i, query: 'frontend design' },
+ { pattern: /代码|编程|开发|debug|bug|programming|coding/i, query: 'coding' },
+ { pattern: /健康|健身|health|fitness/i, query: 'health' },
+];
+
+const SKILL_INTENT_PATTERNS: RegExp[] = [
+ /方法|流程|工作流|模板|检查清单|核对表|评分表|规则|规范|步骤|SOP|转换器|生成器|格式化|提取器|分类器|校验器|自动化|批量|复用|可复用/i,
+ /\b(method|workflow|process|template|checklist|rubric|framework|playbook|sop|converter|generator|formatter|extractor|classifier|validator|automation|batch|reusable)\b/i,
+];
+
+const AGENT_INTENT_PATTERNS: RegExp[] = [
+ /长期|持续|跨会话|记住|记忆|偏好|陪伴|跟进|监督|每天|每周|习惯|备考|学习计划|历史|固定人格|固定人设|固定语气|专属语气|人格本身|人设本身|语气本身/,
+ /\b(long[-\s]?term|memory|remember|preference|follow[-\s]?up|daily|weekly|habit|companion|historical|persistent)\b/i,
+];
+
+const ROLE_FRAMING_PATTERNS: RegExp[] = [
+ /角色|专家|顾问|助理|助手|智能体|机器人|导师|教练|分析师|审查员|编辑|翻译官|规划师|经理|设计师|工程师|客服|运营/,
+ /\b(agent|assistant|bot|advisor|expert|coach|tutor|mentor|analyst|reviewer|editor|translator|planner|manager|designer|engineer)\b/i,
+];
+
+const removeAgentShell = (prompt: string) =>
+ prompt
+ .replaceAll(/https?:\/\/\S+/g, ' ')
+ .replaceAll(/[`*_#>(){}]/g, ' ')
+ .replaceAll('[', ' ')
+ .replaceAll(']', ' ')
+ .replaceAll(
+ /(帮我|请|我想|我希望|希望|需要|想要|能不能|可以)?\s*(创建|新建|做一个|做个|做|搭建|生成|配置|制作|build|create|make|set up)/gi,
+ ' ',
+ )
+ .replaceAll(/\b(agent|assistant|bot|advisor|expert|coach)\b/gi, ' ')
+ .replaceAll(
+ /(一个|一位|一名|专门|能够|可以|用于|用来|负责|智能体|助手|助理|机器人|专家|顾问|教练)/g,
+ ' ',
+ )
+ .replaceAll(/\s+/g, ' ')
+ .trim();
+
+const matchesAny = (patterns: RegExp[], text: string) =>
+ patterns.some((pattern) => pattern.test(text));
+
+const pushUnique = (items: string[], value: string) => {
+ const query = value.trim();
+ if (!query || items.includes(query)) return;
+ items.push(query);
+};
+
+export interface AgentSkillSuggestionResult {
+ items: DiscoverSkillItem[];
+ query: string;
+}
+
+export const isHighConfidenceSkillSuggestionPrompt = (prompt: string): boolean => {
+ const cleaned = removeAgentShell(prompt);
+ const text = `${prompt} ${cleaned}`;
+ const hasReusableSkillIntent = matchesAny(SKILL_INTENT_PATTERNS, text);
+ const hasRoleFraming = matchesAny(ROLE_FRAMING_PATTERNS, prompt);
+ const hasSkillCategoryMatch = QUERY_RULES.some(
+ (rule) => rule.pattern.test(prompt) || rule.pattern.test(cleaned),
+ );
+
+ return (
+ (hasReusableSkillIntent || (hasRoleFraming && hasSkillCategoryMatch)) &&
+ !matchesAny(AGENT_INTENT_PATTERNS, text)
+ );
+};
+
+export const buildAgentSkillSuggestionQueries = (prompt: string): string[] => {
+ const cleaned = removeAgentShell(prompt);
+ const queries: string[] = [];
+
+ for (const rule of QUERY_RULES) {
+ if (rule.pattern.test(prompt) || rule.pattern.test(cleaned)) {
+ pushUnique(queries, rule.query);
+ }
+ if (queries.length >= MAX_QUERY_COUNT) break;
+ }
+
+ return queries.slice(0, MAX_QUERY_COUNT);
+};
+
+export const searchAgentSkillSuggestion = async (
+ prompt: string,
+): Promise<AgentSkillSuggestionResult | undefined> => {
+ if (!isHighConfidenceSkillSuggestionPrompt(prompt)) return;
+
+ const queries = buildAgentSkillSuggestionQueries(prompt);
+ if (queries.length === 0) return;
+
+ for (const query of queries) {
+ const result = await marketApiService.searchSkill({
+ page: 1,
+ pageSize: MAX_RESULT_COUNT,
+ q: query,
+ sort: SkillSorts.Relevance,
+ });
+
+ if (result.items.length > 0) {
+ return {
+ items: result.items.slice(0, MAX_RESULT_COUNT),
+ query,
+ };
+ }
+ }
+};
diff --git a/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.test.ts b/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.test.ts
index dc792116677..a03b2b1bf88 100644
--- a/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.test.ts
+++ b/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.test.ts
@@ -1,6 +1,9 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { trackCreateAgentModalCreationSucceeded } from './createAgentModalAnalytics';
+import {
+ trackCreateAgentModalCreationSucceeded,
+ trackCreateAgentModalSkillSuggestionAction,
+} from './createAgentModalAnalytics';
const trackProductUsageEvent = vi.hoisted(() => vi.fn());
@@ -44,4 +47,31 @@ describe('create agent modal analytics', () => {
expect(tracked).toBe(false);
expect(trackProductUsageEvent).not.toHaveBeenCalled();
});
+
+ it('tracks skill suggestion actions without prompt content', async () => {
+ trackProductUsageEvent.mockResolvedValue(true);
+
+ const tracked = await trackCreateAgentModalSkillSuggestionAction({
+ action: 'install_succeeded',
+ selectedSkillIdentifier: 'resume-reviewer',
+ skillIdentifiers: ['resume-reviewer', 'cover-letter-writer'],
+ source: 'manual',
+ });
+
+ expect(tracked).toBe(true);
+ expect(trackProductUsageEvent).toHaveBeenCalledWith(
+ {
+ name: 'create_agent_modal_skill_suggestion_action',
+ properties: {
+ action: 'install_succeeded',
+ selected_skill_identifier: 'resume-reviewer',
+ skill_count: 2,
+ source: 'manual',
+ spm: 'home.create_agent_modal.skill_suggestion.install_succeeded',
+ top_skill_identifier: 'resume-reviewer',
+ },
+ },
+ { analytics: undefined },
+ );
+ });
});
diff --git a/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.ts b/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.ts
index 75dc8242e5e..f6ec98c857d 100644
--- a/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.ts
+++ b/src/routes/(main)/home/_layout/hooks/createAgentModalAnalytics.ts
@@ -4,12 +4,29 @@ import { trackProductUsageEvent } from '@/libs/analytics/productUsageEvent';
export type CreateAgentModalSubmitSource = 'blank' | 'manual' | 'example' | 'example_edited';
+export type CreateAgentModalSkillSuggestionAction =
+ | 'create_agent_anyway_clicked'
+ | 'install_clicked'
+ | 'install_failed'
+ | 'install_succeeded'
+ | 'open_skills_clicked'
+ | 'shown'
+ | 'try_in_lobeai_clicked';
+
interface TrackCreateAgentModalCreationSucceededParams {
analytics?: AnalyticsManager | null;
source: CreateAgentModalSubmitSource;
type: 'agent' | 'group';
}
+interface TrackCreateAgentModalSkillSuggestionActionParams {
+ action: CreateAgentModalSkillSuggestionAction;
+ analytics?: AnalyticsManager | null;
+ selectedSkillIdentifier?: string;
+ skillIdentifiers?: string[];
+ source: CreateAgentModalSubmitSource;
+}
+
export const trackCreateAgentModalCreationSucceeded = ({
analytics,
source,
@@ -29,3 +46,35 @@ export const trackCreateAgentModalCreationSucceeded = ({
{ analytics },
);
};
+
+export const trackCreateAgentModalSkillSuggestionAction = ({
+ action,
+ analytics,
+ selectedSkillIdentifier,
+ skillIdentifiers,
+ source,
+}: TrackCreateAgentModalSkillSuggestionActionParams) => {
+ const properties: Record<string, number | string> = {
+ action,
+ source,
+ spm: `home.create_agent_modal.skill_suggestion.${action}`,
+ };
+
+ if (skillIdentifiers) {
+ properties.skill_count = skillIdentifiers.length;
+ const [topSkillIdentifier] = skillIdentifiers;
+ if (topSkillIdentifier) properties.top_skill_identifier = topSkillIdentifier;
+ }
+
+ if (selectedSkillIdentifier) {
+ properties.selected_skill_identifier = selectedSkillIdentifier;
+ }
+
+ return trackProductUsageEvent(
+ {
+ name: 'create_agent_modal_skill_suggestion_action',
+ properties,
+ },
+ { analytics },
+ );
+};
diff --git a/src/routes/(main)/home/_layout/hooks/useCreateModal.test.tsx b/src/routes/(main)/home/_layout/hooks/useCreateModal.test.tsx
index 049a3e7cb14..cff881403a0 100644
--- a/src/routes/(main)/home/_layout/hooks/useCreateModal.test.tsx
+++ b/src/routes/(main)/home/_layout/hooks/useCreateModal.test.tsx
@@ -6,6 +6,15 @@ import { CreateAgentModal } from './useCreateModal';
const analyticsTrack = vi.hoisted(() => vi.fn());
const telemetryState = vi.hoisted(() => ({ enabled: true }));
+const marketApiMocks = vi.hoisted(() => ({
+ searchSkill: vi.fn(),
+}));
+const skillServiceMocks = vi.hoisted(() => ({
+ importFromMarket: vi.fn(),
+}));
+const toolStoreMocks = vi.hoisted(() => ({
+ refreshAgentSkills: vi.fn(),
+}));
const chatInputState = vi.hoisted(() => {
interface Editor {
focus: () => void;
@@ -50,8 +59,18 @@ vi.mock('@lobehub/ui', () => ({
{children}
</button>
),
- Button: ({ children, onClick }: { children?: ReactNode; onClick?: () => void }) => (
- <button type="button" onClick={onClick}>
+ Button: ({
+ children,
+ disabled,
+ onClick,
+ type,
+ }: {
+ children?: ReactNode;
+ disabled?: boolean;
+ onClick?: () => void;
+ type?: string;
+ }) => (
+ <button data-button-type={type} disabled={disabled} type="button" onClick={onClick}>
{children}
</button>
),
@@ -59,6 +78,18 @@ vi.mock('@lobehub/ui', () => ({
Text: ({ children }: { children?: ReactNode }) => <span>{children}</span>,
}));
+vi.mock('@/services/marketApi', () => ({
+ marketApiService: {
+ searchSkill: marketApiMocks.searchSkill,
+ },
+}));
+
+vi.mock('@/services/skill', () => ({
+ agentSkillService: {
+ importFromMarket: skillServiceMocks.importFromMarket,
+ },
+}));
+
vi.mock('@lobehub/ui/base-ui', () => ({
Modal: ({ children, open }: { children?: ReactNode; open?: boolean }) =>
open ? <div role="dialog">{children}</div> : null,
@@ -67,6 +98,8 @@ vi.mock('@lobehub/ui/base-ui', () => ({
vi.mock('antd-style', () => ({
cssVar: {
borderRadiusLG: 8,
+ colorError: '#f00',
+ colorSuccess: '#0a0',
colorTextDescription: '#666',
colorTextSecondary: '#666',
colorTextTertiary: '#999',
@@ -82,6 +115,19 @@ vi.mock('react-i18next', () => ({
'chat:createModal.groupPlaceholder': 'Describe what this group should do...',
'chat:createModal.groupTitle': 'What should your group do?',
'chat:createModal.placeholder': 'Describe what your agent should do...',
+ 'chat:createModal.skillSuggestion.actions.createAnyway': 'Create Agent Anyway',
+ 'chat:createModal.skillSuggestion.actions.createAnywayHint': 'Skill not a fit?',
+ 'chat:createModal.skillSuggestion.actions.install': 'Add Skill',
+ 'chat:createModal.skillSuggestion.actions.openSkills': 'Open Skills',
+ 'chat:createModal.skillSuggestion.actions.tryInLobeAI': 'Try in LobeAI',
+ 'chat:createModal.skillSuggestion.description':
+ 'Even though this is phrased as a role, the reusable part is the workflow. Install it once, then use it across Agents.',
+ 'chat:createModal.skillSuggestion.installed.description':
+ 'You can now use this Skill in LobeAI or add it to any Agent.',
+ 'chat:createModal.skillSuggestion.installed.title': 'Skill added',
+ 'chat:createModal.skillSuggestion.installError':
+ "Skill wasn't added. Retry, or create an Agent anyway.",
+ 'chat:createModal.skillSuggestion.title': 'This can use a Skill',
'chat:createModal.title': 'What should your agent do?',
'common:home.suggestQuestions': 'Try these examples',
'common:switch': 'Switch',
@@ -154,9 +200,19 @@ vi.mock('@/store/user/selectors', () => ({
},
}));
+vi.mock('@/store/tool', () => ({
+ useToolStore: (
+ selector: (state: { refreshAgentSkills: typeof toolStoreMocks.refreshAgentSkills }) => unknown,
+ ) =>
+ selector({
+ refreshAgentSkills: toolStoreMocks.refreshAgentSkills,
+ }),
+}));
+
const renderModal = (type: 'agent' | 'group' = 'agent') => {
const onClose = vi.fn();
const onCreateBlank = vi.fn().mockResolvedValue(undefined);
+ const onOpenSkills = vi.fn();
const onSubmit = vi.fn().mockResolvedValue(undefined);
render(
@@ -166,19 +222,51 @@ const renderModal = (type: 'agent' | 'group' = 'agent') => {
type={type}
onClose={onClose}
onCreateBlank={onCreateBlank}
+ onOpenSkills={onOpenSkills}
onSubmit={onSubmit}
/>,
);
- return { onClose, onCreateBlank, onSubmit };
+ return { onClose, onCreateBlank, onOpenSkills, onSubmit };
+};
+
+const expectTrackedSkillSuggestionAction = async (
+ action: string,
+ properties: Record<string, unknown> = {},
+) => {
+ await waitFor(() => {
+ expect(analyticsTrack).toHaveBeenCalledWith(
+ expect.objectContaining({
+ name: 'create_agent_modal_skill_suggestion_action',
+ properties: expect.objectContaining({
+ action,
+ ...properties,
+ }),
+ }),
+ );
+ });
};
describe('CreateAgentModal analytics', () => {
beforeEach(() => {
analyticsTrack.mockReset();
+ marketApiMocks.searchSkill.mockReset();
+ marketApiMocks.searchSkill.mockResolvedValue({
+ currentPage: 1,
+ items: [],
+ pageSize: 3,
+ totalCount: 0,
+ totalPages: 0,
+ });
+ skillServiceMocks.importFromMarket.mockReset();
+ skillServiceMocks.importFromMarket.mockResolvedValue({
+ skill: { id: 'skill-1', name: 'Resume Reviewer' },
+ status: 'created',
+ });
telemetryState.enabled = true;
chatInputState.onMarkdownContentChange = undefined;
chatInputState.onSend = undefined;
+ toolStoreMocks.refreshAgentSkills.mockReset();
vi.mocked(chatInputState.editor.focus).mockClear();
vi.mocked(chatInputState.editor.instance.setDocument).mockClear();
});
@@ -294,4 +382,219 @@ describe('CreateAgentModal analytics', () => {
});
expect(analyticsTrack).not.toHaveBeenCalled();
});
+
+ it('interrupts high-confidence skill prompts with a stronger skill recommendation', async () => {
+ marketApiMocks.searchSkill.mockResolvedValueOnce({
+ currentPage: 1,
+ items: [
+ {
+ createdAt: '2026-01-01',
+ description: 'Review and improve resumes with a reusable checklist.',
+ identifier: 'resume-reviewer',
+ installCount: 12,
+ name: 'Resume Reviewer',
+ updatedAt: '2026-01-01',
+ },
+ ],
+ pageSize: 3,
+ totalCount: 1,
+ totalPages: 1,
+ });
+ const { onSubmit } = renderModal();
+
+ fireEvent.change(screen.getByLabelText('chat input'), {
+ target: { value: '帮我做一个简历优化检查清单' },
+ });
+ fireEvent.click(screen.getByText('Send'));
+
+ await waitFor(() => {
+ expect(marketApiMocks.searchSkill).toHaveBeenCalledWith(
+ expect.objectContaining({ pageSize: 3, q: 'resume review', sort: 'relevance' }),
+ );
+ });
+ expect(onSubmit).not.toHaveBeenCalled();
+ expect(await screen.findByText('This can use a Skill')).toBeInTheDocument();
+ expect(screen.getByText('Resume Reviewer')).toBeInTheDocument();
+ expect(screen.queryByText('Example title')).not.toBeInTheDocument();
+ expect(screen.getByText('Skill not a fit?')).toBeInTheDocument();
+ await expectTrackedSkillSuggestionAction('shown', {
+ skill_count: 1,
+ source: 'manual',
+ top_skill_identifier: 'resume-reviewer',
+ });
+
+ expect(screen.getByText('Add Skill')).toHaveAttribute('data-button-type', 'primary');
+
+ const createAnywayButton = screen.getByText('Create Agent Anyway');
+ expect(createAnywayButton).not.toHaveAttribute('data-button-type', 'primary');
+ fireEvent.click(createAnywayButton);
+
+ await waitFor(() => {
+ expect(onSubmit).toHaveBeenCalledWith('帮我做一个简历优化检查清单');
+ });
+ await expectTrackedSkillSuggestionAction('create_agent_anyway_clicked', {
+ skill_count: 1,
+ source: 'manual',
+ top_skill_identifier: 'resume-reviewer',
+ });
+ await waitFor(() => {
+ expect(analyticsTrack).toHaveBeenCalledWith(
+ expect.objectContaining({
+ name: 'create_agent_modal_creation_succeeded',
+ properties: expect.objectContaining({ source: 'manual' }),
+ }),
+ );
+ });
+ });
+
+ it('does not interrupt ambiguous long-term agent prompts', async () => {
+ const { onSubmit } = renderModal();
+
+ fireEvent.change(screen.getByLabelText('chat input'), {
+ target: { value: '创建一个代码学习导师,长期跟进我的学习计划' },
+ });
+ fireEvent.click(screen.getByText('Send'));
+
+ await waitFor(() => {
+ expect(onSubmit).toHaveBeenCalledWith('创建一个代码学习导师,长期跟进我的学习计划');
+ });
+ expect(marketApiMocks.searchSkill).not.toHaveBeenCalled();
+ expect(screen.queryByText('This can use a Skill')).not.toBeInTheDocument();
+ });
+
+ it('interrupts role-framed reusable prompts when the role maps to a skill workflow', async () => {
+ marketApiMocks.searchSkill.mockResolvedValueOnce({
+ currentPage: 1,
+ items: [
+ {
+ createdAt: '2026-01-01',
+ description: 'Review and improve resumes with a reusable checklist.',
+ identifier: 'resume-reviewer',
+ installCount: 12,
+ name: 'Resume Reviewer',
+ updatedAt: '2026-01-01',
+ },
+ ],
+ pageSize: 3,
+ totalCount: 1,
+ totalPages: 1,
+ });
+ const { onSubmit } = renderModal();
+
+ fireEvent.change(screen.getByLabelText('chat input'), {
+ target: { value: '帮我创建一个简历优化助手' },
+ });
+ fireEvent.click(screen.getByText('Send'));
+
+ await waitFor(() => {
+ expect(marketApiMocks.searchSkill).toHaveBeenCalledWith(
+ expect.objectContaining({ pageSize: 3, q: 'resume review', sort: 'relevance' }),
+ );
+ });
+ expect(onSubmit).not.toHaveBeenCalled();
+ expect(await screen.findByText('This can use a Skill')).toBeInTheDocument();
+ });
+
+ it('shows a completed skill state after installing the recommended skill', async () => {
+ marketApiMocks.searchSkill.mockResolvedValueOnce({
+ currentPage: 1,
+ items: [
+ {
+ createdAt: '2026-01-01',
+ description: 'Review and improve resumes with a reusable checklist.',
+ identifier: 'resume-reviewer',
+ installCount: 12,
+ name: 'Resume Reviewer',
+ updatedAt: '2026-01-01',
+ },
+ ],
+ pageSize: 3,
+ totalCount: 1,
+ totalPages: 1,
+ });
+ const { onClose, onOpenSkills, onSubmit } = renderModal();
+
+ fireEvent.change(screen.getByLabelText('chat input'), {
+ target: { value: '帮我做一个简历优化检查清单' },
+ });
+ fireEvent.click(screen.getByText('Send'));
+
+ expect(await screen.findByText('This can use a Skill')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('Add Skill'));
+
+ await waitFor(() => {
+ expect(skillServiceMocks.importFromMarket).toHaveBeenCalledWith('resume-reviewer');
+ });
+ await expectTrackedSkillSuggestionAction('install_clicked', {
+ selected_skill_identifier: 'resume-reviewer',
+ });
+ await expectTrackedSkillSuggestionAction('install_succeeded', {
+ selected_skill_identifier: 'resume-reviewer',
+ });
+ expect(toolStoreMocks.refreshAgentSkills).toHaveBeenCalled();
+ expect(onClose).not.toHaveBeenCalled();
+ expect(onSubmit).not.toHaveBeenCalled();
+ expect(await screen.findByText('Skill added')).toBeInTheDocument();
+ expect(screen.getByText('Resume Reviewer')).toBeInTheDocument();
+ expect(screen.queryByText('Skill not a fit?')).not.toBeInTheDocument();
+ expect(screen.queryByText('Create Agent Anyway')).not.toBeInTheDocument();
+
+ const tryInLobeAIButton = screen.getByText('Try in LobeAI');
+ expect(tryInLobeAIButton).toHaveAttribute('data-button-type', 'primary');
+ const openSkillsButton = screen.getByText('Open Skills');
+ expect(openSkillsButton).not.toHaveAttribute('data-button-type', 'primary');
+ fireEvent.click(openSkillsButton);
+
+ expect(onOpenSkills).toHaveBeenCalledWith('resume-reviewer');
+ await expectTrackedSkillSuggestionAction('open_skills_clicked', {
+ selected_skill_identifier: 'resume-reviewer',
+ });
+
+ fireEvent.click(tryInLobeAIButton);
+ expect(onClose).toHaveBeenCalled();
+ await expectTrackedSkillSuggestionAction('try_in_lobeai_clicked', {
+ selected_skill_identifier: 'resume-reviewer',
+ });
+ });
+
+ it('keeps the suggestion visible when installing the recommended skill fails', async () => {
+ marketApiMocks.searchSkill.mockResolvedValueOnce({
+ currentPage: 1,
+ items: [
+ {
+ createdAt: '2026-01-01',
+ description: 'Review and improve resumes with a reusable checklist.',
+ identifier: 'resume-reviewer',
+ installCount: 12,
+ name: 'Resume Reviewer',
+ updatedAt: '2026-01-01',
+ },
+ ],
+ pageSize: 3,
+ totalCount: 1,
+ totalPages: 1,
+ });
+ skillServiceMocks.importFromMarket.mockRejectedValueOnce(new Error('Import failed'));
+ const { onClose } = renderModal();
+
+ fireEvent.change(screen.getByLabelText('chat input'), {
+ target: { value: '帮我做一个简历优化检查清单' },
+ });
+ fireEvent.click(screen.getByText('Send'));
+
+ expect(await screen.findByText('This can use a Skill')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('Add Skill'));
+
+ await waitFor(() => {
+ expect(skillServiceMocks.importFromMarket).toHaveBeenCalledWith('resume-reviewer');
+ });
+ expect(toolStoreMocks.refreshAgentSkills).not.toHaveBeenCalled();
+ expect(onClose).not.toHaveBeenCalled();
+ await expectTrackedSkillSuggestionAction('install_failed', {
+ selected_skill_identifier: 'resume-reviewer',
+ });
+ expect(
+ await screen.findByText("Skill wasn't added. Retry, or create an Agent anyway."),
+ ).toBeInTheDocument();
+ });
});
diff --git a/src/routes/(main)/home/_layout/hooks/useCreateModal.tsx b/src/routes/(main)/home/_layout/hooks/useCreateModal.tsx
index 77eca848159..5425bac267a 100644
--- a/src/routes/(main)/home/_layout/hooks/useCreateModal.tsx
+++ b/src/routes/(main)/home/_layout/hooks/useCreateModal.tsx
@@ -1,7 +1,15 @@
import { ActionIcon, Block, Button, Flexbox, Text } from '@lobehub/ui';
import { Modal } from '@lobehub/ui/base-ui';
import { cssVar } from 'antd-style';
-import { Lightbulb, PencilLineIcon, RefreshCw, X } from 'lucide-react';
+import {
+ Blocks,
+ CheckCircle2,
+ Lightbulb,
+ Loader2,
+ PencilLineIcon,
+ RefreshCw,
+ X,
+} from 'lucide-react';
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -12,12 +20,183 @@ import {
DesktopChatInput,
} from '@/features/ChatInput';
import { useRandomQuestions } from '@/routes/(main)/home/features/SuggestQuestions/useRandomQuestions';
+import { agentSkillService } from '@/services/skill';
+import { useToolStore } from '@/store/tool';
+import type { DiscoverSkillItem } from '@/types/discover';
-import type { CreateAgentModalSubmitSource } from './createAgentModalAnalytics';
-import { trackCreateAgentModalCreationSucceeded } from './createAgentModalAnalytics';
+import {
+ type AgentSkillSuggestionResult,
+ searchAgentSkillSuggestion,
+} from './agentSkillSuggestion';
+import type {
+ CreateAgentModalSkillSuggestionAction,
+ CreateAgentModalSubmitSource,
+} from './createAgentModalAnalytics';
+import {
+ trackCreateAgentModalCreationSucceeded,
+ trackCreateAgentModalSkillSuggestionAction,
+} from './createAgentModalAnalytics';
const LEFT_ACTIONS: ActionKeys[] = ['model'];
+interface InstalledSkill {
+ identifier: string;
+ name: string;
+}
+
+interface SkillSuggestionPanelProps {
+ installError?: boolean;
+ installingIdentifier?: string;
+ items: DiscoverSkillItem[];
+ onContinueCreate: () => void;
+ onInstall: (identifier: string) => void;
+}
+
+const SkillSuggestionPanel = memo<SkillSuggestionPanelProps>(
+ ({ installError, installingIdentifier, items, onContinueCreate, onInstall }) => {
+ const { t } = useTranslation('chat');
+ const primarySkillIdentifier = items[0]?.identifier;
+ const installing = Boolean(installingIdentifier);
+
+ return (
+ <Flexbox
+ gap={12}
+ style={{
+ background: cssVar.colorFillQuaternary,
+ border: `1px solid ${cssVar.colorFillSecondary}`,
+ borderRadius: 12,
+ padding: 14,
+ }}
+ >
+ <Flexbox gap={4}>
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Blocks color={cssVar.colorTextSecondary} size={18} />
+ <Text fontSize={14} style={{ fontWeight: 600 }}>
+ {t('createModal.skillSuggestion.title')}
+ </Text>
+ </Flexbox>
+ <Text color={cssVar.colorTextSecondary} fontSize={13}>
+ {t('createModal.skillSuggestion.description')}
+ </Text>
+ </Flexbox>
+ <Flexbox gap={8}>
+ {items.map((item) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={12}
+ justify={'space-between'}
+ key={item.identifier}
+ style={{
+ background: cssVar.colorBgContainer,
+ border: `1px solid ${cssVar.colorFillTertiary}`,
+ borderRadius: 10,
+ padding: 10,
+ }}
+ >
+ <Flexbox flex={1} gap={4} style={{ minWidth: 0 }}>
+ <Text ellipsis fontSize={13} style={{ fontWeight: 500 }}>
+ {item.name}
+ </Text>
+ <Text color={cssVar.colorTextTertiary} ellipsis={{ rows: 2 }} fontSize={12}>
+ {item.description}
+ </Text>
+ </Flexbox>
+ <Button
+ disabled={installing}
+ icon={installingIdentifier === item.identifier ? <Loader2 size={14} /> : undefined}
+ size={'small'}
+ type={item.identifier === primarySkillIdentifier ? 'primary' : undefined}
+ onClick={() => onInstall(item.identifier)}
+ >
+ {t('createModal.skillSuggestion.actions.install')}
+ </Button>
+ </Flexbox>
+ ))}
+ </Flexbox>
+ {installError && (
+ <Text color={cssVar.colorError} fontSize={12}>
+ {t('createModal.skillSuggestion.installError')}
+ </Text>
+ )}
+ <Flexbox horizontal align={'center'} gap={8} justify={'flex-end'}>
+ <Text color={cssVar.colorTextTertiary} fontSize={12}>
+ {t('createModal.skillSuggestion.actions.createAnywayHint')}
+ </Text>
+ <Button disabled={installing} onClick={onContinueCreate}>
+ {t('createModal.skillSuggestion.actions.createAnyway')}
+ </Button>
+ </Flexbox>
+ </Flexbox>
+ );
+ },
+);
+
+interface SkillInstalledPanelProps {
+ onClose: () => void;
+ onOpenSkills?: (identifier: string) => void;
+ skill: InstalledSkill;
+}
+
+const SkillInstalledPanel = memo<SkillInstalledPanelProps>(({ onClose, onOpenSkills, skill }) => {
+ const { t } = useTranslation('chat');
+
+ return (
+ <Flexbox
+ gap={16}
+ style={{
+ background: cssVar.colorFillQuaternary,
+ border: `1px solid ${cssVar.colorFillSecondary}`,
+ borderRadius: 12,
+ padding: 16,
+ }}
+ >
+ <Flexbox gap={8}>
+ <Flexbox horizontal align={'center'} gap={8}>
+ <CheckCircle2 color={cssVar.colorSuccess} size={18} />
+ <Text fontSize={14} style={{ fontWeight: 600 }}>
+ {t('createModal.skillSuggestion.installed.title')}
+ </Text>
+ </Flexbox>
+ <Text color={cssVar.colorTextSecondary} fontSize={13}>
+ {t('createModal.skillSuggestion.installed.description')}
+ </Text>
+ </Flexbox>
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={12}
+ justify={'space-between'}
+ style={{
+ background: cssVar.colorBgContainer,
+ border: `1px solid ${cssVar.colorFillTertiary}`,
+ borderRadius: 10,
+ padding: 10,
+ }}
+ >
+ <Flexbox flex={1} gap={4} style={{ minWidth: 0 }}>
+ <Text ellipsis fontSize={13} style={{ fontWeight: 500 }}>
+ {skill.name}
+ </Text>
+ <Text color={cssVar.colorTextTertiary} fontSize={12}>
+ {skill.identifier}
+ </Text>
+ </Flexbox>
+ </Flexbox>
+ <Flexbox horizontal align={'center'} gap={8} justify={'flex-end'}>
+ {onOpenSkills && (
+ <Button onClick={() => onOpenSkills(skill.identifier)}>
+ {t('createModal.skillSuggestion.actions.openSkills')}
+ </Button>
+ )}
+ <Button type={'primary'} onClick={onClose}>
+ {t('createModal.skillSuggestion.actions.tryInLobeAI')}
+ </Button>
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
interface ExampleItemProps {
description: string;
onClick: (prompt: string) => void;
@@ -102,19 +281,28 @@ export interface CreateAgentModalProps {
agentId?: string;
onClose: () => void;
onCreateBlank: () => Promise<void> | void;
+ onOpenSkills?: (identifier: string) => void;
onSubmit: (prompt: string) => Promise<void> | void;
open: boolean;
type: 'agent' | 'group';
}
export const CreateAgentModal = memo<CreateAgentModalProps>(
- ({ open, type, agentId, onClose, onSubmit, onCreateBlank }) => {
+ ({ open, type, agentId, onClose, onOpenSkills, onSubmit, onCreateBlank }) => {
const { t } = useTranslation('chat');
const editorRef = useRef<ChatInputEditor | null>(null);
const contentRef = useRef('');
const examplePromptRef = useRef('');
+ const skipSkillSuggestionPromptRef = useRef('');
const submitSourceRef = useRef<CreateAgentModalSubmitSource>('manual');
+ const refreshAgentSkills = useToolStore((s) => s.refreshAgentSkills);
+ const [installedSkill, setInstalledSkill] = useState<InstalledSkill>();
+ const [installingSkillIdentifier, setInstallingSkillIdentifier] = useState<string>();
const [loading, setLoading] = useState(false);
+ const [skillInstallError, setSkillInstallError] = useState(false);
+ const [skillSuggestion, setSkillSuggestion] = useState<
+ (AgentSkillSuggestionResult & { prompt: string }) | undefined
+ >();
const isAgent = type === 'agent';
const modalTitle = isAgent ? t('createModal.title') : t('createModal.groupTitle');
@@ -122,15 +310,25 @@ export const CreateAgentModal = memo<CreateAgentModalProps>(
const resetInputTracking = useCallback(() => {
contentRef.current = '';
examplePromptRef.current = '';
+ skipSkillSuggestionPromptRef.current = '';
submitSourceRef.current = 'manual';
}, []);
useEffect(() => {
- if (open) resetInputTracking();
+ if (!open) return;
+ resetInputTracking();
+ setInstalledSkill(undefined);
+ setInstallingSkillIdentifier(undefined);
+ setSkillInstallError(false);
+ setSkillSuggestion(undefined);
}, [open, resetInputTracking]);
const handleClose = useCallback(() => {
resetInputTracking();
+ setInstalledSkill(undefined);
+ setInstallingSkillIdentifier(undefined);
+ setSkillInstallError(false);
+ setSkillSuggestion(undefined);
onClose();
}, [onClose, resetInputTracking]);
@@ -142,12 +340,52 @@ export const CreateAgentModal = memo<CreateAgentModalProps>(
return submitSourceRef.current;
}, []);
+ const trackSkillSuggestionAction = useCallback(
+ (
+ action: CreateAgentModalSkillSuggestionAction,
+ selectedSkillIdentifier?: string,
+ suggestion = skillSuggestion,
+ ) => {
+ if (!suggestion) return;
+
+ void trackCreateAgentModalSkillSuggestionAction({
+ action,
+ selectedSkillIdentifier,
+ skillIdentifiers: suggestion.items.map((item) => item.identifier),
+ source: getSubmitSource(suggestion.prompt),
+ });
+ },
+ [getSubmitSource, skillSuggestion],
+ );
+
const handleSubmit = useCallback(
async (prompt?: string) => {
const text = prompt || contentRef.current.trim();
if (!text || loading) return;
setLoading(true);
try {
+ const skipSkillSuggestion = skipSkillSuggestionPromptRef.current === text;
+ skipSkillSuggestionPromptRef.current = '';
+
+ if (isAgent && !skipSkillSuggestion) {
+ try {
+ const suggestion = await searchAgentSkillSuggestion(text);
+ if (suggestion) {
+ setInstalledSkill(undefined);
+ setSkillInstallError(false);
+ setSkillSuggestion({ ...suggestion, prompt: text });
+ void trackCreateAgentModalSkillSuggestionAction({
+ action: 'shown',
+ skillIdentifiers: suggestion.items.map((item) => item.identifier),
+ source: getSubmitSource(text),
+ });
+ return;
+ }
+ } catch (error) {
+ console.warn('[CreateAgentModal] Failed to search skill suggestions:', error);
+ }
+ }
+
await onSubmit(text);
void trackCreateAgentModalCreationSucceeded({
source: getSubmitSource(text),
@@ -158,9 +396,65 @@ export const CreateAgentModal = memo<CreateAgentModalProps>(
setLoading(false);
}
},
- [getSubmitSource, handleClose, loading, onSubmit, type],
+ [getSubmitSource, handleClose, isAgent, loading, onSubmit, type],
+ );
+
+ const handleContinueCreate = useCallback(() => {
+ const prompt = skillSuggestion?.prompt || contentRef.current.trim();
+ if (!prompt) return;
+ trackSkillSuggestionAction('create_agent_anyway_clicked');
+ skipSkillSuggestionPromptRef.current = prompt;
+ void handleSubmit(prompt);
+ }, [handleSubmit, skillSuggestion?.prompt, trackSkillSuggestionAction]);
+
+ const handleInstallSkill = useCallback(
+ async (identifier: string) => {
+ if (installingSkillIdentifier || loading) return;
+ trackSkillSuggestionAction('install_clicked', identifier);
+ setInstallingSkillIdentifier(identifier);
+ setSkillInstallError(false);
+ try {
+ const result = await agentSkillService.importFromMarket(identifier);
+ await refreshAgentSkills();
+ const marketSkill = skillSuggestion?.items.find((item) => item.identifier === identifier);
+ const skill = result?.skill;
+ setInstalledSkill({
+ identifier: skill?.identifier || marketSkill?.identifier || identifier,
+ name: skill?.name || marketSkill?.name || identifier,
+ });
+ trackSkillSuggestionAction('install_succeeded', identifier);
+ } catch (error) {
+ console.warn('[CreateAgentModal] Failed to import suggested skill:', error);
+ setSkillInstallError(true);
+ trackSkillSuggestionAction('install_failed', identifier);
+ } finally {
+ setInstallingSkillIdentifier(undefined);
+ }
+ },
+ [
+ installingSkillIdentifier,
+ loading,
+ refreshAgentSkills,
+ skillSuggestion?.items,
+ trackSkillSuggestionAction,
+ ],
);
+ const handleOpenInstalledSkill = useCallback(
+ (identifier: string) => {
+ trackSkillSuggestionAction('open_skills_clicked', identifier);
+ onOpenSkills?.(identifier);
+ },
+ [onOpenSkills, trackSkillSuggestionAction],
+ );
+
+ const handleTryInLobeAI = useCallback(() => {
+ if (installedSkill) {
+ trackSkillSuggestionAction('try_in_lobeai_clicked', installedSkill.identifier);
+ }
+ handleClose();
+ }, [handleClose, installedSkill, trackSkillSuggestionAction]);
+
const handleCreateBlank = useCallback(async () => {
if (loading) return;
setLoading(true);
@@ -223,18 +517,22 @@ export const CreateAgentModal = memo<CreateAgentModalProps>(
<Flexbox gap={24} paddingBlock={'16px 24px'} paddingInline={24}>
{/* Header: Create Blank + Close */}
<Flexbox horizontal align="center" gap={4} justify="flex-end">
- <Button icon={<PencilLineIcon size={14} />} type="text" onClick={handleCreateBlank}>
- {t('createModal.createBlank')}
- </Button>
+ {!installedSkill && (
+ <Button icon={<PencilLineIcon size={14} />} type="text" onClick={handleCreateBlank}>
+ {t('createModal.createBlank')}
+ </Button>
+ )}
<ActionIcon icon={X} onClick={handleClose} />
</Flexbox>
{/* Title */}
- <Flexbox align="center">
- <h3 style={{ fontSize: 20, fontWeight: 600, margin: 0 }}>{modalTitle}</h3>
- </Flexbox>
+ {!installedSkill && (
+ <Flexbox align="center">
+ <h3 style={{ fontSize: 20, fontWeight: 600, margin: 0 }}>{modalTitle}</h3>
+ </Flexbox>
+ )}
{/* ChatInput */}
- {open && (
+ {open && !installedSkill && (
<ChatInputProvider
agentId={agentId}
allowExpand={false}
@@ -247,6 +545,9 @@ export const CreateAgentModal = memo<CreateAgentModalProps>(
onMarkdownContentChange={(content) => {
contentRef.current = content;
const trimmedContent = content.trim();
+ if (skillSuggestion && trimmedContent !== skillSuggestion.prompt) {
+ setSkillSuggestion(undefined);
+ }
if (
examplePromptRef.current &&
(submitSourceRef.current === 'example' ||
@@ -267,8 +568,28 @@ export const CreateAgentModal = memo<CreateAgentModalProps>(
</ChatInputProvider>
)}
+ {isAgent && installedSkill && (
+ <SkillInstalledPanel
+ skill={installedSkill}
+ onClose={handleTryInLobeAI}
+ onOpenSkills={onOpenSkills ? handleOpenInstalledSkill : undefined}
+ />
+ )}
+
+ {isAgent && skillSuggestion && !installedSkill && (
+ <SkillSuggestionPanel
+ installError={skillInstallError}
+ installingIdentifier={installingSkillIdentifier}
+ items={skillSuggestion.items}
+ onContinueCreate={handleContinueCreate}
+ onInstall={handleInstallSkill}
+ />
+ )}
+
{/* Examples */}
- <Examples suggestMode={type} onExampleClick={handleExampleClick} />
+ {!skillSuggestion && !installedSkill && (
+ <Examples suggestMode={type} onExampleClick={handleExampleClick} />
+ )}
</Flexbox>
</Modal>
);
diff --git a/src/routes/(main)/settings/skill/index.tsx b/src/routes/(main)/settings/skill/index.tsx
index 37841f0bc70..c06239f2493 100644
--- a/src/routes/(main)/settings/skill/index.tsx
+++ b/src/routes/(main)/settings/skill/index.tsx
@@ -7,6 +7,7 @@ import isEqual from 'fast-deep-equal';
import { FileArchive, Grid2x2Plus, Link, Store } from 'lucide-react';
import { memo, useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useSearchParams } from 'react-router-dom';
import { CustomConnectorModal } from '@/features/Connectors';
import NavHeader from '@/features/NavHeader';
@@ -15,7 +16,7 @@ import ImportFromGithubModal from '@/features/SkillStore/SkillList/ImportFromGit
import ImportFromUrlModal from '@/features/SkillStore/SkillList/ImportFromUrlModal';
import UploadSkillModal from '@/features/SkillStore/SkillList/UploadSkillModal';
import { useToolStore } from '@/store/tool';
-import { builtinToolSelectors } from '@/store/tool/selectors';
+import { agentSkillsSelectors, builtinToolSelectors } from '@/store/tool/selectors';
import SkillDetail, { type ToolDetailType } from './features/SkillDetail';
import SkillList, { type SkillViewMode } from './features/SkillList';
@@ -86,8 +87,14 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
const Page = memo(() => {
const { t } = useTranslation('setting');
+ const [searchParams] = useSearchParams();
+ const queryViewMode: SkillViewMode =
+ searchParams.get('tab') === 'skill' || searchParams.get('view') === 'skill'
+ ? 'skill'
+ : 'connector';
+ const querySkillIdentifier = searchParams.get('skill');
const [selected, setSelected] = useState<SelectedTool | null>(null);
- const [viewMode, setViewMode] = useState<SkillViewMode>('connector');
+ const [viewMode, setViewMode] = useState<SkillViewMode>(queryViewMode);
const [showAddConnector, setShowAddConnector] = useState(false);
const [showUrlModal, setUrlModal] = useState(false);
const [showGithubModal, setGithubModal] = useState(false);
@@ -96,6 +103,8 @@ const Page = memo(() => {
// Data sources for auto-select
const builtinTools = useToolStore((s) => s.builtinTools, isEqual);
const builtinSkills = useToolStore((s) => s.builtinSkills, isEqual);
+ const marketAgentSkills = useToolStore(agentSkillsSelectors.getMarketAgentSkills, isEqual);
+ const userAgentSkills = useToolStore(agentSkillsSelectors.getUserAgentSkills, isEqual);
const installedBuiltinIds = useToolStore(
(s) => builtinToolSelectors.installedAllMetaList(s).map((tool) => tool.identifier),
isEqual,
@@ -105,8 +114,13 @@ const Page = memo(() => {
setSelected(null);
}, [viewMode]);
+ useEffect(() => {
+ setViewMode(queryViewMode);
+ }, [queryViewMode]);
+
useEffect(() => {
if (selected) return;
+ if (viewMode === 'skill' && querySkillIdentifier) return;
if (viewMode === 'connector') {
const firstTool = builtinTools.find(
(tool) => !tool.hidden && installedBuiltinIds.includes(tool.identifier),
@@ -120,7 +134,16 @@ const Page = memo(() => {
setSelected({ identifier: firstSkill.identifier, type: 'builtin-skill' });
}
}
- }, [builtinTools, builtinSkills, installedBuiltinIds, selected, viewMode]);
+ }, [builtinTools, builtinSkills, installedBuiltinIds, querySkillIdentifier, selected, viewMode]);
+
+ useEffect(() => {
+ if (viewMode !== 'skill' || !querySkillIdentifier) return;
+
+ const skill = [...marketAgentSkills, ...userAgentSkills].find(
+ (item) => item.identifier === querySkillIdentifier,
+ );
+ if (skill) setSelected({ identifier: skill.id, type: 'agent-skill' });
+ }, [marketAgentSkills, querySkillIdentifier, userAgentSkills, viewMode]);
const handleOpenStore = useCallback(() => {
createSkillStoreModal();