2020SANDBOX_SKILLS_CACHE_FILENAME = "sandbox_skills_cache.json"
2121DEFAULT_SKILLS_CONFIG : dict [str , dict ] = {"skills" : {}}
2222SANDBOX_SKILLS_ROOT = "skills"
23+ SANDBOX_WORKSPACE_ROOT = "/workspace"
2324_SANDBOX_SKILLS_CACHE_VERSION = 1
2425
2526_SKILL_NAME_RE = re .compile (r"^[A-Za-z0-9._-]+$" )
@@ -185,7 +186,7 @@ def set_sandbox_skills_cache(self, skills: list[dict]) -> None:
185186 description = str (item .get ("description" , "" ) or "" )
186187 path = str (item .get ("path" , "" ) or "" )
187188 if not path :
188- path = f"{ SANDBOX_SKILLS_ROOT } /{ name } /SKILL.md"
189+ path = f"{ SANDBOX_WORKSPACE_ROOT } / { SANDBOX_SKILLS_ROOT } /{ name } /SKILL.md"
189190 deduped [name ] = {
190191 "name" : name ,
191192 "description" : description ,
@@ -215,6 +216,17 @@ def list_skills(
215216 modified = False
216217 skills_by_name : dict [str , SkillInfo ] = {}
217218
219+ sandbox_cached_paths : dict [str , str ] = {}
220+ if runtime == "sandbox" :
221+ cache_for_paths = self ._load_sandbox_skills_cache ()
222+ for item in cache_for_paths .get ("skills" , []):
223+ if not isinstance (item , dict ):
224+ continue
225+ name = str (item .get ("name" , "" ) or "" ).strip ()
226+ path = str (item .get ("path" , "" ) or "" ).strip ().replace ("\\ " , "/" )
227+ if name and path and _SKILL_NAME_RE .match (name ):
228+ sandbox_cached_paths [name ] = path
229+
218230 for entry in sorted (Path (self .skills_root ).iterdir ()):
219231 if not entry .is_dir ():
220232 continue
@@ -235,7 +247,9 @@ def list_skills(
235247 except Exception :
236248 description = ""
237249 if runtime == "sandbox" and show_sandbox_path :
238- path_str = f"{ SANDBOX_SKILLS_ROOT } /{ skill_name } /SKILL.md"
250+ path_str = sandbox_cached_paths .get (skill_name ) or (
251+ f"{ SANDBOX_WORKSPACE_ROOT } /{ SANDBOX_SKILLS_ROOT } /{ skill_name } /SKILL.md"
252+ )
239253 else :
240254 path_str = str (skill_md )
241255 path_str = path_str .replace ("\\ " , "/" )
@@ -266,11 +280,15 @@ def list_skills(
266280 continue
267281 description = str (item .get ("description" , "" ) or "" )
268282 if show_sandbox_path :
269- path_str = f"{ SANDBOX_SKILLS_ROOT } /{ skill_name } /SKILL.md"
283+ path_str = (
284+ f"{ SANDBOX_WORKSPACE_ROOT } /{ SANDBOX_SKILLS_ROOT } /{ skill_name } /SKILL.md"
285+ )
270286 else :
271287 path_str = str (item .get ("path" , "" ) or "" )
272288 if not path_str :
273- path_str = f"{ SANDBOX_SKILLS_ROOT } /{ skill_name } /SKILL.md"
289+ path_str = (
290+ f"{ SANDBOX_WORKSPACE_ROOT } /{ SANDBOX_SKILLS_ROOT } /{ skill_name } /SKILL.md"
291+ )
274292 skills_by_name [skill_name ] = SkillInfo (
275293 name = skill_name ,
276294 description = description ,
0 commit comments