From 73d4d32dfe28bf1ca4b4bec2117201beb7516bbf Mon Sep 17 00:00:00 2001 From: Willie Date: Tue, 7 Apr 2026 20:22:30 +0800 Subject: [PATCH] feat(sync): warn when targets are skipped for agents (no agents path) Both syncAgentsGlobal and syncAgentsProject now collect target names where agentPath is empty and print a summary warning after the sync summary line. This makes it visible to users which targets were silently skipped, helping them configure agents paths if desired. --- cmd/skillshare/sync_agents.go | 16 +++++++++ tests/integration/sync_agent_test.go | 50 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tests/integration/sync_agent_test.go diff --git a/cmd/skillshare/sync_agents.go b/cmd/skillshare/sync_agents.go index c96c37a69..8194d979c 100644 --- a/cmd/skillshare/sync_agents.go +++ b/cmd/skillshare/sync_agents.go @@ -4,6 +4,8 @@ import ( "fmt" "os" "path/filepath" + "sort" + "strings" "time" "skillshare/internal/config" @@ -57,10 +59,12 @@ func syncAgentsGlobal(cfg *config.Config, dryRun, force, jsonOutput bool, start builtinAgents := config.DefaultAgentTargets() var totals agentSyncStats var syncErr error + var skippedTargets []string for name := range cfg.Targets { agentPath := resolveAgentTargetPath(cfg.Targets[name], builtinAgents, name) if agentPath == "" { + skippedTargets = append(skippedTargets, name) continue } @@ -81,6 +85,11 @@ func syncAgentsGlobal(cfg *config.Config, dryRun, force, jsonOutput bool, start ui.Info("Agent sync: %d linked, %d local, %d updated, %d pruned (%s)", totals.linked, totals.skipped, totals.updated, totals.pruned, formatDuration(start)) + if len(skippedTargets) > 0 { + sort.Strings(skippedTargets) + ui.Warning("%d target(s) skipped for agents (no agents path): %s", + len(skippedTargets), strings.Join(skippedTargets, ", ")) + } } return totals, syncErr @@ -135,6 +144,7 @@ func syncAgentsProject(projectRoot string, dryRun, force, jsonOutput bool, start builtinAgents := config.ProjectAgentTargets() var totals agentSyncStats var syncErr error + var skippedTargets []string // Load project config for target list projCfg, loadErr := config.LoadProject(projectRoot) @@ -145,6 +155,7 @@ func syncAgentsProject(projectRoot string, dryRun, force, jsonOutput bool, start for _, entry := range projCfg.Targets { agentPath := resolveProjectAgentTargetPath(entry, builtinAgents, projectRoot) if agentPath == "" { + skippedTargets = append(skippedTargets, entry.Name) continue } @@ -164,6 +175,11 @@ func syncAgentsProject(projectRoot string, dryRun, force, jsonOutput bool, start ui.Info("Project agent sync: %d linked, %d local, %d updated, %d pruned (%s)", totals.linked, totals.skipped, totals.updated, totals.pruned, formatDuration(start)) + if len(skippedTargets) > 0 { + sort.Strings(skippedTargets) + ui.Warning("%d target(s) skipped for agents (no agents path): %s", + len(skippedTargets), strings.Join(skippedTargets, ", ")) + } } return syncErr diff --git a/tests/integration/sync_agent_test.go b/tests/integration/sync_agent_test.go new file mode 100644 index 000000000..72c9b79ef --- /dev/null +++ b/tests/integration/sync_agent_test.go @@ -0,0 +1,50 @@ +//go:build !online + +package integration + +import ( + "os" + "path/filepath" + "testing" + + "skillshare/internal/testutil" +) + +func TestSync_Agents_SkipsTargetsWithoutAgentsPath(t *testing.T) { + sb := testutil.NewSandbox(t) + defer sb.Cleanup() + + // Create agents source with an agent + agentsDir := filepath.Join(filepath.Dir(sb.SourcePath), "agents") + os.MkdirAll(agentsDir, 0755) + os.WriteFile(filepath.Join(agentsDir, "helper.md"), []byte("# Helper"), 0644) + + // Configure a target WITH agents path and one WITHOUT + claudeSkills := filepath.Join(sb.Home, ".claude", "skills") + claudeAgents := filepath.Join(sb.Home, ".claude", "agents") + windsurf := filepath.Join(sb.Home, ".windsurf", "skills") + + sb.WriteConfig(`source: ` + sb.SourcePath + ` +targets: + claude: + skills: + path: "` + claudeSkills + `" + agents: + path: "` + claudeAgents + `" + windsurf: + skills: + path: "` + windsurf + `" +`) + + result := sb.RunCLI("sync", "agents") + result.AssertSuccess(t) + + // Agent should be synced to claude + if !sb.FileExists(filepath.Join(claudeAgents, "helper.md")) { + t.Error("agent should be synced to claude agents dir") + } + + // Warning should mention windsurf was skipped + result.AssertAnyOutputContains(t, "skipped") + result.AssertAnyOutputContains(t, "windsurf") +}