Skip to content

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

feat(skillnet): i18n empty download + upstream repo link in modal

lairuofeiebb7ff9c2e66
diff --git a/jiuwenclaw/agentserver/skill_manager.py b/jiuwenclaw/agentserver/skill_manager.py
index 8ed0adc732..7bce1da2b2 100644
--- a/jiuwenclaw/agentserver/skill_manager.py
+++ b/jiuwenclaw/agentserver/skill_manager.py
@@ -30,6 +30,17 @@ _MARKETPLACE_DIR = _SKILLS_DIR / "_marketplace"
_STATE_FILE = _SKILLS_DIR / "skills_state.json"
+class SkillNetEmptyDownloadError(Exception):
+ """skillnet-ai ``download()`` returned None; 前端用 detail_key 做多语言。"""
+
+ def __init__(self, *, github_context: str = "") -> None:
+ self.github_context = (github_context or "").strip()
+ self.detail_key = "skills.skillNet.errors.emptyDownloadResult"
+ hint = f"\n{self.github_context[:800]}" if self.github_context else ""
+ self.detail_params = {"hint": hint}
+ super().__init__(self.github_context or "empty download path")
+
+
def _is_valid_http_mirror_url(url: str) -> bool:
"""Return True if url is a plausible http(s) mirror base (for SkillDownloader)."""
s = url.strip()
@@ -541,6 +552,15 @@ class SkillManager:
"meta": meta,
"skill_url": skill_url,
}
+ except SkillNetEmptyDownloadError as exc:
+ logger.error("SkillNet 下载失败: %s", exc)
+ out: dict[str, Any] = {
+ "ok": False,
+ "detail_key": exc.detail_key,
+ "detail": "",
+ }
+ out["detail_params"] = exc.detail_params
+ return out
except Exception as exc:
logger.error("SkillNet 下载失败: %s", exc)
raw = str(exc).strip()
@@ -1135,10 +1155,10 @@ class SkillManager:
raise RuntimeError(f"{exc} | {ctx}") from exc
raise
if not local_path:
+ # skillnet-ai 在多种情况下会无异常地返回 None:URL 无效、目录下列表为空、
+ # 或 Contents API 成功但拉 raw 文件全部失败(超时/网络)等,库未区分原因。
ctx = SkillManager._github_skillnet_install_error_context(skill_url)
- if ctx:
- raise RuntimeError(f"SkillNet 返回空下载路径 | {ctx}")
- raise RuntimeError("SkillNet 返回空下载路径")
+ raise SkillNetEmptyDownloadError(github_context=ctx)
return str(local_path)
async def _git_clone(self, url: str, dest: Path) -> str | None:
diff --git a/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsx b/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsx
index 9bec7faa65..9abc92b1a5 100644
--- a/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsx
+++ b/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsx
@@ -2,24 +2,11 @@
* SkillNet 在线搜索弹窗
* 从 SkillNet 检索并安装技能
*/
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import { useTranslation } from "react-i18next";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { Trans, useTranslation } from "react-i18next";
import { webRequest } from "../../services/webClient";
-/** Empty input → no mirror; non-empty must be http(s) URL or treated as invalid (do not send to backend). */
-function parseOptionalHttpMirrorUrl(input: string): { valid: boolean; value: string | null } {
- const t = input.trim();
- if (!t) return { valid: true, value: null };
- try {
- const u = new URL(t);
- if (u.protocol !== "http:" && u.protocol !== "https:") {
- return { valid: false, value: null };
- }
- return { valid: true, value: t };
- } catch {
- return { valid: false, value: null };
- }
-}
+const SKILLNET_UPSTREAM_REPO_URL = "https://github.com/zjunlp/SkillNet";
type SkillNetItem = {
skill_name: string;
@@ -47,7 +34,6 @@ export function SkillNetSearchModal({
}: SkillNetSearchModalProps) {
const { t } = useTranslation();
const [query, setQuery] = useState("");
- const [mirrorUrlInput, setMirrorUrlInput] = useState("");
const [results, setResults] = useState<SkillNetItem[]>([]);
const [loadState, setLoadState] = useState<LoadState>("idle");
const [expandedUrl, setExpandedUrl] = useState<string | null>(null);
@@ -64,13 +50,6 @@ export function SkillNetSearchModal({
[sessionId]
);
- const parsedMirror = useMemo(
- () => parseOptionalHttpMirrorUrl(mirrorUrlInput),
- [mirrorUrlInput]
- );
- const mirrorFieldInvalid =
- mirrorUrlInput.trim().length > 0 && !parsedMirror.valid;
-
useEffect(() => {
if (!open) return;
const onKeyDown = (e: KeyboardEvent) => {
@@ -138,13 +117,6 @@ export function SkillNetSearchModal({
setActionTarget(item.skill_url);
setErrorMessage(null);
try {
- const installParams: Record<string, unknown> = {
- url: item.skill_url,
- force: true,
- };
- if (parsedMirror.value) {
- installParams.mirror_url = parsedMirror.value;
- }
const data = await webRequest<{
success: boolean;
pending?: boolean;
@@ -153,7 +125,10 @@ export function SkillNetSearchModal({
detail_key?: string;
detail_params?: Record<string, unknown>;
skill?: { name?: string };
- }>("skills.skillnet.install", withSession(installParams));
+ }>(
+ "skills.skillnet.install",
+ withSession({ url: item.skill_url, force: true })
+ );
if (!data.success) {
const message = data.detail_key
? t(data.detail_key, data.detail_params as Record<string, string> | undefined)
@@ -215,7 +190,7 @@ export function SkillNetSearchModal({
setActionTarget(null);
}
},
- [clearInstalledSuccess, onInstalled, parsedMirror.value, t, withSession]
+ [clearInstalledSuccess, onInstalled, t, withSession]
);
if (!open) return null;
@@ -229,10 +204,23 @@ export function SkillNetSearchModal({
aria-label={t("common.close")}
/>
<div className="relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border border-border bg-card shadow-2xl animate-rise flex flex-col">
- <div className="flex items-center justify-between gap-3 px-5 py-3 border-b border-border bg-panel flex-shrink-0">
- <h3 className="text-base font-semibold text-text">
- {t("skills.skillNet.title")}
- </h3>
+ <div className="flex items-start justify-between gap-3 px-5 py-3 border-b border-border bg-panel flex-shrink-0">
+ <div className="min-w-0 flex-1 space-y-1">
+ <h3 className="text-base font-semibold text-text">
+ {t("skills.skillNet.title")}
+ </h3>
+ <p className="text-[11px] leading-snug text-text-muted">
+ <a
+ href={SKILLNET_UPSTREAM_REPO_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="font-medium text-accent underline decoration-accent/35 underline-offset-2 hover:text-accent-hover hover:decoration-accent/60"
+ aria-label={t("skills.skillNet.titleRepoAria")}
+ >
+ {t("skills.skillNet.titleRepoLinkText")}
+ </a>
+ </p>
+ </div>
<button
type="button"
onClick={onClose}
@@ -254,41 +242,19 @@ export function SkillNetSearchModal({
</div>
<ul className="list-disc pl-4 space-y-1">
<li>{t("skills.skillNet.usageNotice3")}</li>
- <li>{t("skills.skillNet.usageNotice1")}</li>
+ <li>
+ <Trans
+ i18nKey="skills.skillNet.usageNotice1"
+ components={{
+ strong: (
+ <strong className="font-semibold text-text" />
+ ),
+ }}
+ />
+ </li>
<li>{t("skills.skillNet.usageNotice2")}</li>
- <li>{t("skills.skillNet.usageNotice4")}</li>
</ul>
</div>
- <div className="mb-4 space-y-1.5">
- <label
- htmlFor="skillnet-mirror-url"
- className="block text-xs font-medium text-text"
- >
- {t("skills.skillNet.mirrorLabel")}
- </label>
- <input
- id="skillnet-mirror-url"
- type="text"
- inputMode="url"
- autoComplete="off"
- spellCheck={false}
- value={mirrorUrlInput}
- onChange={(e) => setMirrorUrlInput(e.target.value)}
- placeholder={t("skills.skillNet.mirrorPlaceholder")}
- aria-invalid={mirrorFieldInvalid}
- className={`w-full px-3 py-2 rounded-md bg-secondary border text-sm text-text placeholder:text-text-muted ${
- mirrorFieldInvalid ? "border-danger" : "border-border"
- }`}
- />
- <p className="text-xs text-text-muted whitespace-pre-wrap font-mono leading-relaxed">
- {t("skills.skillNet.mirrorExamples")}
- </p>
- {mirrorFieldInvalid && (
- <p className="text-xs text-danger" role="alert">
- {t("skills.skillNet.mirrorInvalid")}
- </p>
- )}
- </div>
<div className="flex items-center gap-2">
<input
value={query}
@@ -380,7 +346,7 @@ export function SkillNetSearchModal({
e.stopPropagation();
handleInstall(item);
}}
- disabled={anyInstalling || mirrorFieldInvalid}
+ disabled={anyInstalling}
className={`px-3 py-1.5 rounded-md text-xs whitespace-nowrap transition-colors flex-shrink-0 ${
anyInstalling
? "bg-secondary text-text-muted cursor-not-allowed"
diff --git a/jiuwenclaw/web/src/i18n/locales/en.json b/jiuwenclaw/web/src/i18n/locales/en.json
index 266daddde3..ab3d0f5e8e 100644
--- a/jiuwenclaw/web/src/i18n/locales/en.json
+++ b/jiuwenclaw/web/src/i18n/locales/en.json
@@ -486,6 +486,8 @@
"detailError": "Failed to load details",
"skillNet": {
"title": "SkillNet Online Search",
+ "titleRepoLinkText": "SkillNet on GitHub",
+ "titleRepoAria": "SkillNet repository on GitHub",
"search": "Search",
"collapse": "Collapse",
"expand": "Expand",
@@ -515,6 +517,7 @@
"saveConfigFailed": "Install completed but saving config failed. Please refresh the page and retry.",
"reloadRequired": "Skill installed. Please refresh the page to take effect.",
"downloadFailed": "Download failed. Please try again.",
+ "emptyDownloadResult": "SkillNet downloaded nothing (empty path). Common causes: invalid URL or no files under that path; or GitHub listed files but every raw.githubusercontent.com fetch failed (timeouts, firewall, API reachable but raw blocked, etc.).{{hint}}",
"skillMdNotFound": "Download incomplete or missing SKILL.md. Please retry.",
"parseSkillFailed": "Could not parse the downloaded skill file.",
"skillAlreadyInstalled": "This skill is already installed.",
diff --git a/jiuwenclaw/web/src/i18n/locales/zh.json b/jiuwenclaw/web/src/i18n/locales/zh.json
index 9e835f78a2..59acb33523 100644
--- a/jiuwenclaw/web/src/i18n/locales/zh.json
+++ b/jiuwenclaw/web/src/i18n/locales/zh.json
@@ -486,6 +486,8 @@
"detailError": "加载详情失败",
"skillNet": {
"title": "SkillNet 在线搜索",
+ "titleRepoLinkText": "SkillNet 开源仓库",
+ "titleRepoAria": "SkillNet 官方 GitHub 仓库",
"search": "搜索",
"collapse": "收起",
"expand": "展开",
@@ -515,6 +517,7 @@
"saveConfigFailed": "安装完成但保存配置失败,请刷新页面重试。",
"reloadRequired": "技能已安装,请手动刷新页面生效。",
"downloadFailed": "下载失败,请重试。",
+ "emptyDownloadResult": "SkillNet 未下载到任何内容。可能原因:链接无效或路径下无文件;或已从 GitHub 列出文件但从 raw.githubusercontent.com 拉取全部失败(网络超时、防火墙、仅 API 可达而 raw 不可达等)。{{hint}}",
"skillMdNotFound": "下载未完成或内容不完整,未找到 SKILL.md,请重试。",
"parseSkillFailed": "无法解析下载的技能文件",
"skillAlreadyInstalled": "该技能已安装。",