Implementation:1ay1 Agentty Slash Command Catalog
| Knowledge Sources | |
|---|---|
| Domains | UI, Commands |
| Last Updated | 2026-10-28 12:00 GMT |
Overview
One catalog and resolver for every slash name (built-in actions, user commands, skills, MCP prompts), shared by the TUI composer, submit, ACP, and `agentty run`.
Description
The agentty::slash module is the one catalog of every slash name and one resolver over it. The TUI composer menu, TUI submit, ACP, and `agentty run` all use these, so they agree on what `/name` is. Pure: no IO, no discovery — callers build the Catalog from what they already loaded.
Sources merge into one catalog with precedence: actions > commands > skills > MCP prompts (earlier wins a name clash). The resolver parses a leading `/name` from text, identifies what it maps to (Plain, Action, Command, Skill, Prompt), and provides the rest of the line as args. The composer menu filters by query with exact/prefix/fuzzy matching. Headless callers (`discover`) build the catalog from disk + live MCP pool, and `expand_checked` renders a command/skill/prompt to its expanded text.
Usage
Import this when you need to: build a slash command catalog, resolve a `/name` in input text, filter the composer menu, or expand a slash command for submission.
Code Reference
Source Location
- Repository: 1ay1_Agentty
- File: include/agentty/runtime/slash.hpp
- Lines: 1-156
Signature
namespace agentty::slash {
enum class Kind : std::uint8_t { Action, Command, Skill, Prompt };
enum class Action : std::uint8_t { New, Compact, Model, Rename, Fork, Rewind,
Review, Threads, Settings, Tools, Login, Quit };
struct Entry {
std::string name, description, hint;
Kind kind = Kind::Command;
Action action = Action::New;
bool takes_args = false;
};
struct Catalog { std::vector<Entry> entries; };
[[nodiscard]] const std::vector<Entry>& builtin_actions();
[[nodiscard]] Catalog make_catalog(const std::vector<Source>& commands,
const std::vector<Source>& skills,
const std::vector<Source>& prompts,
bool with_actions = true);
struct Head { std::string_view name, args; bool has_space; };
[[nodiscard]] std::optional<Head> head(std::string_view text);
struct Resolved { What what; const Entry* entry; std::string args; };
[[nodiscard]] Resolved resolve(std::string_view text, const Catalog& cat);
[[nodiscard]] std::vector<Match> filter(const Catalog& cat, std::string_view query);
[[nodiscard]] Completed complete(std::string_view text, const Entry& entry);
// Headless:
[[nodiscard]] Catalog discover(Io, bool with_actions = false);
[[nodiscard]] std::optional<Expanded> expand_checked(Io, std::string_view text, const Catalog&, bool);
}
Import
#include "agentty/runtime/slash.hpp"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| commands/skills/prompts | std::vector<Source> | Yes | Loaded sources for the catalog |
| text | std::string_view | Yes (resolve) | Input text starting with /name |
| query | std::string_view | Yes (filter) | Filter query for the menu |
Outputs
| Name | Type | Description |
|---|---|---|
| resolve() | Resolved | What the text maps to (Plain/Action/Command/Skill/Prompt) |
| filter() | std::vector<Match> | Menu entries matching the query, best first |
| expand_checked() | std::optional<Expanded> | Expanded template text or usage note |
Usage Examples
Build Catalog and Resolve
#include "agentty/runtime/slash.hpp"
auto cat = agentty::slash::make_catalog(cmds, skills, prompts, true);
auto resolved = agentty::slash::resolve("/compact", cat);
// resolved.what == Action, resolved.entry->action == Compact
auto r2 = agentty::slash::resolve("/rename my task", cat);
// r2.what == Action, r2.args == "my task", r2.entry->action == Rename
Filter the Composer Menu
auto matches = agentty::slash::filter(cat, "comp");
// Entries matching "comp", best first (exact > prefix > fuzzy)
for (const auto& m : matches) {
// m.entry->name, m.score, m.hits (byte offsets for highlighting)
}