@@ -425,6 +425,16 @@ def handle_delete_skill(self, data):
425425 self .send_json ({'success' : False , 'error' : str (e )})
426426
427427 # Commands handlers
428+ def _parse_frontmatter (self , content ):
429+ """解析 frontmatter 中的 description"""
430+ import re
431+ match = re .match (r'^---\s*\n([\s\S]*?)\n---' , content )
432+ if match :
433+ for line in match .group (1 ).split ('\n ' ):
434+ if line .startswith ('description:' ):
435+ return line [12 :].strip ()
436+ return None
437+
428438 def handle_list_commands (self ):
429439 commands_dir = os .path .join (FACTORY_DIR , 'commands' )
430440 commands = []
@@ -434,7 +444,15 @@ def handle_list_commands(self):
434444 if entry .endswith ('.md' ):
435445 full_path = os .path .join (real_dir , entry )
436446 if os .path .isfile (full_path ):
437- commands .append ({'name' : entry [:- 3 ], 'path' : full_path })
447+ with open (full_path , 'r' , encoding = 'utf-8' ) as f :
448+ content = f .read ()
449+ desc = self ._parse_frontmatter (content )
450+ commands .append ({
451+ 'name' : entry [:- 3 ],
452+ 'path' : full_path ,
453+ 'description' : desc ,
454+ 'content' : content
455+ })
438456 except :
439457 pass
440458 self .send_json (commands )
@@ -546,12 +564,8 @@ def handle_list_mcp(self):
546564 config = json .load (f )
547565 if 'mcpServers' in config :
548566 for name , server in config ['mcpServers' ].items ():
549- servers .append ({
550- 'name' : name ,
551- 'command' : server .get ('command' , '' ),
552- 'args' : server .get ('args' , []),
553- 'env' : server .get ('env' , {})
554- })
567+ item = {'name' : name , ** server }
568+ servers .append (item )
555569 except :
556570 pass
557571 self .send_json (servers )
0 commit comments