MCPcopy
hub / github.com/cli/cli / InstallLocal

Function InstallLocal

internal/skills/installer/installer.go:156–178  ·  view source on GitHub ↗

InstallLocal copies skills from a local directory to the target install location.

(opts *LocalOptions)

Source from the content-addressed store, hash-verified

154
155// InstallLocal copies skills from a local directory to the target install location.
156func InstallLocal(opts *LocalOptions) (*Result, error) {
157 targetDir := opts.Dir
158 if targetDir == "" {
159 if opts.AgentHost == nil {
160 return nil, fmt.Errorf("either Dir or AgentHost must be specified")
161 }
162 var err error
163 targetDir, err = opts.AgentHost.InstallDir(opts.Scope, opts.GitRoot, opts.HomeDir)
164 if err != nil {
165 return nil, err
166 }
167 }
168
169 var installed []string
170 for _, skill := range opts.Skills {
171 if err := installLocalSkill(opts.SourceDir, skill, targetDir); err != nil {
172 return nil, fmt.Errorf("failed to install skill %q: %w", skill.InstallName(), err)
173 }
174 installed = append(installed, skill.InstallName())
175 }
176
177 return &Result{Installed: installed, Dir: targetDir}, nil
178}
179
180func installLocalSkill(sourceRoot string, skill discovery.Skill, baseDir string) error {
181 // Use skill.Name (not InstallName) so skills are always installed flat.

Callers 2

runLocalInstallFunction · 0.92
TestInstallLocalFunction · 0.85

Calls 4

installLocalSkillFunction · 0.85
InstallDirMethod · 0.80
InstallNameMethod · 0.80
ErrorfMethod · 0.65

Tested by 1

TestInstallLocalFunction · 0.68