LookupCommand parses userInput as a /command invocation and returns the matching command along with its trailing arguments. The boolean is false when userInput doesn't start with '/' or doesn't match a configured command. Callers that need both the resolved instruction and the original command metad
(ctx context.Context, rt Runtime, userInput string)
| 26 | // command metadata (e.g. its target agent) typically call LookupCommand to |
| 27 | // inspect the command before calling ResolveCommand. |
| 28 | func LookupCommand(ctx context.Context, rt Runtime, userInput string) (cmd types.Command, rest string, ok bool) { |
| 29 | if !strings.HasPrefix(userInput, "/") { |
| 30 | return types.Command{}, "", false |
| 31 | } |
| 32 | |
| 33 | head, tail, _ := strings.Cut(userInput, " ") |
| 34 | commandName := head[1:] |
| 35 | |
| 36 | command, found := rt.CurrentAgentInfo(ctx).Commands[commandName] |
| 37 | if !found { |
| 38 | return types.Command{}, "", false |
| 39 | } |
| 40 | return command, tail, true |
| 41 | } |
| 42 | |
| 43 | // ResolveCommand transforms a /command into its expanded instruction text. |
| 44 | // It processes: |