(ctx context.Context, userInput string)
| 16 | ) |
| 17 | |
| 18 | func (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 | |
| 51 | func removeCommandAndNormalizeSpaces(userInput, command string) string { |
| 52 | regexPattern := fmt.Sprintf(`(?i)\s*%s\s*`, regexp.QuoteMeta(command)) |
no test coverage detected