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

Function mightBeInteractive

cli/agent_command_blocks.go:1047–1079  ·  view source on GitHub ↗

mightBeInteractive verifica se comando pode ser interativo

(cmd string, contextInfo agent.CommandContextInfo)

Source from the content-addressed store, hash-verified

1045
1046// mightBeInteractive verifica se comando pode ser interativo
1047func mightBeInteractive(cmd string, contextInfo agent.CommandContextInfo) bool {
1048 if contextInfo.SourceType == agent.SourceTypeFile {
1049 if contextInfo.FileExtension != "" {
1050 nonInteractiveExtensions := map[string]bool{
1051 ".log": true, ".js": true, ".ts": true, ".py": true, ".go": true,
1052 ".java": true, ".php": true, ".rb": true, ".c": true, ".cpp": true,
1053 }
1054 if nonInteractiveExtensions[contextInfo.FileExtension] {
1055 return false
1056 }
1057 }
1058
1059 if hasCodeStructures(cmd) {
1060 return false
1061 }
1062 }
1063
1064 possiblyInteractivePatterns := []string{
1065 "^ping\\s", "^traceroute\\s", "^nc\\s", "^netcat\\s", "^telnet\\s",
1066 "^ssh\\s", "^top$", "^htop$", "^vi\\s", "^vim\\s", "^nano\\s",
1067 "^less\\s", "^more\\s", "^tail -f", "^mysql\\s", "^psql\\s",
1068 "^docker exec -it", "^kubectl exec -it", "^python\\s+-i", "^node\\s+-i",
1069 }
1070
1071 for _, pattern := range possiblyInteractivePatterns {
1072 matched, _ := regexp.MatchString(pattern, cmd)
1073 if matched {
1074 return true
1075 }
1076 }
1077
1078 return false
1079}
1080
1081// hasCodeStructures detecta estruturas de código
1082func hasCodeStructures(content string) bool {

Callers 1

runSingleCommandMethod · 0.85

Calls 1

hasCodeStructuresFunction · 0.85

Tested by

no test coverage detected