Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): prioritize official local skills
xd-bobodaccaae06383
diff --git a/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx b/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsxindex 6cb080c471..03ccdde6c5 100644--- a/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx+++ b/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx@@ -32,6 +32,7 @@ import { buildLocalSkillRoute, findLocalSkillByPath } from './lib/localRoutes';import {builtInSkillDescriptionKey,isBuiltInLearnSkillEnabled,+ prioritizeCindyBuiltInSkills,} from './lib/builtInSkillPresentation';import { refresh as refreshSkillhub, useSkillhub } from './hooks/useSkillhub';import {@@ -146,18 +147,20 @@ export function SkillhubHomeView({// 本地技能:global 一组 + 每个 project 一组(displayName 取自 store.projects,兜底 basename)。const globalSkills = useMemo(() =>- skills.filter(- (skill) => {- const descriptionKey = builtInSkillDescriptionKey(skill);- const displayDescription = descriptionKey ? t(descriptionKey) : skill.description;- return (- skill.scope === 'global' &&- includesSkillQuery(- [skill.name, displayDescription, skill.description, skill.kind, skill.engine],- normalizedQuery,- )- );- },+ prioritizeCindyBuiltInSkills(+ skills.filter(+ (skill) => {+ const descriptionKey = builtInSkillDescriptionKey(skill);+ const displayDescription = descriptionKey ? t(descriptionKey) : skill.description;+ return (+ skill.scope === 'global' &&+ includesSkillQuery(+ [skill.name, displayDescription, skill.description, skill.kind, skill.engine],+ normalizedQuery,+ )+ );+ },+ ),),[normalizedQuery, skills, t],);diff --git a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/builtInSkillPresentation.test.ts b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/builtInSkillPresentation.test.tsindex 83364071b2..49f1492b92 100644--- a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/builtInSkillPresentation.test.ts+++ b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/builtInSkillPresentation.test.ts@@ -1,7 +1,42 @@import { describe, expect, it } from 'vitest';import { CINDY_LEARN_SOURCE_DESCRIPTION } from '../../../../../shared/cindyBuiltInSkills';-import { isBuiltInLearnSkillEnabled } from '../builtInSkillPresentation';+import {+ isBuiltInLearnSkillEnabled,+ prioritizeCindyBuiltInSkills,+} from '../builtInSkillPresentation';++describe('prioritizeCindyBuiltInSkills', () => {+ it('puts Cindy official Skills first in their product order and keeps user order stable', () => {+ const userLearn = { name: 'learn', description: 'My workflow', scope: 'global' };+ const localA = { name: 'local-a', description: 'A', scope: 'global' };+ const builtInLearn = {+ name: 'learn',+ description: CINDY_LEARN_SOURCE_DESCRIPTION,+ scope: 'global',+ };+ const localB = { name: 'local-b', description: 'B', scope: 'global' };+ const builtInCreator = {+ name: 'cindy-skill-creator',+ builtIn: true,+ scope: 'global',+ };++ expect(prioritizeCindyBuiltInSkills([+ userLearn,+ localA,+ builtInLearn,+ localB,+ builtInCreator,+ ])).toEqual([+ builtInCreator,+ builtInLearn,+ userLearn,+ localA,+ localB,+ ]);+ });+});describe('isBuiltInLearnSkillEnabled', () => {it('waits for the local scan, then follows only the official Learn entry', () => {diff --git a/apps/desktop/src/renderer/features/skillhub/lib/builtInSkillPresentation.ts b/apps/desktop/src/renderer/features/skillhub/lib/builtInSkillPresentation.tsindex cb3f41c370..2605bdbb8c 100644--- a/apps/desktop/src/renderer/features/skillhub/lib/builtInSkillPresentation.ts+++ b/apps/desktop/src/renderer/features/skillhub/lib/builtInSkillPresentation.ts@@ -7,6 +7,11 @@ import {export const SKILL_CREATOR_DESCRIPTION_KEY = 'skillhub.builtIn.skillCreator.description' as const;export const LEARN_DESCRIPTION_KEY = 'skillhub.builtIn.learn.description' as const;+const BUILT_IN_SKILL_ORDER = new Map([+ [CINDY_SKILL_CREATOR_NAME, 0],+ [CINDY_LEARN_NAME, 1],+]);+/*** Built-in Skills keep their canonical metadata in English for agents. Cindy* substitutes localized copy only when it renders a known built-in entry.@@ -25,6 +30,28 @@ export function builtInSkillDescriptionKey(return undefined;}+/** Put Cindy's official Skills first while preserving the existing order of user Skills. */+export function prioritizeCindyBuiltInSkills<Skill extends {+ builtIn?: boolean;+ name: string;+ description?: string;+ scope?: string;+}>(skills: ReadonlyArray<Skill>): Skill[] {+ return skills+ .map((skill, index) => ({ skill, index }))+ .sort((left, right) => {+ const leftPriority = isCindyBuiltInSkillMetadata(left.skill)+ ? BUILT_IN_SKILL_ORDER.get(left.skill.name) ?? BUILT_IN_SKILL_ORDER.size+ : Number.POSITIVE_INFINITY;+ const rightPriority = isCindyBuiltInSkillMetadata(right.skill)+ ? BUILT_IN_SKILL_ORDER.get(right.skill.name) ?? BUILT_IN_SKILL_ORDER.size+ : Number.POSITIVE_INFINITY;+ if (leftPriority !== rightPriority) return leftPriority < rightPriority ? -1 : 1;+ return left.index - right.index;+ })+ .map(({ skill }) => skill);+}+/** Keep SkillHub's Learn shortcut aligned with the built-in Skill toggle. */export function isBuiltInLearnSkillEnabled(skills: ReadonlyArray<{