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

Function NewPluginFromPath

cli/plugins/plugin.go:169–203  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

167}
168
169func NewPluginFromPath(path string) (Plugin, error) {
170 info, err := os.Stat(path)
171 if err != nil || info.IsDir() {
172 return nil, fmt.Errorf("invalid path")
173 }
174 // (Mantém lógica original de validação Windows vs Unix)
175 if runtime.GOOS != "windows" && info.Mode().Perm()&0111 == 0 {
176 return nil, fmt.Errorf("not executable")
177 }
178
179 cmd := exec.Command(path, "--metadata")
180 output, err := cmd.Output()
181 if err != nil {
182 return nil, err
183 }
184
185 var meta Metadata
186 if err := json.Unmarshal(output, &meta); err != nil {
187 return nil, err
188 }
189
190 var schemaStr string
191 schemaCmd := exec.Command(path, "--schema")
192 if out, err := schemaCmd.Output(); err == nil {
193 if json.Valid(out) {
194 schemaStr = string(out)
195 }
196 }
197
198 return &ExecutablePlugin{
199 metadata: meta,
200 path: path,
201 schema: schemaStr,
202 }, nil
203}

Callers 1

ReloadMethod · 0.85

Calls 4

ErrorfMethod · 0.80
ValidMethod · 0.80
ModeMethod · 0.65
OutputMethod · 0.65

Tested by

no test coverage detected