mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 12:23:22 +00:00
fix: install agents from mixed repos after skills
Mixed repos containing both skills/ and agents/ directories previously only installed skills, silently ignoring agents. Now after every skill install exit point, discovered agents are also installed to the agents source directory. - Add installDiscoveredAgents helper that installs agents post-skills - Update 'Found' message to show agent count in mixed repos - Call helper at all 4 skill install exit points in handleGitInstall - Add integration test for mixed-repo install scenario
This commit is contained in:
@@ -218,6 +218,7 @@ func handleGitInstall(source *install.Source, cfg *config.Config, opts install.I
|
||||
logSummary.InstalledSkills = append(logSummary.InstalledSkills, skill.Name)
|
||||
logSummary.SkillCount = len(logSummary.InstalledSkills)
|
||||
}
|
||||
installDiscoveredAgents(discovery, cfg, opts)
|
||||
return logSummary, nil
|
||||
}
|
||||
|
||||
@@ -234,7 +235,11 @@ func handleGitInstall(source *install.Source, cfg *config.Config, opts install.I
|
||||
return handleAgentInstall(discovery, agentsDir, opts, logSummary)
|
||||
}
|
||||
|
||||
ui.StepEnd("Found", fmt.Sprintf("%d skill(s)", len(discovery.Skills)))
|
||||
foundMsg := fmt.Sprintf("%d skill(s)", len(discovery.Skills))
|
||||
if len(discovery.Agents) > 0 {
|
||||
foundMsg += fmt.Sprintf(", %d agent(s)", len(discovery.Agents))
|
||||
}
|
||||
ui.StepEnd("Found", foundMsg)
|
||||
|
||||
// Apply --exclude early so excluded skills never appear in prompts
|
||||
if len(opts.Exclude) > 0 {
|
||||
@@ -302,6 +307,7 @@ func handleGitInstall(source *install.Source, cfg *config.Config, opts install.I
|
||||
logSummary.InstalledSkills = append(logSummary.InstalledSkills, skill.Name)
|
||||
logSummary.SkillCount = len(logSummary.InstalledSkills)
|
||||
}
|
||||
installDiscoveredAgents(discovery, cfg, opts)
|
||||
|
||||
return logSummary, nil
|
||||
}
|
||||
@@ -326,6 +332,7 @@ func handleGitInstall(source *install.Source, cfg *config.Config, opts install.I
|
||||
logSummary.InstalledSkills = append(logSummary.InstalledSkills, batchSummary.InstalledSkills...)
|
||||
logSummary.FailedSkills = append(logSummary.FailedSkills, batchSummary.FailedSkills...)
|
||||
logSummary.SkillCount = len(logSummary.InstalledSkills)
|
||||
installDiscoveredAgents(discovery, cfg, opts)
|
||||
return logSummary, nil
|
||||
}
|
||||
|
||||
@@ -361,6 +368,7 @@ func handleGitInstall(source *install.Source, cfg *config.Config, opts install.I
|
||||
logSummary.InstalledSkills = append(logSummary.InstalledSkills, batchSummary.InstalledSkills...)
|
||||
logSummary.FailedSkills = append(logSummary.FailedSkills, batchSummary.FailedSkills...)
|
||||
logSummary.SkillCount = len(logSummary.InstalledSkills)
|
||||
installDiscoveredAgents(discovery, cfg, opts)
|
||||
|
||||
return logSummary, nil
|
||||
}
|
||||
@@ -1108,6 +1116,37 @@ func handleAgentInstall(discovery *install.DiscoveryResult, agentsDir string, op
|
||||
return logSummary, nil
|
||||
}
|
||||
|
||||
// installDiscoveredAgents installs agents from a mixed repo after skills have been installed.
|
||||
func installDiscoveredAgents(discovery *install.DiscoveryResult, cfg *config.Config, opts install.InstallOptions) {
|
||||
if len(discovery.Agents) == 0 {
|
||||
return
|
||||
}
|
||||
if opts.Kind == "skill" {
|
||||
return
|
||||
}
|
||||
|
||||
agentsDir := cfg.EffectiveAgentsSource()
|
||||
fmt.Println()
|
||||
ui.Header("Installing agents")
|
||||
|
||||
for _, agent := range discovery.Agents {
|
||||
spinner := ui.StartSpinner(fmt.Sprintf("Installing agent %s...", agent.Name))
|
||||
result, err := install.InstallAgentFromDiscovery(discovery, agent, agentsDir, opts)
|
||||
spinner.Stop()
|
||||
if err != nil {
|
||||
ui.ErrorMsg("Failed to install agent %s: %v", agent.Name, err)
|
||||
continue
|
||||
}
|
||||
if result.Action == "skipped" {
|
||||
ui.StepSkip(agent.Name, strings.Join(result.Warnings, "; "))
|
||||
} else if opts.DryRun {
|
||||
ui.Warning("[dry-run] Would install agent: %s", agent.Name)
|
||||
} else {
|
||||
ui.SuccessMsg("Installed agent: %s", agent.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// agentInstallResult tracks the outcome of a single agent install.
|
||||
type agentInstallResult struct {
|
||||
agent install.AgentInfo
|
||||
|
||||
@@ -128,3 +128,44 @@ targets: {}
|
||||
result := sb.RunCLI("uninstall", "-g", "agents", "nonexistent")
|
||||
result.AssertOutputNotContains(t, "unknown option")
|
||||
}
|
||||
|
||||
func TestInstall_MixedRepo_InstallsAgentsToAgentsDir(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets: {}
|
||||
`)
|
||||
|
||||
// Create a git repo with both skills and agents
|
||||
repoDir := filepath.Join(sb.Home, "mixed-repo")
|
||||
os.MkdirAll(filepath.Join(repoDir, "skills", "my-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(repoDir, "skills", "my-skill", "SKILL.md"),
|
||||
[]byte("---\nname: my-skill\n---\n# My Skill"), 0644)
|
||||
os.MkdirAll(filepath.Join(repoDir, "agents"), 0755)
|
||||
os.WriteFile(filepath.Join(repoDir, "agents", "my-agent.md"),
|
||||
[]byte("# My Agent"), 0644)
|
||||
initGitRepo(t, repoDir)
|
||||
|
||||
result := sb.RunCLI("install", "file://"+repoDir, "--yes")
|
||||
result.AssertSuccess(t)
|
||||
|
||||
// Skill should be in skills source
|
||||
skillPath := filepath.Join(sb.SourcePath, "my-skill")
|
||||
if !sb.FileExists(filepath.Join(skillPath, "SKILL.md")) {
|
||||
t.Error("skill should be installed to skills source dir")
|
||||
}
|
||||
|
||||
// Agent should be in agents source (NOT skills source)
|
||||
agentsDir := filepath.Join(filepath.Dir(sb.SourcePath), "agents")
|
||||
agentPath := filepath.Join(agentsDir, "my-agent.md")
|
||||
if !sb.FileExists(agentPath) {
|
||||
t.Errorf("agent should be installed to agents dir (%s), not skills dir", agentsDir)
|
||||
}
|
||||
|
||||
// Agent should NOT be in skills source
|
||||
wrongPath := filepath.Join(sb.SourcePath, "my-agent.md")
|
||||
if sb.FileExists(wrongPath) {
|
||||
t.Error("agent should NOT be in skills source dir")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user