JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(skill): ClawHub owner/slug origin, display_name uninstall, online source filter
NickFuryXXX6eb801f70ca0
diff --git a/jiuwenswarm/agents/harness/common/tools/skill_toolkits.py b/jiuwenswarm/agents/harness/common/tools/skill_toolkits.pyindex ff02b2efe3..18553724cb 100644--- a/jiuwenswarm/agents/harness/common/tools/skill_toolkits.py+++ b/jiuwenswarm/agents/harness/common/tools/skill_toolkits.py@@ -168,7 +168,18 @@ class SkillToolkit:if source == "skillnet" and local_source == "skillnet" and origin == target:return self._build_installed_item(name, "skillnet")if source == "clawhub" and local_source == "clawhub":- if origin == f"clawhub:{target}" or origin == target or name == target:+ # target 可为 owner/slug 或旧版纯 slug;禁止用展示名匹配,避免同名误判+ # 磁盘按 slug 唯一,故 owner/slug ↔ slug / 旧 origin 需互通,否则+ # Agent 纯 slug 安装会从 already_installed 退化为 download 失败。+ origin_cf = origin.casefold()+ target_cf = target.casefold()+ if origin_cf == f"clawhub:{target_cf}" or origin_cf == target_cf:+ return self._build_installed_item(name, "clawhub")+ slug_cf = target_cf.rsplit("/", 1)[-1]+ if slug_cf and (+ origin_cf == f"clawhub:{slug_cf}"+ or origin_cf.endswith(f"/{slug_cf}")+ ):return self._build_installed_item(name, "clawhub")if source == "teamskillshub" and local_source == "teamskillshub":if (@@ -185,8 +196,7 @@ class SkillToolkit:marketplace = str(plugin.get("marketplace", "")).strip()plugin_source = str(plugin.get("source", "")).strip()normalized_source = plugin_source or marketplace- if source == "clawhub" and normalized_source == "clawhub" and name == target:- return self._build_installed_item(name, "clawhub")+ # ClawHub 不按插件名匹配:同名不同发布者会误判已安装if source == "skillnet" and normalized_source == "skillnet" and name == target:return self._build_installed_item(name, "skillnet")if source == "teamskillshub" and normalized_source == "teamskillshub" and name == target:@@ -295,10 +305,17 @@ class SkillToolkit:skill_dir = str(meta.get("skill_dir", ""))skill_file = str(meta.get("skill_file", ""))identifier = ""+ display_name = ""for item in self._manager.get_local_skills():if item.get("name") == name:identifier = str(item.get("origin", "")).strip()+ display_name = str(item.get("display_name") or "").strip()break+ if not display_name:+ for plugin in self._manager.get_installed_plugins():+ if plugin.get("name") == name:+ display_name = str(plugin.get("display_name") or "").strip()+ breakout_source = sourceif out_source == "clawhub" and identifier.startswith("clawhub:"):identifier = identifier.split(":", 1)[1].strip()@@ -306,6 +323,7 @@ class SkillToolkit:identifier = identifier.split(":", 1)[1].strip()return {"name": name,+ "display_name": display_name or name,"description": description,"source": out_source,"identifier": identifier or name,@@ -317,6 +335,26 @@ class SkillToolkit:"skill_file": skill_file,}+ @staticmethod+ def _match_installed_item(items: list[dict[str, Any]], query: str) -> dict[str, Any] | None:+ """按内部名 / 展示名匹配已安装技能(大小写不敏感)。++ UI 可能展示 ClawHub 的 ``Weather``,而磁盘规范名是 ``weather``;+ Agent 也可能任一侧传入。必须同时覆盖,否则会误报未安装。+ """+ needle = str(query or "").strip()+ if not needle:+ return None+ needle_cf = needle.casefold()+ for item in items:+ name = str(item.get("name") or "").strip()+ display_name = str(item.get("display_name") or "").strip()+ if name == needle or display_name == needle:+ return item+ if name.casefold() == needle_cf or display_name.casefold() == needle_cf:+ return item+ return None+async def search_skill(self, query: str, source: str = _DEFAULT_SOURCE, limit: int = 10) -> dict[str, Any]:"""Search skills from SkillNet, ClawHub, and/or TeamSkillsHub with a unified response."""try:@@ -510,7 +548,8 @@ class SkillToolkit:clawhub_owner = ""if "/" in target:clawhub_owner, _, clawhub_slug = target.partition("/")- r = self._check_already_installed(clawhub_slug, resolved_source)+ check_id = f"{clawhub_owner}/{clawhub_slug}" if clawhub_owner else clawhub_slug+ r = self._check_already_installed(check_id, resolved_source)if r is not None:return rpayload = await self._manager.handle_skills_clawhub_download(@@ -587,11 +626,10 @@ class SkillToolkit:"detail": str(installed_payload.get("detail", "")).strip() or "failed to inspect installed skills",}- installed_item = None- for item in installed_payload.get("items", []):- if item.get("name") == skill_name:- installed_item = item- break+ installed_item = self._match_installed_item(+ list(installed_payload.get("items") or []),+ skill_name,+ )if installed_item is None:return {"success": False,@@ -600,7 +638,9 @@ class SkillToolkit:"detail": f"Skill `{skill_name}` is not installed.",}- payload = await self._manager.handle_skills_uninstall({"name": skill_name})+ # 实际卸载必须用磁盘规范名,避免展示名大小写导致删不到目录+ canonical_name = str(installed_item.get("name") or skill_name).strip()+ payload = await self._manager.handle_skills_uninstall({"name": canonical_name})except Exception as exc: # noqa: BLE001logger.exception("uninstall_skill failed")return {@@ -621,9 +661,10 @@ class SkillToolkit:return {"success": True,"removed": True,- "name": skill_name,+ "name": canonical_name,+ "display_name": str(installed_item.get("display_name") or canonical_name),"source": installed_item.get("source", "") if installed_item else "",- "detail": f"Skill `{skill_name}` uninstalled successfully.",+ "detail": f"Skill `{canonical_name}` uninstalled successfully.",}async def _list_installed_skills(self) -> dict[str, Any]:diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsxindex 706036fdd9..475587c3d2 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx@@ -16,6 +16,7 @@ import { PermissionWarningDialog } from './PermissionWarningDialog';import { ModelProviderIcon } from '../ModelProviderIcon';import { getEvolutionPillLabel } from './evolution-status';import { webRequest } from '../../services/webClient';+import { getSkillAvatar } from '../../utils/skillAvatar';import {isLikelyAbsolutePath,isProjectDirectoryPickerSupported,@@ -31,6 +32,8 @@ import { generateUuidV4 } from '../../utils/uuid';/** 输入栏下拉所需的最小技能数据结构(与 SkillPanel 中的 SkillItem 保持一致) */type InputAreaSkillItem = {name: string;+ /** 展示名(保留安装来源的原始大小写,如 ClawHub 的 Weather);缺省回退到 name */+ display_name?: string;description: string;source: string;is_builtin?: boolean;@@ -2422,32 +2425,6 @@ function SkillSelector({ onNavigateToSkills, onInsertSkill, onRemoveSkill }: {const [searchQuery, setSearchQuery] = useState('');const menuRef = useRef<HTMLDivElement>(null);- const avatarColors = [- 'bg-red-500',- 'bg-orange-500',- 'bg-amber-500',- 'bg-yellow-500',- 'bg-lime-500',- 'bg-green-500',- 'bg-emerald-500',- 'bg-teal-500',- 'bg-cyan-500',- 'bg-sky-500',- 'bg-blue-500',- 'bg-indigo-500',- 'bg-violet-500',- 'bg-purple-500',- 'bg-fuchsia-500',- 'bg-pink-500',- 'bg-rose-500',- ];-- const getSkillAvatar = (name: string) => {- const firstChar = name.charAt(0).toUpperCase();- const colorIndex = name.charCodeAt(0) % avatarColors.length;- return { firstChar, color: avatarColors[colorIndex] };- };-const installedSkillMap = useMemo(() => {const map = new Map<string, InputAreaInstalledPlugin>();plugins.forEach((plugin) => {@@ -2477,8 +2454,9 @@ function SkillSelector({ onNavigateToSkills, onInsertSkill, onRemoveSkill }: {if (!q) return installedSkills;return installedSkills.filter((s) => {const name = s.name.toLowerCase();+ const displayName = (s.display_name || '').toLowerCase();const desc = (s.description || '').toLowerCase();- return name.includes(q) || desc.includes(q);+ return name.includes(q) || displayName.includes(q) || desc.includes(q);});}, [installedSkills, searchQuery]);@@ -2621,7 +2599,7 @@ function SkillSelector({ onNavigateToSkills, onInsertSkill, onRemoveSkill }: {{avatar.firstChar}</div><div className="chat-skill-select__item-main">- <div className="chat-skill-select__item-name">{skill.name}</div>+ <div className="chat-skill-select__item-name">{skill.display_name || skill.name}</div><div className="chat-skill-select__item-desc">{skill.description || t('skills.noDescription')}</div>diff --git a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsxindex 212a328524..727e2470e1 100644--- a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx@@ -14,6 +14,7 @@ import { TeamSkillsHubModal } from "../../features/TeamSkillsHubModal";import { OnlineSkillSearchPanel } from "../../features/OnlineSkillSearchPanel";import { SkillEvolutionModal } from "../../features/SkillEvolutionModal";import { normalizeSkillNetUrl } from "../../utils/skillNetUrl";+import { getSkillAvatar } from "../../utils/skillAvatar";import { SkillGraphPanel, type SkillGraphPanelHandle } from "../SkillGraphPanel";import { MarkdownRenderer } from "../MarkdownRenderer";import { Switch } from "../Switch";@@ -27,6 +28,8 @@ const GRAPH_READING_MIN_VISIBLE_MS = 500;type SkillItem = {name: string;+ /** 展示名(保留安装来源的原始大小写,如 ClawHub 的 Weather);缺省回退到 name */+ display_name?: string;description: string;source: string;version: string;@@ -139,6 +142,9 @@ function getSourceLabel(source: string, t: (key: string) => string, isBuiltinSouif (source === "local") return t('skills.source.local');if (source === "project") return t('skills.source.project');if (source === "builtin") return t('skills.source.builtin');+ if (source === "clawhub") return t('skills.source.clawhub');+ if (source === "skillnet") return t('skills.source.skillnet');+ if (source === "teamskillshub") return t('skills.source.teamskillshub');return source || t('skills.source.unknown');}@@ -728,6 +734,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:return result.filter((skill) => {const haystack = [skill.name,+ skill.display_name,skill.description,skill.author,coerceStringList(skill.tags).join(" "),@@ -1207,32 +1214,6 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:[fetchSkills, handleBackToList, t, withSession]);- const avatarColors = [- "bg-red-500",- "bg-orange-500",- "bg-amber-500",- "bg-yellow-500",- "bg-lime-500",- "bg-green-500",- "bg-emerald-500",- "bg-teal-500",- "bg-cyan-500",- "bg-sky-500",- "bg-blue-500",- "bg-indigo-500",- "bg-violet-500",- "bg-purple-500",- "bg-fuchsia-500",- "bg-pink-500",- "bg-rose-500",- ];-- const getSkillAvatar = (name: string) => {- const firstChar = name.charAt(0).toUpperCase();- const colorIndex = name.charCodeAt(0) % avatarColors.length;- return { firstChar, color: avatarColors[colorIndex] };- };-const renderActionButton = (skill: SkillItem) => {const plugin = installedSkillMap.get(skill.name);@@ -1976,6 +1957,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:{listState === "success" && builtinSkills.length > 0 && (builtinSkills.map((skill) => {const avatar = getSkillAvatar(skill.name);+ const displayName = skill.display_name || skill.name;const isDisabled = skill.enabled === false;const isToggling = actionTarget === `toggle:${skill.name}`;const isInstalled = installedSkillMap.has(skill.name) || skill.source === "local";@@ -1995,7 +1977,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:</div><div className="min-w-0"><div className="text-base font-semibold text-text-strong">- {skill.name}+ {displayName}</div><div className="text-sm text-text-muted mt-1 line-clamp-3">{skill.description || t('skills.noDescription')}@@ -2031,7 +2013,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:</div><div className="min-w-0 flex-1"><div className="text-sm font-semibold text-text-strong truncate">- {skill.name}+ {displayName}</div><div className="text-xs text-text-muted mt-1 line-clamp-2">{skill.description || t('skills.noDescription')}@@ -2125,7 +2107,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:</div><div><div className="text-lg font-semibold text-text-strong">- {selectedSkill.name}+ {selectedSkill.display_name || selectedSkill.name}</div><div className="text-sm text-text-muted mt-1">{selectedSkill.description || t('skills.noDescription')}@@ -2257,6 +2239,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:{listState === "success" &&getMySkillsFiltered().map((skill) => {const avatar = getSkillAvatar(skill.name);+ const displayName = skill.display_name || skill.name;const isDisabled = skill.enabled === false;const isToggling = actionTarget === `toggle:${skill.name}`;return (@@ -2274,7 +2257,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:</div><div className="min-w-0"><div className="text-base font-semibold text-text-strong">- {skill.name}+ {displayName}</div><div className="text-sm text-text-muted mt-1 line-clamp-3">{skill.description || t('skills.noDescription')}@@ -2308,7 +2291,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:</div><div className="min-w-0 flex-1"><div className="text-sm font-semibold text-text-strong truncate">- {skill.name}+ {displayName}</div><div className="text-xs text-text-muted mt-1 line-clamp-2">{skill.description || t('skills.noDescription')}diff --git a/jiuwenswarm/channels/web/frontend/src/features/ClawHubSearchModal/index.tsx b/jiuwenswarm/channels/web/frontend/src/features/ClawHubSearchModal/index.tsxindex e3d5dc4039..add44eec64 100644--- a/jiuwenswarm/channels/web/frontend/src/features/ClawHubSearchModal/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/features/ClawHubSearchModal/index.tsx@@ -5,35 +5,11 @@import { useCallback, useEffect, useState } from "react";import { useTranslation } from "react-i18next";import { webRequest } from "../../services/webClient";+import { getSkillAvatar } from "../../utils/skillAvatar";+import { isClawHubOriginInstalled } from "../../utils/skillNetUrl";type LoadState = "idle" | "loading" | "success" | "error";-const avatarColors = [- "bg-red-500",- "bg-orange-500",- "bg-amber-500",- "bg-yellow-500",- "bg-lime-500",- "bg-green-500",- "bg-emerald-500",- "bg-teal-500",- "bg-cyan-500",- "bg-sky-500",- "bg-blue-500",- "bg-indigo-500",- "bg-violet-500",- "bg-purple-500",- "bg-fuchsia-500",- "bg-pink-500",- "bg-rose-500",-];--const getSkillAvatar = (name: string) => {- const firstChar = name.charAt(0).toUpperCase();- const colorIndex = name.charCodeAt(0) % avatarColors.length;- return { firstChar, color: avatarColors[colorIndex] };-};-type ClawHubSkillItem = {slug: string;display_name: string;@@ -64,7 +40,7 @@ export function ClawHubSearchModal({embedded = false,sessionId,externalSearchQuery,- installedSkillNames,+ installedSkillNames: _installedSkillNames,installedSkillOrigins,viewMode = "list",onClose,@@ -257,7 +233,12 @@ export function ClawHubSearchModal({skill?: { name: string };}>("skills.clawhub.download",- withSession({ slug, owner_handle: item.owner_handle, force: forceOverwrite })+ withSession({+ slug,+ owner_handle: item.owner_handle,+ ...(item.display_name ? { display_name: item.display_name } : {}),+ force: forceOverwrite,+ }));if (!data.success) {const message = data.detail_key@@ -281,8 +262,9 @@ export function ClawHubSearchModal({throw new Error(message);}const skillName = data.skill?.name || slug;- // 更新本地已安装状态- setInstalledSlugs(prev => new Set([...prev, slug]));+ // 更新本地已安装状态(含 owner,避免同 slug 误标)+ const installedKey = item.owner_handle ? `${item.owner_handle}/${slug}` : slug;+ setInstalledSlugs(prev => new Set([...prev, installedKey]));showMessage("success", t("skills.clawhub.messages.installed", { name: slug }));// 通知父组件刷新技能列�?await onInstalled?.(skillName);@@ -343,12 +325,15 @@ export function ClawHubSearchModal({<div className="text-sm text-text-muted">{t("skills.clawhub.noResults")}</div>) : (results.map((item) => {- const isInstalled = installedSlugs.has(item.slug) || (installedSkillNames?.has(item.slug) ?? false) || (installedSkillOrigins?.has(`clawhub:${item.slug}`) ?? false);+ const installedKey = item.owner_handle ? `${item.owner_handle}/${item.slug}` : item.slug;+ const isInstalled =+ installedSlugs.has(installedKey) ||+ isClawHubOriginInstalled(item.slug, item.owner_handle, installedSkillOrigins);const isInstalling = installingSlug === item.slug;- const avatar = getSkillAvatar(item.slug);+ const avatar = getSkillAvatar(item.display_name || item.slug);return (<div- key={item.owner_handle ? `${item.owner_handle}/${item.slug}` : item.slug}+ key={installedKey}className={`p-4 rounded-lg border border-border bg-panel ${viewMode === "grid" ? "flex flex-col" : "flex items-start justify-between gap-4"}`}style={viewMode === "grid" ? { width: "496px", height: "168px", flexShrink: 0 } : undefined}>@@ -636,13 +621,16 @@ export function ClawHubSearchModal({<div className="text-xs text-text-muted">{t("skills.clawhub.noResults")}</div>) : (results.map((item) => {- // 使用本地状态判断是否已安装(刚安装的会立即更新)- const isInstalled = installedSlugs.has(item.slug) || (installedSkillNames?.has(item.slug) ?? false) || (installedSkillOrigins?.has(`clawhub:${item.slug}`) ?? false);+ // 使用本地状态判断是否已安装(刚安装的会立即更新);按 owner+slug 精确匹配+ const installedKey = item.owner_handle ? `${item.owner_handle}/${item.slug}` : item.slug;+ const isInstalled =+ installedSlugs.has(installedKey) ||+ isClawHubOriginInstalled(item.slug, item.owner_handle, installedSkillOrigins);const isInstalling = installingSlug === item.slug;- const avatar = getSkillAvatar(item.slug);+ const avatar = getSkillAvatar(item.display_name || item.slug);return (<div- key={item.owner_handle ? `${item.owner_handle}/${item.slug}` : item.slug}+ key={installedKey}className="p-4 rounded-lg border border-border bg-panel flex items-start justify-between gap-4"><div className="flex items-center gap-3 min-w-0 flex-1">diff --git a/jiuwenswarm/channels/web/frontend/src/features/OnlineSkillSearchPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/features/OnlineSkillSearchPanel/index.tsxindex 9fd250a513..b8a8fc43eb 100644--- a/jiuwenswarm/channels/web/frontend/src/features/OnlineSkillSearchPanel/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/features/OnlineSkillSearchPanel/index.tsx@@ -1,8 +1,8 @@import { useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { webRequest } from '../../services/webClient';-import { normalizeSkillNetUrl } from '../../utils/skillNetUrl';-import { getSkillAvatar } from '../SkillNetSearchModal';+import { getSkillAvatar } from '../../utils/skillAvatar';+import { isClawHubOriginInstalled, normalizeSkillNetUrl } from '../../utils/skillNetUrl';type OnlineSource = 'skillnet' | 'clawhub';type LoadState = 'idle' | 'loading' | 'success' | 'error';@@ -14,6 +14,8 @@ type OnlineSearchItem = {identifier: string;version: string;author: string;+ /** ClawHub publisher; required for download when slug is shared by multiple owners. */+ owner_handle?: string;native_score?: number;category: string;updated_at: number;@@ -21,6 +23,11 @@ type OnlineSearchItem = {fusion_score: number;};+const onlineItemKey = (item: OnlineSearchItem) =>+ item.source === 'clawhub' && item.owner_handle+ ? `${item.source}:${item.owner_handle}/${item.identifier}`+ : `${item.source}:${item.identifier}`;+type OnlineSourceStatus = {source: OnlineSource;status: 'success' | 'error' | 'skipped';@@ -95,6 +102,9 @@ export function OnlineSkillSearchPanel({const [installingKey, setInstallingKey] = useState<string | null>(null);const [installedKeys, setInstalledKeys] = useState<Set<string>>(() => new Set());const [expandedKey, setExpandedKey] = useState<string | null>(null);+ const [enabledSources, setEnabledSources] = useState<Set<OnlineSource>>(+ () => new Set<OnlineSource>(['skillnet', 'clawhub'])+ );const requestSequenceRef = useRef(0);const installingKeyRef = useRef<string | null>(null);const installAbortControllerRef = useRef<AbortController | null>(null);@@ -161,12 +171,13 @@ export function OnlineSkillSearchPanel({const isInstalled = useCallback((item: OnlineSearchItem) => {- const key = `${item.source}:${item.identifier}`;+ const key = onlineItemKey(item);if (installedKeys.has(key)) return true;if (item.source === 'skillnet') {return item.identifier ? (installedSkillOrigins?.has(normalizeSkillNetUrl(item.identifier)) ?? false) : (installedSkillNames?.has(item.name) ?? false);}- return (installedSkillNames?.has(item.identifier) ?? false) || (installedSkillOrigins?.has(`clawhub:${item.identifier}`) ?? false);+ // ClawHub:按 owner+slug 精确匹配,避免同名 slug 全部显示已安装+ return isClawHubOriginInstalled(item.identifier, item.owner_handle, installedSkillOrigins);},[installedKeys, installedSkillNames, installedSkillOrigins]);@@ -200,7 +211,7 @@ export function OnlineSkillSearchPanel({const handleInstall = useCallback(async (item: OnlineSearchItem) => {- const key = `${item.source}:${item.identifier}`;+ const key = onlineItemKey(item);if (installingKeyRef.current) return;const abortController = new AbortController();@@ -226,7 +237,15 @@ export function OnlineSkillSearchPanel({}skillName = data.skill?.name || skillName;} else {- const data = await webRequest<InstallResponse>('skills.clawhub.download', withSession({ slug: item.identifier, force }));+ const data = await webRequest<InstallResponse>(+ 'skills.clawhub.download',+ withSession({+ slug: item.identifier,+ ...(item.owner_handle ? { owner_handle: item.owner_handle } : {}),+ ...(item.name ? { display_name: item.name } : {}),+ force,+ })+ );throwIfAborted(abortController.signal);if (!data.success) {if (!force && data.detail_key === 'skills.clawhub.errors.skillAlreadyInstalled') {@@ -265,6 +284,21 @@ export function OnlineSkillSearchPanel({[installSkillNet, onInstalled, t, withSession]);+ const toggleSourceFilter = useCallback((source: OnlineSource) => {+ setEnabledSources(prev => {+ const next = new Set(prev);+ if (next.has(source)) {+ if (next.size <= 1) return prev;+ next.delete(source);+ } else {+ next.add(source);+ }+ return next;+ });+ }, []);++ const visibleItems = items.filter(item => enabledSources.has(item.source));+return (<div className='flex h-full min-h-0 flex-col'>{message?.type === 'success' ? (@@ -287,23 +321,46 @@ export function OnlineSkillSearchPanel({<div className='mb-3 rounded-lg border border-warn/40 bg-warn/10 px-3 py-2 text-sm text-warn'>{t('skills.onlineSearch.partialFailure')}</div>) : null}{sourceStatuses.length > 0 ? (- <div className='mb-3 flex flex-wrap gap-2 text-xs'>+ <div className='mb-3 flex flex-wrap items-center gap-2 text-xs'>{sourceStatuses.map(sourceStatus => {const sourceLabel = sourceStatus.source === 'skillnet' ? 'SkillNet' : 'ClawHub';const statusLabel = t(`skills.onlineSearch.sourceStatus.${sourceStatus.status}`, { count: sourceStatus.count });const detail = sourceStatus.detail_key ? t(sourceStatus.detail_key) : sourceStatus.detail;- const statusClass =- sourceStatus.status === 'success'+ const selected = enabledSources.has(sourceStatus.source);+ const isLastSelected = selected && enabledSources.size <= 1;+ const statusClass = !selected+ ? 'border-border bg-secondary text-text-muted opacity-60'+ : sourceStatus.status === 'success'? 'border-[color:var(--color-border-success)] bg-ok-subtle text-ok': sourceStatus.status === 'error'? 'border-danger/40 bg-danger/10 text-danger': 'border-border bg-secondary text-text-muted';return (- <span key={sourceStatus.source} title={detail || undefined} className={`rounded-full border px-2 py-1 ${statusClass}`}>+ <button+ key={sourceStatus.source}+ type='button'+ aria-pressed={selected}+ title={+ isLastSelected+ ? t('skills.onlineSearch.sourceFilterKeepOne')+ : detail || t('skills.onlineSearch.sourceFilterToggle')+ }+ onClick={() => toggleSourceFilter(sourceStatus.source)}+ className={`rounded-full border px-2 py-1 transition-opacity ${statusClass} ${+ isLastSelected ? 'cursor-default' : 'cursor-pointer hover:opacity-90'+ }`}+ >{sourceLabel}: {statusLabel}- </span>+ </button>);})}+ <span+ className='inline-flex h-4 w-4 items-center justify-center rounded-full border border-border text-[10px] font-normal text-text-muted cursor-help'+ title={t('skills.onlineSearch.sourceFilterHelp') ?? undefined}+ aria-label={t('skills.onlineSearch.sourceFilterHelp')}+ >+ ?+ </span></div>) : null}@@ -311,10 +368,13 @@ export function OnlineSkillSearchPanel({{loadState === 'loading' ? <div className='flex h-full items-center justify-center text-text-muted'>{t('common.loading')}</div> : null}{loadState === 'error' && !message ? <div className='text-sm text-text-muted'>{t('skills.onlineSearch.searchFailed')}</div> : null}{loadState === 'success' && items.length === 0 ? <div className='text-sm text-text-muted'>{t('skills.onlineSearch.noResults')}</div> : null}- {loadState === 'success' && items.length > 0 ? (+ {loadState === 'success' && items.length > 0 && visibleItems.length === 0 ? (+ <div className='text-sm text-text-muted'>{t('skills.onlineSearch.noFilteredResults')}</div>+ ) : null}+ {loadState === 'success' && visibleItems.length > 0 ? (<div className={`mt-4 min-h-0 flex-1 overflow-y-auto ${viewMode === 'grid' ? 'flex flex-wrap content-start gap-4' : 'space-y-3'}`}>- {items.map(item => {- const key = `${item.source}:${item.identifier}`;+ {visibleItems.map(item => {+ const key = onlineItemKey(item);const installed = isInstalled(item);const installing = installingKey === key;const isSkillNet = item.source === 'skillnet';diff --git a/jiuwenswarm/channels/web/frontend/src/features/SkillNetSearchModal/index.tsx b/jiuwenswarm/channels/web/frontend/src/features/SkillNetSearchModal/index.tsxindex a394d9ab35..6b2a3819b0 100644--- a/jiuwenswarm/channels/web/frontend/src/features/SkillNetSearchModal/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/features/SkillNetSearchModal/index.tsx@@ -6,40 +6,17 @@ import { useCallback, useEffect, useRef, useState } from "react";import { Trans, useTranslation } from "react-i18next";import { webRequest } from "../../services/webClient";import type { WebError } from "../../types/websocket";+import { getSkillAvatar } from "../../utils/skillAvatar";import { normalizeSkillNetUrl } from "../../utils/skillNetUrl";+export { getSkillAvatar } from "../../utils/skillAvatar";+const SKILLNET_UPSTREAM_REPO_URL = "https://github.com/zjunlp/SkillNet";/** 同时进行的 SkillNet 安装任务上限(与后端 asyncio 能力匹配,避免前端狂点拖垮) */const SKILLNET_MAX_CONCURRENT_INSTALLS = 5;/** SkillNet「评估」入口:暂时隐藏;后端 `skills.skillnet.evaluate` 仍可用,改回 true 即恢复按钮 */const SKILLNET_EVALUATE_BUTTON_ENABLED = false;-const avatarColors = [- "bg-red-500",- "bg-orange-500",- "bg-amber-500",- "bg-yellow-500",- "bg-lime-500",- "bg-green-500",- "bg-emerald-500",- "bg-teal-500",- "bg-cyan-500",- "bg-sky-500",- "bg-blue-500",- "bg-indigo-500",- "bg-violet-500",- "bg-purple-500",- "bg-fuchsia-500",- "bg-pink-500",- "bg-rose-500",-];--export const getSkillAvatar = (name: string) => {- const firstChar = name.charAt(0).toUpperCase();- const colorIndex = name.charCodeAt(0) % avatarColors.length;- return { firstChar, color: avatarColors[colorIndex] };-};-/** 评估结果展示顺序(与 skillnet-ai 五维一致) */const EVAL_DIMENSION_KEYS = ["safety",diff --git a/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsx b/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsxindex 3bdf43d817..f989256617 100644--- a/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsx@@ -4,38 +4,13 @@import { useCallback, useEffect, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { webRequest } from "../../services/webClient";+import { getSkillAvatar } from "../../utils/skillAvatar";/** 与后端 TEAM_SKILLS_HUB_BASE_URL 默认值一致(info 请求失败时的回退) */const DEFAULT_TEAMSKILLS_HUB_BASE_URL = "https://teamskills.openjiuwen.com";type LoadState = "idle" | "loading" | "success" | "error";-const avatarColors = [- "bg-red-500",- "bg-orange-500",- "bg-amber-500",- "bg-yellow-500",- "bg-lime-500",- "bg-green-500",- "bg-emerald-500",- "bg-teal-500",- "bg-cyan-500",- "bg-sky-500",- "bg-blue-500",- "bg-indigo-500",- "bg-violet-500",- "bg-purple-500",- "bg-fuchsia-500",- "bg-pink-500",- "bg-rose-500",-];--const getSkillAvatar = (name: string) => {- const firstChar = name.charAt(0).toUpperCase();- const colorIndex = name.charCodeAt(0) % avatarColors.length;- return { firstChar, color: avatarColors[colorIndex] };-};-type TeamSkillsHubSkillItem = {asset_id: string;name: string;diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.jsonindex edf3a3ec9f..0b8ca29f82 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json@@ -1451,7 +1451,11 @@"success": "Available ({{count}})","error": "Unavailable","skipped": "Not configured"- }+ },+ "sourceFilterHelp": "SkillNet and ClawHub are shown by default. Click a source chip to filter results; keep at least one source selected.",+ "sourceFilterToggle": "Click to filter this source",+ "sourceFilterKeepOne": "Keep at least one source selected",+ "noFilteredResults": "No results for the current source filter. Select another source."},"actions": {"install": "Install",@@ -1474,6 +1478,9 @@"local": "Local","project": "Project","builtin": "Built-in",+ "clawhub": "ClawHub",+ "skillnet": "SkillNet",+ "teamskillshub": "TeamSkillsHub","unknown": "Unknown"},"sourceLabel": "Source",diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.jsonindex d1d28e5d76..874ba3f17c 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json@@ -1452,7 +1452,11 @@"success": "可用({{count}})","error": "不可用","skipped": "未配置"- }+ },+ "sourceFilterHelp": "默认同时展示 SkillNet 与 ClawHub。点击源标签可筛选结果;至少保留一个源。",+ "sourceFilterToggle": "点击筛选该源",+ "sourceFilterKeepOne": "至少保留一个源",+ "noFilteredResults": "当前筛选条件下没有结果,请重新选择源。"},"actions": {"install": "安装",@@ -1475,6 +1479,9 @@"local": "本地","project": "项目","builtin": "内置",+ "clawhub": "ClawHub",+ "skillnet": "SkillNet",+ "teamskillshub": "TeamSkillsHub","unknown": "未知"},"sourceLabel": "来源",diff --git a/jiuwenswarm/channels/web/frontend/src/utils/skillAvatar.ts b/jiuwenswarm/channels/web/frontend/src/utils/skillAvatar.tsnew file mode 100644index 0000000000..5025659cc8--- /dev/null+++ b/jiuwenswarm/channels/web/frontend/src/utils/skillAvatar.ts@@ -0,0 +1,28 @@+const avatarColors = [+ "bg-red-500",+ "bg-orange-500",+ "bg-amber-500",+ "bg-yellow-500",+ "bg-lime-500",+ "bg-green-500",+ "bg-emerald-500",+ "bg-teal-500",+ "bg-cyan-500",+ "bg-sky-500",+ "bg-blue-500",+ "bg-indigo-500",+ "bg-violet-500",+ "bg-purple-500",+ "bg-fuchsia-500",+ "bg-pink-500",+ "bg-rose-500",+];++/** 技能头像:展示字母大写;颜色按首字母小写哈希,避免 Weather/weather 颜色不一致。 */+export function getSkillAvatar(name: string): { firstChar: string; color: string } {+ const trimmed = String(name || "").trim() || "?";+ const firstChar = trimmed.charAt(0).toUpperCase();+ const colorSeed = trimmed.charAt(0).toLowerCase().charCodeAt(0) || 0;+ const colorIndex = colorSeed % avatarColors.length;+ return { firstChar, color: avatarColors[colorIndex] };+}diff --git a/jiuwenswarm/channels/web/frontend/src/utils/skillNetUrl.ts b/jiuwenswarm/channels/web/frontend/src/utils/skillNetUrl.tsindex e9bb17a2b9..3e5c7ac39a 100644--- a/jiuwenswarm/channels/web/frontend/src/utils/skillNetUrl.ts+++ b/jiuwenswarm/channels/web/frontend/src/utils/skillNetUrl.ts@@ -20,3 +20,37 @@ export function normalizeSkillNetUrl(raw: string): string {return s.replace(/\/$/, "").toLowerCase();}}++/** ClawHub 本地 skills[].origin:有发布者时用 clawhub:owner/slug,避免同名 slug 误判已安装。 */+export function buildClawHubOrigin(slug: string, ownerHandle?: string | null): string {+ const s = String(slug || "").trim();+ const owner = String(ownerHandle || "").trim();+ if (!s) return "";+ return owner ? `clawhub:${owner}/${s}` : `clawhub:${s}`;+}++/** 判断 ClawHub 搜索结果是否已安装:优先 owner+slug,并兼容旧版 clawhub:slug / 缺 owner 时的 owner/slug。 */+export function isClawHubOriginInstalled(+ slug: string,+ ownerHandle: string | null | undefined,+ installedOrigins: ReadonlySet<string> | undefined+): boolean {+ if (!installedOrigins?.size) return false;+ const s = String(slug || "").trim();+ if (!s) return false;+ const owner = String(ownerHandle || "").trim();+ const legacyOrigin = normalizeSkillNetUrl(buildClawHubOrigin(s));+ if (owner) {+ if (installedOrigins.has(normalizeSkillNetUrl(buildClawHubOrigin(s, owner)))) return true;+ // 升级前记录可能仍是 clawhub:slug(磁盘按 slug 唯一)+ return installedOrigins.has(legacyOrigin);+ }+ if (installedOrigins.has(legacyOrigin)) return true;+ // 搜索项缺 owner 时,兼容新安装写入的 clawhub:owner/slug+ const slugCf = s.toLowerCase();+ for (const origin of installedOrigins) {+ const n = normalizeSkillNetUrl(origin);+ if (n.startsWith("clawhub:") && n.endsWith(`/${slugCf}`)) return true;+ }+ return false;+}diff --git a/jiuwenswarm/server/runtime/skill/skill_manager.py b/jiuwenswarm/server/runtime/skill/skill_manager.pyindex b73fc22fb4..f0a1c7eec8 100644--- a/jiuwenswarm/server/runtime/skill/skill_manager.py+++ b/jiuwenswarm/server/runtime/skill/skill_manager.py@@ -516,6 +516,7 @@ class SkillManager:meta["content"] = meta.pop("body", "")meta["file_path"] = meta.pop("path", "")meta["source"] = self._resolve_skill_source(meta.get("name", ""))+ meta["display_name"] = self._resolve_skill_display_name(meta.get("name", ""))meta["is_builtin"] = self._is_builtin_skill(meta.get("name", ""), self._get_installed_plugins(), child)builtin_dir = get_builtin_skills_dir()if builtin_dir.exists():@@ -935,14 +936,16 @@ class SkillManager:description = str(item.get("summary") or "").strip()identifier = str(item.get("slug") or "").strip()version = str(item.get("version") or "").strip()- author = ""+ owner_handle = str(item.get("owner_handle") or "").strip()+ # ClawHub download needs ownerHandle when the same slug has multiple publishers.+ author = owner_handlenative_score = item.get("score")category = ""updated_at = item.get("updated_at") or 0else:raise ValueError(f"unsupported online search source: {source}")- return {+ normalized: dict[str, Any] = {"source": source,"name": name,"description": description,@@ -962,6 +965,11 @@ class SkillManager:}],}+ if source == "clawhub":+ normalized["owner_handle"] = owner_handle+ if owner_handle:+ normalized["matched_sources"][0]["owner_handle"] = owner_handle+ return normalized@classmethoddef _aggregate_online_search_results(@@ -978,10 +986,13 @@ class SkillManager:item = cls._normalize_online_search_item(source, raw_item, rank)if not item["identifier"] and not item["name"]:continue- identity = cls._normalize_online_search_identifier(- source,- item["identifier"] or item["name"],- )+ identity_value = item["identifier"] or item["name"]+ if source == "clawhub":+ owner_handle = str(item.get("owner_handle") or "").strip()+ if owner_handle and identity_value:+ # Keep ambiguous slugs from different publishers as distinct results.+ identity_value = f"{owner_handle}/{identity_value}"+ identity = cls._normalize_online_search_identifier(source, identity_value)existing = merged.get(identity)if existing is None:merged[identity] = item@@ -1375,6 +1386,7 @@ class SkillManager:params:slug: skill slug (必需)owner_handle: 发布者标识 (可选,slug 有多个发布者时必需)+ display_name: 目录展示名 (可选;用于保留 ClawHub 大小写,避免安装后 Weather→weather)version: 版本号 (可选,默认 latest)tag: 标签 (可选,如 latest)force: 强制覆盖 (可选,默认 False)@@ -1397,6 +1409,7 @@ class SkillManager:}owner_handle = str(params.get("owner_handle") or "").strip()+ display_name = str(params.get("display_name") or "").strip()version = params.get("version")tag = params.get("tag")force = bool(params.get("force", False))@@ -1480,14 +1493,27 @@ class SkillManager:mirror_root.mkdir(parents=True, exist_ok=True)shutil.copytree(skill_dir, mirror_dest)- # 记录安装信息- parsed_name = meta.get("name", "")- skill_name = parsed_name if (parsed_name and parsed_name != (md.stem if md else "")) else slug+ # skill_name 必须与磁盘扫描出的规范名(_resolve_skill_name)保持一致,+ # 否则会被 _register_unmanaged_local_skills 当作"未登记的本地技能"+ # 重复注册一条 source=local 的幽灵记录(表现为大小写不一致 + 重复条目)。+ # 展示层面的大小写差异(如 Weather vs weather)改为通过 display_name 单独承载。+ parsed_name = str(meta.get("name") or "").strip()+ stem = md.stem if md else ""+ if parsed_name and parsed_name != stem:+ skill_name = parsed_name+ else:+ skill_name = slug+ resolved_display_name = display_name if display_name else skill_nameself._add_local_skill({"name": skill_name,- "origin": f"clawhub:{slug}",+ "display_name": resolved_display_name,+ "origin": (+ f"clawhub:{owner_handle}/{slug}"+ if owner_handle+ else f"clawhub:{slug}"+ ),"source": "clawhub","installed_at": datetime.now(timezone.utc).isoformat(),}@@ -1495,6 +1521,7 @@ class SkillManager:self._add_installed_plugin({"name": skill_name,+ "display_name": resolved_display_name,"marketplace": "clawhub","version": meta.get("version", ""),"commit": "",@@ -1506,7 +1533,11 @@ class SkillManager:_safe_rmtree(skill_dir)return {"success": True,- "skill": {"name": skill_name, "source": "clawhub"},+ "skill": {+ "name": skill_name,+ "display_name": resolved_display_name,+ "source": "clawhub",+ },}except httpx.HTTPStatusError as exc:@@ -2758,9 +2789,14 @@ class SkillManager:origin = ls.get("origin")if isinstance(origin, str) and origin.strip():meta["origin"] = origin.strip()+ display_name = ls.get("display_name")+ if isinstance(display_name, str) and display_name.strip():+ meta["display_name"] = display_name.strip()breakmeta["source"] = source+ if not str(meta.get("display_name") or "").strip():+ meta["display_name"] = meta.get("name", "")meta["installed"] = Truemeta["enabled"] = self.get_skill_enabled(meta.get("name", ""))# 判断是否为内置技能(传入 child 路径,通过实际路径判断)@@ -2843,6 +2879,24 @@ class SkillManager:return "project"+ def _resolve_skill_display_name(self, skill_name: str) -> str:+ """解析 skill 展示名(优先 local_skills/installed_plugins 记录的 display_name)."""+ if not skill_name:+ return skill_name+ for local_skill in self._state.get("local_skills", []):+ if local_skill.get("name") == skill_name:+ display_name = str(local_skill.get("display_name") or "").strip()+ if display_name:+ return display_name+ break+ for plugin in self._get_installed_plugins():+ if plugin.get("name") == skill_name:+ display_name = str(plugin.get("display_name") or "").strip()+ if display_name:+ return display_name+ break+ return skill_name+def _resolve_local_skill_dir(self, skill_name: str) -> Path | None:"""根据 skill name 定位本地技能目录(仅 agent/skills 下)."""try:diff --git a/tests/unit_tests/agentserver/test_skill_manager_clawhub_owner_handle.py b/tests/unit_tests/agentserver/test_skill_manager_clawhub_owner_handle.pyindex d07baa5419..730e8ffbc3 100644--- a/tests/unit_tests/agentserver/test_skill_manager_clawhub_owner_handle.py+++ b/tests/unit_tests/agentserver/test_skill_manager_clawhub_owner_handle.py@@ -75,6 +75,17 @@ class _FakeDownloadClient:return self._captured_params+def _zip_bytes(entries: dict[str, str | bytes]) -> bytes:+ import io+ import zipfile++ buf = io.BytesIO()+ with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf:+ for name, content in entries.items():+ zf.writestr(name, content)+ return buf.getvalue()++@pytest.mark.asyncioasync def test_clawhub_search_returns_owner_handle(tmp_path, monkeypatch):manager = SkillManager(workspace_dir=str(tmp_path / "workspace"))@@ -198,6 +209,62 @@ async def test_clawhub_download_empty_owner_handle_omits_param(tmp_path, monkeypassert "ownerHandle" not in captured+async def test_clawhub_download_records_owner_qualified_origin(tmp_path, monkeypatch):+ manager = SkillManager(workspace_dir=str(tmp_path / "workspace"))+ await manager.handle_skills_clawhub_set_token({"token": "test-token"})++ zip_content = _zip_bytes(+ {+ "weather/SKILL.md": "---\nname: weather\nversion: 1.0.0\n---\nbody\n",+ }+ )+ fake_client = _FakeDownloadClient(status_code=200, content=zip_content)+ monkeypatch.setattr(+ "jiuwenswarm.server.runtime.skill.skill_manager.httpx.AsyncClient",+ lambda timeout: fake_client,+ )++ result = await manager.handle_skills_clawhub_download(+ {"slug": "weather", "owner_handle": "openclaw", "display_name": "Weather"}+ )++ assert result["success"] is True+ # 内部标识名须与磁盘解析出的规范名一致(此处等于 slug),+ # 否则会被自动扫描逻辑当作"未登记的本地技能"重复注册一条幽灵记录。+ assert result["skill"]["name"] == "weather"+ assert result["skill"]["display_name"] == "Weather"+ local = manager.get_local_skills()+ assert any(+ item.get("origin") == "clawhub:openclaw/weather" and item.get("name") == "weather"+ for item in local+ )+ assert any(item.get("display_name") == "Weather" for item in local)+++async def test_clawhub_download_without_owner_keeps_slug_origin(tmp_path, monkeypatch):+ manager = SkillManager(workspace_dir=str(tmp_path / "workspace"))+ await manager.handle_skills_clawhub_set_token({"token": "test-token"})++ zip_content = _zip_bytes(+ {+ "unique-skill/SKILL.md": "---\nname: unique-skill\nversion: 1.0.0\n---\nbody\n",+ }+ )+ fake_client = _FakeDownloadClient(status_code=200, content=zip_content)+ monkeypatch.setattr(+ "jiuwenswarm.server.runtime.skill.skill_manager.httpx.AsyncClient",+ lambda timeout: fake_client,+ )++ result = await manager.handle_skills_clawhub_download({"slug": "unique-skill"})++ assert result["success"] is True+ local = manager.get_local_skills()+ assert any(item.get("origin") == "clawhub:unique-skill" for item in local)++@pytest.mark.asyncioasync def test_install_skill_parses_owner_handle_from_identifier(tmp_path, monkeypatch):from jiuwenswarm.agents.harness.common.tools.skill_toolkits import SkillToolkitdiff --git a/tests/unit_tests/agentserver/test_skill_manager_online_search.py b/tests/unit_tests/agentserver/test_skill_manager_online_search.pyindex 31a0437b85..b7f3be1429 100644--- a/tests/unit_tests/agentserver/test_skill_manager_online_search.py+++ b/tests/unit_tests/agentserver/test_skill_manager_online_search.py@@ -18,13 +18,14 @@ def _skillnet_item(name: str, rank_marker: str) -> dict:}-def _clawhub_item(name: str, rank_marker: str) -> dict:+def _clawhub_item(name: str, rank_marker: str, owner_handle: str = "") -> dict:return {"slug": name,"display_name": name,"summary": f"ClawHub {rank_marker}","version": "1.0.0","updated_at": 1_750_000_000_000,+ "owner_handle": owner_handle,}@@ -164,6 +165,39 @@ def test_online_search_native_score_preserves_zero_and_falls_back_for_none():assert missing_score["native_score"] == 12+def test_online_search_preserves_clawhub_owner_handle():+ item = SkillManager._normalize_online_search_item(+ "clawhub",+ _clawhub_item("weather", "first", owner_handle="openclaw"),+ 1,+ )++ assert item["identifier"] == "weather"+ assert item["owner_handle"] == "openclaw"+ assert item["author"] == "openclaw"+ assert item["matched_sources"][0]["owner_handle"] == "openclaw"+++def test_online_search_keeps_ambiguous_clawhub_slugs_distinct():+ items = SkillManager._aggregate_online_search_results(+ "weather",+ {+ "skillnet": [],+ "clawhub": [+ _clawhub_item("weather", "first", owner_handle="owner-a"),+ _clawhub_item("weather", "second", owner_handle="owner-b"),+ ],+ },+ 10,+ )++ assert len(items) == 2+ assert {(item["identifier"], item["owner_handle"]) for item in items} == {+ ("weather", "owner-a"),+ ("weather", "owner-b"),+ }++def test_online_search_merges_identical_normalized_urls():items = SkillManager._aggregate_online_search_results("shared",diff --git a/tests/unit_tests/agentserver/test_skill_toolkits.py b/tests/unit_tests/agentserver/test_skill_toolkits.pyindex 695b85db1d..b4d7d0e7ca 100644--- a/tests/unit_tests/agentserver/test_skill_toolkits.py+++ b/tests/unit_tests/agentserver/test_skill_toolkits.py@@ -35,6 +35,116 @@ def test_uninstall_skill_removes_local_skill_without_plugin_record(tmp_path):assert manager.get_local_skills() == []+def test_uninstall_skill_matches_display_name_case_insensitively(tmp_path, monkeypatch):+ """UI/Agent 可能传入 Weather,内部规范名是 weather,应能成功卸载。"""+ import io+ import zipfile++ manager = SkillManager(workspace_dir=str(tmp_path / "workspace"))+ toolkit = SkillToolkit(manager)++ buf = io.BytesIO()+ with zipfile.ZipFile(buf, "w") as zf:+ zf.writestr(+ "weather/SKILL.md",+ "---\nname: weather\ndescription: Get weather\nversion: 1.0.0\n---\nbody\n",+ )+ zip_content = buf.getvalue()++ class _Resp:+ status_code = 200+ content = zip_content++ def raise_for_status(self):+ return None++ class _Client:+ async def __aenter__(self):+ return self++ async def __aexit__(self, *args):+ return False++ async def get(self, url, *, params, headers):+ return _Resp()++ monkeypatch.setattr(+ "jiuwenswarm.server.runtime.skill.skill_manager.httpx.AsyncClient",+ lambda timeout: _Client(),+ )+ asyncio.run(manager.handle_skills_clawhub_set_token({"token": "t"}))+ installed = asyncio.run(+ manager.handle_skills_clawhub_download(+ {"slug": "weather", "owner_handle": "steipete", "display_name": "Weather"}+ )+ )+ assert installed["success"] is True+ assert installed["skill"]["name"] == "weather"+ assert installed["skill"]["display_name"] == "Weather"++ # 用展示名大小写卸载+ result = asyncio.run(toolkit.uninstall_skill("Weather"))+ assert result["success"] is True+ assert result["removed"] is True+ assert result["name"] == "weather"+ assert not (tmp_path / "workspace" / "skills" / "weather").exists()+++def test_find_installed_by_target_clawhub_owner_slug_interops_with_plain_slug(tmp_path):+ """新 origin=clawhub:owner/slug 时,纯 slug / 旧 origin 都应判已安装。"""+ manager = SkillManager(workspace_dir=str(tmp_path / "workspace"))+ toolkit = SkillToolkit(manager)+ manager._add_local_skill(+ {+ "name": "weather",+ "display_name": "Weather",+ "origin": "clawhub:steipete/weather",+ "source": "clawhub",+ }+ )++ by_owner = toolkit._find_installed_by_target("steipete/weather", "clawhub")+ by_slug = toolkit._find_installed_by_target("weather", "clawhub")+ assert by_owner is not None and by_owner["name"] == "weather"+ assert by_slug is not None and by_slug["name"] == "weather"++ # 旧版 origin 也应被 owner/slug 与纯 slug 命中+ manager._add_local_skill(+ {+ "name": "legacy-skill",+ "origin": "clawhub:legacy-skill",+ "source": "clawhub",+ }+ )+ assert toolkit._find_installed_by_target("alice/legacy-skill", "clawhub") is not None+ assert toolkit._find_installed_by_target("legacy-skill", "clawhub") is not None+++def test_install_skill_clawhub_already_installed_when_origin_has_owner(tmp_path, monkeypatch):+ """Agent 用纯 slug 再装时,应对已有 clawhub:owner/slug 返回 already_installed。"""+ manager = SkillManager(workspace_dir=str(tmp_path / "workspace"))+ toolkit = SkillToolkit(manager)+ manager._add_local_skill(+ {+ "name": "weather",+ "display_name": "Weather",+ "origin": "clawhub:steipete/weather",+ "source": "clawhub",+ }+ )+ (tmp_path / "workspace" / "skills" / "weather").mkdir(parents=True)++ async def _should_not_download(_params):+ raise AssertionError("should skip download when already installed")++ monkeypatch.setattr(manager, "handle_skills_clawhub_download", _should_not_download)++ result = asyncio.run(toolkit.install_skill("weather", source="clawhub"))+ assert result["success"] is True+ assert result["already_installed"] is True+ assert result["name"] == "weather"++def test_search_builtin_skills_matches_name_and_description(tmp_path):builtin_dir = tmp_path / "builtin_skills"builtin_dir.mkdir()