MCPcopy Create free account
hub / github.com/diillson/chatcli / processSpecialCommands

Method processSpecialCommands

cli/cli_commands.go:18–49  ·  view source on GitHub ↗
(ctx context.Context, userInput string)

Source from the content-addressed store, hash-verified

16)
17
18func (cli *ChatCLI) processSpecialCommands(ctx context.Context, userInput string) (string, string, []models.ImageContent) {
19 var additionalContext string
20
21 // Pre-process @path/to/file mentions into @file path/to/file
22 // Matches @./relative/path, @src/file.go, @~/home/file, @/absolute/path
23 // but NOT @file (already handled), @command, @coder, @websearch, @webfetch
24 userInput = expandPathMentions(userInput)
25
26 // Processar comandos especiais
27 userInput, context := cli.processHistoryCommand(userInput)
28 additionalContext += context
29
30 userInput, context = cli.processGitCommand(userInput)
31 additionalContext += context
32
33 userInput, context = cli.processEnvCommand(userInput)
34 additionalContext += context
35
36 userInput, context, images := cli.processFileCommand(ctx, userInput)
37 additionalContext += context
38
39 // Processar '>' como um operador para adicionar contexto
40 if idx := strings.Index(userInput, ">"); idx != -1 {
41 additionalContext += userInput[idx+1:] + "\n"
42 userInput = userInput[:idx]
43 }
44
45 // Remover espaços extras
46 userInput = strings.TrimSpace(userInput)
47
48 return userInput, additionalContext, images
49}
50
51func removeCommandAndNormalizeSpaces(userInput, command string) string {
52 regexPattern := fmt.Sprintf(`(?i)\s*%s\s*`, regexp.QuoteMeta(command))

Callers 6

RunOnceMethod · 0.95
runAgentLogicMethod · 0.95
runCoderLogicMethod · 0.95
runCoderQueryMethod · 0.95
processLLMRequestMethod · 0.95
RunAgentOnceMethod · 0.95

Calls 5

processHistoryCommandMethod · 0.95
processGitCommandMethod · 0.95
processEnvCommandMethod · 0.95
processFileCommandMethod · 0.95
expandPathMentionsFunction · 0.85

Tested by

no test coverage detected