MCPcopy Index your code
hub / github.com/docker/docker-agent / LookupCommand

Function LookupCommand

pkg/runtime/commands.go:28–41  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

26// command metadata (e.g. its target agent) typically call LookupCommand to
27// inspect the command before calling ResolveCommand.
28func 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:

Callers 6

PrepareUserMessageFunction · 0.92
LookupCommandMethod · 0.92
ResolveCommandFunction · 0.85

Calls 1

CurrentAgentInfoMethod · 0.65

Tested by 3