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
SkillNet: skillnet-ai 0.0.15, error copy, SKILL.md case, GitHubAPIError passthrough
lairuofeibb70c0b372d1
diff --git a/jiuwenclaw/agentserver/skill_manager.py b/jiuwenclaw/agentserver/skill_manager.pyindex b59d14b7d6..5ce59e71a1 100644--- a/jiuwenclaw/agentserver/skill_manager.py+++ b/jiuwenclaw/agentserver/skill_manager.py@@ -282,7 +282,14 @@ class SkillManager:raw_results = await asyncio.to_thread(self._skillnet_search_sync, search_kwargs)except Exception as exc:logger.error("SkillNet 搜索失败: %s", exc)- return {"success": False, "detail": f"SkillNet 搜索失败: {exc}"}+ raw = str(exc).strip()+ if raw:+ return {"success": False, "detail": raw}+ return {+ "success": False,+ "detail": "搜索失败,请稍后重试。",+ "detail_key": "skills.skillNet.errors.searchFailedFallback",+ }normalized: list[dict[str, Any]] = []for item in raw_results:@@ -339,17 +346,26 @@ class SkillManager:return {"success": False, "detail": "缺少参数: install_id"}job = self._skillnet_install_jobs.get(install_id)if job is None:- return {"success": False, "detail": "无效或已过期的 install_id"}+ return {+ "success": False,+ "detail": "安装会话已过期,请重新点击安装。",+ "detail_key": "skills.skillNet.errors.sessionExpired",+ }status = job.get("status", "pending")if status == "pending":return {"success": True, "status": "pending"}if status == "failed":- return {+ out: dict[str, Any] = {"success": False,"status": "failed","detail": job.get("detail", "安装失败"),}+ if "detail_key" in job:+ out["detail_key"] = job["detail_key"]+ if "detail_params" in job:+ out["detail_params"] = job["detail_params"]+ return out# donereturn {"success": True,@@ -376,25 +392,39 @@ class SkillManager:self._skillnet_install_jobs[install_id] = {"status": "failed","detail": (- f"下载超时 (>{_SKILLNET_DOWNLOAD_TIMEOUT}s),可能因网络延迟较高。"- "可设置环境变量 SKILLNET_DOWNLOAD_TIMEOUT 调整超时时间,"- "或使用 VPN 改善网络连接。"+ f"下载超时(超过 {_SKILLNET_DOWNLOAD_TIMEOUT} 秒),请稍后重试。"+ "若网络较慢,可稍后在技能列表中查看是否已安装成功。"),+ "detail_key": "skills.skillNet.errors.downloadTimeout",+ "detail_params": {"seconds": _SKILLNET_DOWNLOAD_TIMEOUT},}returnexcept Exception as exc:logger.error("SkillNet 后台安装异常: %s", exc)+ raw = str(exc).strip()self._skillnet_install_jobs[install_id] = {"status": "failed",- "detail": str(exc),+ "detail": raw or "安装失败,请重试。",+ **(+ {}+ if raw+ else {+ "detail_key": "skills.skillNet.errors.installFailedFallback",+ }+ ),}returnif not result.get("ok"):- self._skillnet_install_jobs[install_id] = {+ job_entry: dict[str, Any] = {"status": "failed",- "detail": result.get("detail", "安装失败"),+ "detail": result.get("detail", "安装失败,请重试。"),}+ if result.get("detail_key"):+ job_entry["detail_key"] = result["detail_key"]+ if result.get("detail_params") is not None:+ job_entry["detail_params"] = result["detail_params"]+ self._skillnet_install_jobs[install_id] = job_entryreturnskill_name = result["skill_name"]@@ -420,7 +450,8 @@ class SkillManager:logger.error("SkillNet 写入状态失败: %s", exc)self._skillnet_install_jobs[install_id] = {"status": "failed",- "detail": str(exc),+ "detail": "安装完成但保存配置失败,请刷新页面重试。",+ "detail_key": "skills.skillNet.errors.saveConfigFailed",}return@@ -432,7 +463,8 @@ class SkillManager:logger.error("SkillNet 安装完成后 hook 失败: %s", exc)self._skillnet_install_jobs[install_id] = {"status": "failed",- "detail": f"重载 Agent 失败: {exc}",+ "detail": "技能已安装,请手动刷新页面生效。",+ "detail_key": "skills.skillNet.errors.reloadRequired",}return@@ -451,17 +483,27 @@ class SkillManager:if not download_path.exists():return {"ok": False,- "detail": f"下载结果不存在: {download_path}",+ "detail": "下载失败,请重试。",+ "detail_key": "skills.skillNet.errors.downloadFailed",}+ # 库在部分文件下载失败时仍会返回路径,只有找到 SKILL.md 才视为下载完整,才继续后续逻辑skill_dir = self._locate_skill_dir(download_path)if skill_dir is None:- return {"ok": False, "detail": "下载内容中未找到 SKILL.md"}+ return {+ "ok": False,+ "detail": "下载未完成或内容不完整,未找到 SKILL.md,请重试。",+ "detail_key": "skills.skillNet.errors.skillMdNotFound",+ }md = self._try_find_skill_file(skill_dir)meta = self._parse_skill_md(md) if md else Noneif meta is None:- return {"ok": False, "detail": "无法解析下载的技能文件"}+ return {+ "ok": False,+ "detail": "无法解析下载的技能文件",+ "detail_key": "skills.skillNet.errors.parseSkillFailed",+ }skill_name = str(meta.get("name", skill_dir.name)).strip() or skill_dir.namedest = _SKILLS_DIR / skill_name@@ -469,7 +511,8 @@ class SkillManager:if not force:return {"ok": False,- "detail": f"skill {skill_name} 已存在",+ "detail": "该技能已安装。",+ "detail_key": "skills.skillNet.errors.skillAlreadyInstalled",}shutil.rmtree(dest)@@ -491,7 +534,12 @@ class SkillManager:}except Exception as exc:logger.error("SkillNet 下载失败: %s", exc)- return {"ok": False, "detail": f"SkillNet 下载失败: {exc}"}+ raw = str(exc).strip()+ detail = raw or "安装失败,请重试。"+ extra: dict[str, Any] = {}+ if not raw:+ extra["detail_key"] = "skills.skillNet.errors.installFailedFallback"+ return {"ok": False, "detail": detail, **extra}async def handle_skills_uninstall(self, params: dict) -> dict:"""卸载已安装的 skill.@@ -942,7 +990,7 @@ class SkillManager:@staticmethoddef _locate_skill_dir(path: Path) -> Path | None:- """定位包含 SKILL.md 的目录(优先当前目录,再向下递归)."""+ """定位包含 SKILL.md 的目录(优先当前目录,再向下递归);文件名大小写不敏感."""if path.is_file() and path.name.lower() == "skill.md":return path.parentif path.is_dir():@@ -952,6 +1000,10 @@ class SkillManager:for md in path.rglob("SKILL.md"):if md.is_file():return md.parent+ # 兼容小写 skill.md(如 Linux 下仓库命名)+ for md in path.rglob("*.md"):+ if md.is_file() and md.name.lower() == "skill.md":+ return md.parentreturn None@staticmethod@@ -1073,7 +1125,7 @@ class SkillManager:def _skillnet_download_sync(skill_url: str, target_dir: str) -> str:"""同步调用 skillnet-ai download;失败时附带 GitHub API 返回说明(如前端的限流文案)。"""try:- from skillnet_ai.downloader import SkillDownloader+ from skillnet_ai.downloader import SkillDownloader, GitHubAPIErrorexcept Exception as exc:raise RuntimeError("未安装 skillnet-ai,请先安装依赖: pip install skillnet-ai"@@ -1092,6 +1144,8 @@ class SkillManager:try:local_path = downloader.download(folder_url=skill_url, target_dir=target_dir)+ except GitHubAPIError:+ raiseexcept Exception as exc:ctx = SkillManager._github_skillnet_install_error_context(skill_url)if ctx:@@ -1104,10 +1158,6 @@ class SkillManager:raise RuntimeError("SkillNet 返回空下载路径")return str(local_path)- # ------------------------------------------------------------------------ # Git 操作- # ------------------------------------------------------------------------async def _git_clone(self, url: str, dest: Path) -> str | None:"""浅克隆 git 仓库,返回 commit hash 或 None."""dest.parent.mkdir(parents=True, exist_ok=True)diff --git a/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsx b/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsxindex 58c75d72e1..b5972efb03 100644--- a/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsx+++ b/jiuwenclaw/web/src/features/SkillNetSearchModal/index.tsx@@ -83,10 +83,15 @@ export function SkillNetSearchModal({const data = await webRequest<{success: boolean;detail?: string;+ detail_key?: string;+ detail_params?: Record<string, unknown>;skills?: SkillNetItem[];}>("skills.skillnet.search", withSession({ q, limit: 50 }));if (!data.success) {- throw new Error(data.detail || t("skills.errors.skillNetSearchFailed"));+ const message = data.detail_key+ ? t(data.detail_key, data.detail_params as Record<string, string> | undefined)+ : (data.detail || t("skills.errors.skillNetSearchFailed"));+ throw new Error(message);}setResults(data.skills || []);setLoadState("success");@@ -135,6 +140,8 @@ export function SkillNetSearchModal({success: boolean;status?: string;detail?: string;+ detail_key?: string;+ detail_params?: Record<string, unknown>;skill?: { name?: string };}>("skills.skillnet.install_status",@@ -146,9 +153,10 @@ export function SkillNetSearchModal({break;}if (st.status === "failed" || (!st.success && st.status !== "pending")) {- throw new Error(- st.detail || t("skills.errors.skillNetInstallFailed")- );+ const message = st.detail_key+ ? t(st.detail_key, st.detail_params as Record<string, string> | undefined)+ : (st.detail || t("skills.errors.skillNetInstallFailed"));+ throw new Error(message);}await new Promise((r) => window.setTimeout(r, pollMs));}@@ -204,7 +212,7 @@ export function SkillNetSearchModal({<div className="p-5 overflow-auto flex-1 min-h-0">{installedSuccess && (- <div className="mb-3 px-3 py-2 rounded-md bg-green-500/15 text-green-700 dark:text-green-400 text-sm">+ <div className="mb-3 px-3 py-2.5 rounded-lg text-sm leading-snug border border-[color:var(--border-ok)] bg-ok-subtle text-ok">{t("skills.messages.skillNetInstalled", { name: installedSuccess })}</div>)}@@ -241,7 +249,7 @@ export function SkillNetSearchModal({</div>{errorMessage && (- <div className="mt-3 px-3 py-2 rounded-md bg-secondary text-sm text-danger break-words whitespace-pre-wrap max-h-32 overflow-y-auto">+ <div className="mt-3 px-3 py-2 rounded-md bg-secondary text-sm text-danger break-words whitespace-pre-wrap max-h-48 overflow-y-auto">{errorMessage}</div>)}diff --git a/jiuwenclaw/web/src/i18n/locales/en.json b/jiuwenclaw/web/src/i18n/locales/en.jsonindex 862bfbabe5..10b438a272 100644--- a/jiuwenclaw/web/src/i18n/locales/en.json+++ b/jiuwenclaw/web/src/i18n/locales/en.json@@ -495,7 +495,19 @@"usageNoticeTitle": "Notes","usageNotice1": "Installing a skill downloads files from GitHub. Ensure the machine running JiuwenClaw can reach GitHub (network / proxy).","usageNotice2": "GitHub’s API limits anonymous (unauthenticated) use to about 60 requests per hour per IP. If install fails with rate limiting, wait and retry later. For increased rate limits, configure github_token in the configuration page.",- "usageNotice3": "SkillNet search uses a public service; timeouts or errors may be due to network congestion or server load—try again later."+ "usageNotice3": "SkillNet search uses a public service; timeouts or errors may be due to network congestion or server load—try again later.",+ "errors": {+ "searchFailedFallback": "Search failed. Please try again later.",+ "sessionExpired": "Install session expired. Please click Install again.",+ "downloadTimeout": "Download timed out (over {{seconds}}s). Please try again later. If the network is slow, check the skill list later to see if it was installed.",+ "installFailedFallback": "Install failed. Please try again.",+ "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.",+ "skillMdNotFound": "Download incomplete or missing SKILL.md. Please retry.",+ "parseSkillFailed": "Could not parse the downloaded skill file.",+ "skillAlreadyInstalled": "This skill is already installed."+ }},"marketplacesAvailable": "Available marketplaces: {{names}}","marketplacesDefault": "Default marketplace: anthropics",diff --git a/jiuwenclaw/web/src/i18n/locales/zh.json b/jiuwenclaw/web/src/i18n/locales/zh.jsonindex f3e8b613df..9571d7d6a9 100644--- a/jiuwenclaw/web/src/i18n/locales/zh.json+++ b/jiuwenclaw/web/src/i18n/locales/zh.json@@ -495,7 +495,19 @@"usageNoticeTitle": "提示","usageNotice1": "从 SkillNet 安装技能时,文件实际从 GitHub 下载,请保证运行 JiuwenClaw 的环境能访问 GitHub(网络、代理等)。","usageNotice2": "从 GitHub 拉取依赖其 API:未认证(匿名)约 60 次/小时/本机 IP;若安装失败并提示限流,请隔一段时间再试。如需提高速率限制,请在配置页面中配置 github_token。",- "usageNotice3": "SkillNet 在线搜索走公网服务,若出现超时或失败,可能是网络拥堵或服务繁忙,请稍后再试。"+ "usageNotice3": "SkillNet 在线搜索走公网服务,若出现超时或失败,可能是网络拥堵或服务繁忙,请稍后再试。",+ "errors": {+ "searchFailedFallback": "搜索失败,请稍后重试。",+ "sessionExpired": "安装会话已过期,请重新点击安装。",+ "downloadTimeout": "下载超时(超过 {{seconds}} 秒),请稍后重试。若网络较慢,可稍后在技能列表中查看是否已安装成功。",+ "installFailedFallback": "安装失败,请重试。",+ "saveConfigFailed": "安装完成但保存配置失败,请刷新页面重试。",+ "reloadRequired": "技能已安装,请手动刷新页面生效。",+ "downloadFailed": "下载失败,请重试。",+ "skillMdNotFound": "下载未完成或内容不完整,未找到 SKILL.md,请重试。",+ "parseSkillFailed": "无法解析下载的技能文件",+ "skillAlreadyInstalled": "该技能已安装。"+ }},"marketplacesAvailable": "可用 marketplace: {{names}}","marketplacesDefault": "默认 marketplace: anthropics",diff --git a/pyproject.toml b/pyproject.tomlindex b24c7423a7..961b08d8c0 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -30,7 +30,7 @@ dependencies = ["wecom-aibot-sdk>=1.0.0","python-socks>=2.8.1","greenlet>=3.3.2",- "skillnet-ai>=0.0.14",+ "skillnet-ai==0.0.15",][project.scripts]diff --git a/uv.lock b/uv.lockindex b22223d236..9dd34679ee 100644--- a/uv.lock+++ b/uv.lock@@ -1391,7 +1391,7 @@ requires-dist = [{ name = "python-socks", specifier = ">=2.8.1" },{ name = "python-telegram-bot", specifier = ">=20.0" },{ name = "ruamel-yaml", specifier = ">=0.18.0" },- { name = "skillnet-ai", specifier = ">=0.0.14" },+ { name = "skillnet-ai", specifier = "==0.0.15" },{ name = "websockets", specifier = ">=12.0" },{ name = "wecom-aibot-sdk", specifier = ">=1.0.0" },]@@ -3560,7 +3560,7 @@ wheels = [[[package]]name = "skillnet-ai"-version = "0.0.14"+version = "0.0.15"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "openai" },@@ -3574,9 +3574,9 @@ dependencies = [{ name = "tqdm" },{ name = "typer" },]-sdist = { url = "https://files.pythonhosted.org/packages/38/2e/95df280e3db9d96646bea71198a71f828beefc430de83912e51cc5cbabac/skillnet_ai-0.0.14.tar.gz", hash = "sha256:d458b07745d9f885e6e461637e6a6eea070786163eae1e2b44389d3b887b1635", size = 54939, upload-time = "2026-03-17T13:37:18.74Z" }+sdist = { url = "https://files.pythonhosted.org/packages/22/d7/c07dcecbb694b07656d3be6b8017132cb65a0394bb7ec9bf06c88a0a8d18/skillnet_ai-0.0.15.tar.gz", hash = "sha256:997a240196cbc19e1b7108ac5a917a8ad33c078867cde7658b608cd97f839740", size = 55477, upload-time = "2026-03-18T13:06:48.485Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/ce/d4/898ec5c3bfdc7c72f3d948242c45f7a4c631e8474d526e8cb351def9285f/skillnet_ai-0.0.14-py3-none-any.whl", hash = "sha256:fb9fd7c16cb8628a96dd0591a48776e17604f253825333492cfcd96277bb4bec", size = 56624, upload-time = "2026-03-17T13:37:16.944Z" },+ { url = "https://files.pythonhosted.org/packages/e0/b6/4e31699ace2b722ed56d613930b6464859f1403d56e2990eace121fb6e26/skillnet_ai-0.0.15-py3-none-any.whl", hash = "sha256:0259d04b992f1b4d1887b4266e597813af195e693933713fdb63450e17b485c0", size = 57332, upload-time = "2026-03-18T13:06:47.037Z" },][[package]]