MCPcopy Create free account
hub / github.com/cli/cli / InstallLocal

Function InstallLocal

internal/skills/installer/installer.go:157–179  ·  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

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