@@ -54,6 +54,7 @@ def resolve_user_skills_path(ctx, user):
5454 user_path = ctx .get_user_path (user )
5555 return os .path .join (user_path , "skills" )
5656
57+
5758def resolve_skills_write_path (ctx , user = None ):
5859 if user :
5960 user_skills_path = resolve_user_skills_path (ctx , user )
@@ -63,6 +64,7 @@ def resolve_skills_write_path(ctx, user=None):
6364 os .makedirs (home_skills , exist_ok = True )
6465 return home_skills
6566
67+
6668def resolve_all_skills (ctx , user = None ):
6769 home_skills = ctx .get_home_path (os .path .join (".agent" , "skills" ))
6870 skill_roots = {}
@@ -100,37 +102,41 @@ def resolve_all_skills(ctx, user=None):
100102 or os .path .exists (os .path .join (entry .path , "skill.md" ))
101103 ):
102104 skill_dir = Path (entry .path ).resolve ()
103- props = read_properties (skill_dir )
104-
105- # recursivly list all files in this directory
106- files = []
107- for file in skill_dir .glob ("**/*" ):
108- if file .is_file ():
109- full_path = str (file )
110- rel_path = full_path [len (str (skill_dir )) + 1 :]
111- files .append (rel_path )
112-
113- writable = False
114- if ctx .is_auth_enabled ():
115- writable = user_skills_path and is_safe_path (user_skills_path , skill_dir )
116- else :
117- writable = is_safe_path (home_skills , skill_dir ) or is_safe_path (local_skills , skill_dir )
118-
119- skill_props = props .to_dict ()
120- skill_props .update (
121- {
122- "group" : group ,
123- "location" : str (skill_dir ),
124- "files" : files ,
125- "writable" : bool (writable ),
126- }
127- )
128- ret [props .name ] = skill_props
105+ try :
106+ props = read_properties (skill_dir )
107+
108+ # recursivly list all files in this directory
109+ files = []
110+ for file in skill_dir .glob ("**/*" ):
111+ if file .is_file ():
112+ full_path = str (file )
113+ rel_path = full_path [len (str (skill_dir )) + 1 :]
114+ files .append (rel_path )
115+
116+ writable = False
117+ if ctx .is_auth_enabled ():
118+ writable = user_skills_path and is_safe_path (user_skills_path , skill_dir )
119+ else :
120+ writable = is_safe_path (home_skills , skill_dir ) or is_safe_path (local_skills , skill_dir )
121+
122+ skill_props = props .to_dict ()
123+ skill_props .update (
124+ {
125+ "group" : group ,
126+ "location" : str (skill_dir ),
127+ "files" : files ,
128+ "writable" : bool (writable ),
129+ }
130+ )
131+ ret [props .name ] = skill_props
132+ except Exception as e :
133+ ctx .log (f"Failed to load skill { entry .name } from { skill_dir } : { e } " )
129134
130135 except OSError :
131136 pass
132137 return ret
133138
139+
134140def assert_valid_location (ctx , location , user ):
135141 if ctx .is_auth_enabled () and not user :
136142 raise Exception ("Unauthorized" )
@@ -149,6 +155,7 @@ def assert_valid_location(ctx, location, user):
149155 if not is_safe_path (home_skills_path , location ) and not is_safe_path (local_skills_path , location ):
150156 raise Exception ("Cannot modify skills outside of allowed directories" )
151157
158+
152159def install (ctx ):
153160 home_skills = ctx .get_home_path (os .path .join (".agent" , "skills" ))
154161 # if not folder exists
@@ -206,7 +213,7 @@ async def install_skill(request):
206213
207214 user = ctx .assert_username (request )
208215 write_skill_path = resolve_skills_write_path (ctx , user = user )
209-
216+
210217 # Install from GitHub
211218 from .installer import install_from_github
212219
@@ -485,7 +492,10 @@ def skill(name: Annotated[str, "skill name"], file: Annotated[str | None, "skill
485492 files = skill .get ("files" )
486493 if files and len (files ) > 1 :
487494 content += "\n \n ## Skill Files:\n ```\n "
488- return content
495+ content += "\n " .join (files )
496+ content += "\n ```"
497+
498+ return content
489499
490500 ctx .register_tool (skill , group = "core_tools" )
491501
0 commit comments