diff --git a/astrbot/core/skills/skill_manager.py b/astrbot/core/skills/skill_manager.py index 03ba1e153e..0b51529d2e 100644 --- a/astrbot/core/skills/skill_manager.py +++ b/astrbot/core/skills/skill_manager.py @@ -681,6 +681,8 @@ def list_skills( return [skills_by_name[name] for name in sorted(skills_by_name)] def is_sandbox_only_skill(self, name: str) -> bool: + if self._get_plugin_skill_dir(name) is not None: + return False skill_dir = Path(self.skills_root) / name skill_md_exists = _normalize_skill_markdown_path(skill_dir) is not None if skill_md_exists: diff --git a/tests/test_skill_manager_sandbox_cache.py b/tests/test_skill_manager_sandbox_cache.py index 1af5d2f213..3ad1372432 100644 --- a/tests/test_skill_manager_sandbox_cache.py +++ b/tests/test_skill_manager_sandbox_cache.py @@ -170,3 +170,42 @@ def test_sandbox_and_local_path_resolution_with_show_sandbox_path_false( assert local_skill_path.is_relative_to(skills_root) assert local_skill_path == skills_root / "custom-local" / "SKILL.md" assert by_name["python-sandbox"].path == "/app/skills/python-sandbox/SKILL.md" + + +def test_plugin_skill_with_stale_sandbox_cache_is_not_sandbox_only( + monkeypatch, + tmp_path: Path, +): + data_dir = tmp_path / "data" + temp_dir = tmp_path / "temp" + skills_root = tmp_path / "skills" + data_dir.mkdir(parents=True, exist_ok=True) + temp_dir.mkdir(parents=True, exist_ok=True) + skills_root.mkdir(parents=True, exist_ok=True) + + monkeypatch.setattr( + "astrbot.core.skills.skill_manager.get_astrbot_data_path", + lambda: str(data_dir), + ) + monkeypatch.setattr( + "astrbot.core.skills.skill_manager.get_astrbot_temp_path", + lambda: str(temp_dir), + ) + + from astrbot.core.skills import skill_manager as skill_manager_module + + plugin_skills_root = Path(skill_manager_module.get_astrbot_plugin_path()) + _write_skill(plugin_skills_root / "astrbot" / "skills", "pdf", "builtin pdf") + + mgr = SkillManager(skills_root=str(skills_root)) + mgr.set_sandbox_skills_cache( + [ + { + "name": "pdf", + "description": "stale sandbox cache entry", + "path": "/app/skills/pdf/SKILL.md", + } + ] + ) + + assert mgr.is_sandbox_only_skill("pdf") is False