fix: invalidate skills cache on toggle/save/delete and stat skills_dir for deletion detection
This commit is contained in:
1 parent
18528a88f0
commit
0d6932dcce
2 files changed
+8
-1
No files matched your search
@@ -1595,6 +1595,10 @@ def _skill_tree_max_mtime_ns(skills_dir: Path, config_path: Path) -> int:
|
||||
pass
|
||||
if not skills_dir.is_dir():
|
||||
return max_ns
|
||||
try:
|
||||
max_ns = max(max_ns, skills_dir.stat().st_mtime_ns)
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
from agent.skill_utils import iter_skill_index_files
|
||||
for skill_md in iter_skill_index_files(skills_dir, "SKILL.md"):
|
||||
|
||||
+4
-1
@@ -431,6 +431,7 @@ def _visible_pinned_lineage_ids(session_rows) -> set[str]:
|
||||
from api.profiles import ( # noqa: F401, E402 (re-export)
|
||||
_profiles_match,
|
||||
_is_isolated_profile_mode,
|
||||
_SKILLS_STATS_CACHE,
|
||||
get_active_profile_name,
|
||||
get_active_profile_name as _get_active_profile_name,
|
||||
get_active_hermes_home,
|
||||
@@ -19868,6 +19869,7 @@ def _handle_skill_save(handler, body):
|
||||
if skill_file.is_symlink():
|
||||
return bad(handler, "Cannot save to a symlinked skill file")
|
||||
skill_file.write_text(body["content"], encoding="utf-8")
|
||||
_SKILLS_STATS_CACHE.clear()
|
||||
return j(handler, {"ok": True, "name": skill_name, "path": str(skill_file)})
|
||||
|
||||
|
||||
@@ -19887,6 +19889,7 @@ def _handle_skill_delete(handler, body):
|
||||
return bad(handler, "Skill not found", 404)
|
||||
skill_dir = matches[0].parent
|
||||
shutil.rmtree(str(skill_dir))
|
||||
_SKILLS_STATS_CACHE.clear()
|
||||
return j(handler, {"ok": True, "name": body["name"]})
|
||||
|
||||
|
||||
@@ -19961,7 +19964,7 @@ def _handle_skill_toggle(handler, body):
|
||||
_save_yaml_config_file(config_path, cfg)
|
||||
|
||||
reload_config() # outside with block — reload_config() acquires the lock itself
|
||||
|
||||
_SKILLS_STATS_CACHE.clear()
|
||||
return j(handler, {"ok": True, "name": name, "enabled": enabled})
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user