// 某个引擎可选的技能:Claude = 本地技能 + 已启用插件 + 第三方技能 + 自定义技能;Codex = Codex 实际可见的技能。 // 后台的 Profile 编辑与工作组的能力卡片共用 import { COMMUNITY_SKILL_PLUGIN, CUSTOM_SKILL_PLUGIN, type AppSettings, type ProviderId, type SkillInfo } from '@agent-server/shared' import type { CustomSkillService } from '../custom-skills/service' import { CodexProvider } from '../providers/codex/adapter' import type { AgentProvider } from '../providers/types' import type { CommunitySkillService } from './community-skills' import type { PluginService } from './plugins' export function createSkillCatalog(deps: { settings: () => AppSettings plugins: PluginService communitySkills: CommunitySkillService customSkills: CustomSkillService providers: Partial> }) { return async (engine: ProviderId): Promise => { if (engine !== 'codex') return [...await deps.plugins.skills(), ...deps.communitySkills.skillInfos().map(s => ({ ...s, optIn: true })), ...deps.customSkills.skillInfos()] const codex = deps.providers.codex if (!(codex instanceof CodexProvider)) return [] const infos = await codex.skillInfos(deps.settings()).catch(() => []) const excluded = new Set(deps.customSkills.excludedFromAll()) return infos.map(s => { const [prefix] = s.id.split(':') const source = s.scope === 'system' ? 'system' : prefix === 'openai-skills' ? 'official' : prefix === 'codex-user' ? 'plugin' : prefix === COMMUNITY_SKILL_PLUGIN ? 'community' : prefix === CUSTOM_SKILL_PLUGIN ? 'custom' : 'local' const optIn = source === 'community' || (source === 'custom' && excluded.has(s.id)) return { id: s.id, name: s.id.split(':').pop()!, description: s.description, plugin: prefix!, source, license: source === 'plugin' || source === 'system' ? 'unknown' : 'open', optIn } }) } }