22Add skill command - Add AI skills from URL or file.
33"""
44
5+ from __future__ import annotations
6+
7+ from typing import Any
8+
59from core import symbols as sym
610from core .command import Command , CommandContext
711
812
13+ def build_inline_skill (raw_args : str , quoted_text : str = "" ) -> dict [str , Any ] | None :
14+ """Build inline skill payload from command args/quoted text.
15+
16+ Supports:
17+ - addskill <name> <instructions>
18+ - addskill <name> (with quoted message text as instructions)
19+ """
20+ raw = (raw_args or "" ).strip ()
21+ if not raw :
22+ return None
23+
24+ parts = raw .split (maxsplit = 1 )
25+ if not parts :
26+ return None
27+
28+ name = parts [0 ].strip ().lower ()
29+ if not name :
30+ return None
31+
32+ content = parts [1 ].strip () if len (parts ) > 1 else ""
33+ if not content :
34+ content = (quoted_text or "" ).strip ()
35+ if not content :
36+ return None
37+
38+ return {
39+ "name" : name ,
40+ "description" : f"Inline skill: { name } " ,
41+ "trigger" : "always" ,
42+ "priority" : 10 ,
43+ "content" : content ,
44+ }
45+
46+
947class AddSkillCommand (Command ):
1048 name = "addskill"
1149 aliases = ["skill" ]
12- description = "Add an AI skill from URL or attached file"
13- usage = "addskill <url> or attach .md file"
50+ description = "Add an AI skill from inline text, URL, or attached file"
51+ usage = "addskill <name> <instructions> | addskill < url> | attach .md file"
1452 category = "owner"
1553 owner_only = True
1654
@@ -24,9 +62,9 @@ async def execute(self, ctx: CommandContext) -> None:
2462 )
2563
2664 if ctx .args :
27- url = ctx .args [0 ]
28- if url .startswith ("http://" ) or url .startswith ("https://" ):
29- skill = await load_skill_from_url (url )
65+ first_arg = ctx .args [0 ]
66+ if first_arg .startswith ("http://" ) or first_arg .startswith ("https://" ):
67+ skill = await load_skill_from_url (first_arg )
3068 if skill :
3169 save_skill_to_file (skill )
3270 agentic_ai .add_skill (
@@ -83,10 +121,34 @@ async def execute(self, ctx: CommandContext) -> None:
83121 )
84122 return
85123
124+ quoted_text = ""
125+ if ctx .message .quoted_message and ctx .message .quoted_message .get ("text" ):
126+ quoted_text = str (ctx .message .quoted_message .get ("text" ) or "" )
127+
128+ inline_skill = build_inline_skill (ctx .raw_args , quoted_text )
129+ if inline_skill :
130+ save_skill_to_file (inline_skill )
131+ agentic_ai .add_skill (
132+ inline_skill ["name" ],
133+ inline_skill ["content" ],
134+ inline_skill ["description" ],
135+ inline_skill ["trigger" ],
136+ )
137+ await ctx .client .reply (
138+ ctx .message ,
139+ f"{ sym .SUCCESS } *Skill Added*\n \n "
140+ f"*Name:* `{ inline_skill ['name' ]} `\n "
141+ f"*Description:* { inline_skill ['description' ]} \n "
142+ f"*Trigger:* { inline_skill ['trigger' ]} " ,
143+ )
144+ return
145+
86146 await ctx .client .reply (
87147 ctx .message ,
88148 f"{ sym .INFO } *Add AI Skill*\n \n "
89149 f"Usage:\n "
150+ f"• `/addskill <name> <instructions>` - Inline skill\n "
151+ f"• Reply to text with `/addskill <name>`\n "
90152 f"• `/addskill <url>` - Load from URL\n "
91153 f"• Attach a `.md` file and send `/addskill`\n \n "
92154 f"*Skill Format:*\n "
0 commit comments