feat(command): add /skill slash command to list enabled skills
- Register /skill in BUILTIN_COMMAND_SPECS with wrench icon - Add cmd_skill handler that lists skill names and descriptions - Disabled skills are excluded from the output - Add 6 tests covering empty list, names/descriptions, disabled filtering, fallback description, markdown output, and router registration
This commit is contained in:
@@ -98,6 +98,12 @@ BUILTIN_COMMAND_SPECS: tuple[BuiltinCommandSpec, ...] = (
|
||||
"Revert memory to a previous Dream snapshot.",
|
||||
"undo-2",
|
||||
),
|
||||
BuiltinCommandSpec(
|
||||
"/skill",
|
||||
"List skills",
|
||||
"List all enabled skills available to the agent.",
|
||||
"wrench",
|
||||
),
|
||||
BuiltinCommandSpec(
|
||||
"/help",
|
||||
"Show help",
|
||||
@@ -642,6 +648,25 @@ async def cmd_pairing(ctx: CommandContext) -> OutboundMessage:
|
||||
)
|
||||
|
||||
|
||||
async def cmd_skill(ctx: CommandContext) -> OutboundMessage:
|
||||
"""List all enabled skills (name and description only)."""
|
||||
loop = ctx.loop
|
||||
skills = loop.context.skills.list_skills(filter_unavailable=False)
|
||||
if not skills:
|
||||
content = "No skills available."
|
||||
else:
|
||||
lines = [f"Available skills ({len(skills)}):", ""]
|
||||
for entry in skills:
|
||||
desc = loop.context.skills._get_skill_description(entry["name"])
|
||||
lines.append(f"- **{entry['name']}** — {desc}")
|
||||
content = "\n".join(lines)
|
||||
return OutboundMessage(
|
||||
channel=ctx.msg.channel,
|
||||
chat_id=ctx.msg.chat_id,
|
||||
content=content,
|
||||
metadata=dict(ctx.msg.metadata or {}),
|
||||
)
|
||||
|
||||
async def cmd_help(ctx: CommandContext) -> OutboundMessage:
|
||||
"""Return available slash commands."""
|
||||
return OutboundMessage(
|
||||
@@ -681,6 +706,7 @@ def register_builtin_commands(router: CommandRouter) -> None:
|
||||
router.prefix("/dream-log ", cmd_dream_log)
|
||||
router.exact("/dream-restore", cmd_dream_restore)
|
||||
router.prefix("/dream-restore ", cmd_dream_restore)
|
||||
router.exact("/skill", cmd_skill)
|
||||
router.exact("/help", cmd_help)
|
||||
router.exact("/pairing", cmd_pairing)
|
||||
router.prefix("/pairing ", cmd_pairing)
|
||||
|
||||
Reference in New Issue
Block a user