MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / Uninstall

Function Uninstall

internal/tools/installer.go:80–103  ·  view source on GitHub ↗

Uninstall best-effort removes the tool. npm-installed tools are removed via `npm uninstall -g `; for other install styles we fall back to deleting the binary discovered on PATH. The returned message is suitable for stdout.

(tool Tool, runner CommandRunner, stdout, stderr io.Writer)

Source from the content-addressed store, hash-verified

78// `npm uninstall -g <pkg>`; for other install styles we fall back to deleting
79// the binary discovered on PATH. The returned message is suitable for stdout.
80func Uninstall(tool Tool, runner CommandRunner, stdout, stderr io.Writer) (int, string, error) {
81 if runner == nil {
82 runner = ShellRunner{}
83 }
84 pkg, isNPM := npmPackage(tool.InstallCmd)
85 if isNPM {
86 cmd := fmt.Sprintf("npm uninstall -g %s", pkg)
87 name, args := shellCommand(cmd)
88 code, err := runner.Run(name, args, stdout, stderr)
89 return code, cmd, err
90 }
91 bin := tool.LaunchCommand()
92 if bin == "" {
93 return 0, "no binary to remove", nil
94 }
95 path, err := exec.LookPath(bin)
96 if err != nil {
97 return 0, fmt.Sprintf("%s not found on PATH", bin), nil
98 }
99 if rmErr := os.Remove(path); rmErr != nil {
100 return 1, fmt.Sprintf("rm %s", path), rmErr
101 }
102 return 0, fmt.Sprintf("removed %s", path), nil
103}
104
105// npmPackage extracts the npm package name from a shell install_cmd like
106// `npm install -g @scope/name@latest`. Returns false when the command is not

Callers 4

UninstallMethod · 0.92
lifecycleCommandMethod · 0.92

Calls 5

npmPackageFunction · 0.85
shellCommandFunction · 0.85
LaunchCommandMethod · 0.80
RunMethod · 0.65
RemoveMethod · 0.45