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 (symphony): 修复技能索引页面展示的技能名与SKILL.md中不一致的问题
xutuo442f47464539
diff --git a/docs/README.md b/docs/README.mdindex b8001d3e1f..1f4a8ed0a3 100644--- a/docs/README.md+++ b/docs/README.md@@ -92,7 +92,7 @@</tr><tr><td width="22%"><strong>技能交响乐</strong></td>- <td width="28%"><a href="zh/symphony-技能编排与分发.md">技能交响乐</a></td>+ <td width="28%"><a href="zh/Symphony-技能编排与分发.md">技能交响乐</a></td><td width="50%">技能编排与分发系统。</td></tr><tr>diff --git a/docs/README_EN.md b/docs/README_EN.mdindex 9dbe822bfb..e0f465c617 100644--- a/docs/README_EN.md+++ b/docs/README_EN.md@@ -92,7 +92,7 @@ This page collects common JiuwenSwarm usage instructions, feature documentation,</tr><tr><td width="22%"><strong>Skill Symphony</strong></td>- <td width="28%"><a href="en/symphony.md">Skill Symphony</a></td>+ <td width="28%"><a href="en/Symphony.md">Skill Symphony</a></td><td width="50%">Introduces skill orchestration and dispatch system.</td></tr><tr>diff --git a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsxindex 9f1b17e9fb..4c1d456550 100644--- a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx@@ -132,6 +132,7 @@ type SkillIndexNode = {dont_select_when?: string;source_description?: string;worker_id?: string;+ skill_name?: string;category?: string;keywords?: string[];examples?: string[];@@ -216,6 +217,32 @@ function getSkillIndexNodeLabel(node: SkillIndexNode): string {return String(node.label || node.worker_id || node.cid || "").trim() || "node";}+function getSkillIndexSkillName(node: SkillIndexNode): string {+ return String(node.skill_name || node.worker_id || node.label || "").trim();+}++function getSkillIndexNodeClassName(disabledLeaf: boolean, selected: boolean): string {+ if (disabledLeaf) {+ return selected+ ? "border-zinc-400/40 bg-zinc-500/10 text-text-muted"+ : "border-transparent text-text-muted opacity-75 hover:bg-secondary/50";+ }+ if (selected) {+ return "border-accent/40 bg-accent/10 text-accent";+ }+ return "border-transparent text-text hover:bg-secondary/60";+}++function getSkillIndexNodeBadgeClassName(disabledLeaf: boolean, isLeaf: boolean): string {+ if (disabledLeaf) {+ return "border-zinc-400/25 bg-zinc-500/10 text-text-muted";+ }+ if (isLeaf) {+ return "border-emerald-500/25 bg-emerald-500/10 text-emerald-600";+ }+ return "border-sky-500/25 bg-sky-500/10 text-sky-600";+}+function findSkillIndexNode(nodes: SkillIndexNode[], cid: string | null): SkillIndexNode | null {if (!cid) return null;return nodes.find((node) => node.cid === cid) || null;@@ -448,6 +475,8 @@ function SkillIndexTreeView({emptyText,branchLabel,skillLabel,+ disabledSkillNames,+ disabledSkillLabel,}: {roots: SkillIndexTreeNode[];selectedCid: string | null;@@ -455,6 +484,8 @@ function SkillIndexTreeView({emptyText: string;branchLabel: string;skillLabel: string;+ disabledSkillNames: Set<string>;+ disabledSkillLabel: string;}) {const [expanded, setExpanded] = useState<Record<string, boolean>>({});@@ -477,6 +508,7 @@ function SkillIndexTreeView({const isExpanded = expanded[node.cid] ?? false;const selected = selectedCid === node.cid;const isLeaf = node.type === "leaf";+ const disabledLeaf = isLeaf && disabledSkillNames.has(getSkillIndexSkillName(node));return (<div key={node.cid}><div@@ -484,9 +516,7 @@ function SkillIndexTreeView({aria-selected={selected}aria-expanded={hasChildren ? isExpanded : undefined}className={`flex items-center gap-1 rounded-md border text-xs transition-colors ${- selected- ? "border-accent/40 bg-accent/10 text-accent"- : "border-transparent text-text hover:bg-secondary/60"+ getSkillIndexNodeClassName(disabledLeaf, selected)}`}style={{ paddingLeft: `${8 + depth * 14}px` }}>@@ -514,19 +544,24 @@ function SkillIndexTreeView({<buttontype="button"onClick={() => onSelect(node.cid)}- className="min-w-0 flex-1 h-7 flex items-center gap-2 text-left"+ className="min-w-0 flex-1 min-h-7 py-1 flex items-center gap-2 text-left"title={getSkillIndexNodeLabel(node)}><spanclassName={`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none ${- isLeaf- ? "border-emerald-500/25 bg-emerald-500/10 text-emerald-600"- : "border-sky-500/25 bg-sky-500/10 text-sky-600"+ getSkillIndexNodeBadgeClassName(disabledLeaf, isLeaf)}`}>{isLeaf ? skillLabel : branchLabel}</span>- <span className="truncate">{getSkillIndexNodeLabel(node)}</span>+ <span className="min-w-0 flex-1">+ <span className="block truncate">{getSkillIndexNodeLabel(node)}</span>+ {disabledLeaf ? (+ <span className="block truncate text-[10px] leading-4 text-text-muted">+ {disabledSkillLabel}+ </span>+ ) : null}+ </span></button></div>{hasChildren && isExpanded ? (@@ -1422,6 +1457,10 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:() => buildSkillIndexTree(retrievalTreeNodes),[retrievalTreeNodes]);+ const disabledSkillNames = useMemo(+ () => new Set(skills.filter((skill) => skill.enabled === false).map((skill) => skill.name)),+ [skills]+ );const selectedTreeNode = useMemo(() => findSkillIndexNode(retrievalTreeNodes, selectedTreeNodeCid),[retrievalTreeNodes, selectedTreeNodeCid]@@ -1753,6 +1792,8 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:emptyText={t('skills.retrieval.noTree')}branchLabel={t('skills.retrieval.nodeTypes.branch')}skillLabel={t('skills.retrieval.nodeTypes.skill')}+ disabledSkillNames={disabledSkillNames}+ disabledSkillLabel={t('skills.retrieval.disabledSkill')}/>) : (<MarkdownRendererdiff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.jsonindex 07a3b57e01..f7f9d23b1f 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json@@ -1141,6 +1141,7 @@"nodeCategory": "Category","nodeKeywords": "Keywords","nodeExamples": "Examples",+ "disabledSkill": "Disabled","nodeTypes": {"branch": "Branch","skill": "Skill"diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.jsonindex be50cbcd0b..d4777ed99b 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json@@ -1140,6 +1140,7 @@"nodeCategory": "分类","nodeKeywords": "关键词","nodeExamples": "示例",+ "disabledSkill": "已禁用","nodeTypes": {"branch": "分支","skill": "技能"diff --git a/jiuwenswarm/symphony/skill_retrieval/catalog.py b/jiuwenswarm/symphony/skill_retrieval/catalog.pynew file mode 100644index 0000000000..8e60c91927--- /dev/null+++ b/jiuwenswarm/symphony/skill_retrieval/catalog.py@@ -0,0 +1,32 @@+from __future__ import annotations++import json+from pathlib import Path+from typing import Any++CATALOG_FILENAME = "catalog.jsonl"+++def load_catalog_by_worker(index_dir: Path) -> dict[str, dict[str, Any]]:+ out: dict[str, dict[str, Any]] = {}+ path = index_dir / CATALOG_FILENAME+ if not path.is_file():+ return out+ for line in path.read_text(encoding="utf-8").splitlines():+ if not line.strip():+ continue+ item = _load_catalog_line(line)+ if item is None:+ continue+ worker_id = str(item.get("worker_id") or "").strip()+ if worker_id:+ out[worker_id] = item+ return out+++def _load_catalog_line(line: str) -> dict[str, Any] | None:+ try:+ item = json.loads(line)+ except json.JSONDecodeError:+ return None+ return item if isinstance(item, dict) else Nonediff --git a/jiuwenswarm/symphony/skill_retrieval/index_service.py b/jiuwenswarm/symphony/skill_retrieval/index_service.pyindex 5c495cbd49..023fc400f6 100644--- a/jiuwenswarm/symphony/skill_retrieval/index_service.py+++ b/jiuwenswarm/symphony/skill_retrieval/index_service.py@@ -13,13 +13,13 @@ from typing import Anyimport yaml+from .catalog import CATALOG_FILENAME, load_catalog_by_workerfrom .config import SkillRetrievalSettings, load_settingsfrom .dispatch_imports import dispatch_import_pathfrom .inventory import SkillInventory, scan_skill_inventoryfrom .markdown import render_build_failure, render_build_success, render_disabledTREE_INDEX_FILENAME = "tree_index.yaml"-CATALOG_FILENAME = "catalog.jsonl"MANIFEST_FILENAME = "manifest.json"STATE_FILENAME = "state.json"LOGGER = logging.getLogger(__name__)@@ -449,7 +449,8 @@ class SkillIndexService:branch_count = sum(1 for node in nodes if isinstance(node, dict) and node.get("type") == "branch")leaf_count = sum(1 for node in nodes if isinstance(node, dict) and node.get("type") == "leaf")- tree_nodes = _tree_node_payload(nodes)+ catalog_by_worker = load_catalog_by_worker(index_dir)+ tree_nodes = _tree_node_payload(nodes, catalog_by_worker=catalog_by_worker)return {"success": True,"result": (@@ -1166,7 +1167,7 @@ def _render_tree_outline(nodes: list[Any], *, max_nodes: int = 400) -> str:return "\n".join(lines) if lines else "(empty tree)"-def _tree_node_payload(nodes: list[Any]) -> list[dict[str, Any]]:+def _tree_node_payload(nodes: list[Any], *, catalog_by_worker: dict[str, dict[str, Any]]) -> list[dict[str, Any]]:out: list[dict[str, Any]] = []known_cids: set[str] = set()for raw in nodes:@@ -1187,6 +1188,8 @@ def _tree_node_payload(nodes: list[Any]) -> list[dict[str, Any]]:parent_cid = ""node_type = str(raw.get("type") or "").strip() or "branch"worker_id = str(raw.get("worker_id") or "").strip()+ catalog = catalog_by_worker.get(worker_id, {})+ skill_name = str(catalog.get("name") or "").strip() if node_type == "leaf" else ""fallback_label = worker_id if node_type == "leaf" and worker_id else cid.rsplit(".", 1)[-1]out.append({@@ -1199,6 +1202,7 @@ def _tree_node_payload(nodes: list[Any]) -> list[dict[str, Any]]:"dont_select_when": str(raw.get("dont_select_when") or "").strip(),"source_description": str(raw.get("source_description") or "").strip(),"worker_id": worker_id,+ "skill_name": skill_name,"category": str(raw.get("category") or "").strip(),"keywords": _string_list(raw.get("keywords")),"examples": _string_list(raw.get("examples")),diff --git a/jiuwenswarm/symphony/skill_retrieval/retrieve_service.py b/jiuwenswarm/symphony/skill_retrieval/retrieve_service.pyindex c130a30e7d..54797d82c6 100644--- a/jiuwenswarm/symphony/skill_retrieval/retrieve_service.py+++ b/jiuwenswarm/symphony/skill_retrieval/retrieve_service.py@@ -1,12 +1,12 @@from __future__ import annotations-import jsonfrom pathlib import Pathfrom typing import Any+from .catalog import CATALOG_FILENAME, load_catalog_by_workerfrom .config import load_settingsfrom .dispatch_imports import dispatch_import_path-from .index_service import CATALOG_FILENAME, _index_dir+from .index_service import _index_dirfrom .markdown import render_disabled, render_retrieve_failure, render_retrieve_successfrom .skill_tree import build_skill_tree_payload@@ -53,7 +53,7 @@ class SkillRetrieveService:}index_dir = _index_dir(settings)- catalog_by_worker = _load_catalog(index_dir)+ catalog_by_worker = load_catalog_by_worker(index_dir)try:result = self._run_dispatch_retrieve(settings=settings, index_dir=index_dir, query=normalized_query)except Exception as exc:@@ -134,31 +134,6 @@ def run_structured_skill_retrieve(*, settings: Any, index_dir: Path, query: str)retriever.close()-def _load_catalog(index_dir: Path) -> dict[str, dict[str, Any]]:- out: dict[str, dict[str, Any]] = {}- path = index_dir / CATALOG_FILENAME- if not path.is_file():- return out- for line in path.read_text(encoding="utf-8").splitlines():- if not line.strip():- continue- item = _load_catalog_line(line)- if item is None:- continue- worker_id = str(item.get("worker_id") or "").strip()- if worker_id:- out[worker_id] = item- return out---def _load_catalog_line(line: str) -> dict[str, Any] | None:- try:- item = json.loads(line)- except json.JSONDecodeError:- return None- return item if isinstance(item, dict) else None--def _settings_summary(settings: Any) -> str:retrieve = settings.retrievereturn (