mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
Phase 1 — Foundation:
- parseKindArg() defaults to kindSkills, adds "all" keyword
- list: discover agents via resource.AgentKind, populate Kind field in JSON/TUI
- sync agents / sync all: new sync_agents.go handles agent sync to targets
- uninstall: migrate from --kind flag to positional ("uninstall agents <name>")
Phase 2 — Core CRUD:
- update agents: check status, enrich with remote, reinstall from source
- uninstall agents: move .md + sidecar to agent trash with confirmation
- collect agents: CollectAgents from agent-capable targets to source
- trash agents: list/restore/delete/empty for agent trash directory
- trash.RestoreAgent(): file-level restore (vs directory-level for skills)
Behavior: all commands default to skills-only (no breaking change).
"cmd agents" = agents only, "cmd all" = skills + agents.
Fix: TestLog_SyncPartialStatus uses dangling symlink instead of chmod
(root ignores permissions in devcontainer).
25 new integration tests, all passing.
131 lines
3.3 KiB
Go
131 lines
3.3 KiB
Go
//go:build !online
|
|
|
|
package integration
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"skillshare/internal/testutil"
|
|
)
|
|
|
|
func TestInstall_AgentFlag_ParsesCorrectly(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets: {}
|
|
`)
|
|
|
|
// --kind with invalid value should error
|
|
result := sb.RunCLI("install", "--kind", "invalid", "test")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, "must be 'skill' or 'agent'")
|
|
}
|
|
|
|
func TestInstall_AgentFlagShort_ParsesCorrectly(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets: {}
|
|
`)
|
|
|
|
// -a without value should error
|
|
result := sb.RunCLI("install", "-a")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, "requires agent name")
|
|
}
|
|
|
|
func TestCheck_Agents_EmptyDir(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets: {}
|
|
`)
|
|
|
|
// Create agents source dir
|
|
agentsDir := filepath.Join(filepath.Dir(sb.SourcePath), "agents")
|
|
os.MkdirAll(agentsDir, 0755)
|
|
|
|
result := sb.RunCLI("check", "agents")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "No agents found")
|
|
}
|
|
|
|
func TestCheck_Agents_LocalAgent(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets: {}
|
|
`)
|
|
|
|
// Create agents source dir with a local agent
|
|
agentsDir := filepath.Join(filepath.Dir(sb.SourcePath), "agents")
|
|
os.MkdirAll(agentsDir, 0755)
|
|
os.WriteFile(filepath.Join(agentsDir, "tutor.md"), []byte("# Tutor agent"), 0644)
|
|
|
|
result := sb.RunCLI("check", "agents")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "tutor")
|
|
result.AssertAnyOutputContains(t, "local")
|
|
}
|
|
|
|
func TestCheck_Agents_JsonOutput(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets: {}
|
|
`)
|
|
|
|
agentsDir := filepath.Join(filepath.Dir(sb.SourcePath), "agents")
|
|
os.MkdirAll(agentsDir, 0755)
|
|
os.WriteFile(filepath.Join(agentsDir, "tutor.md"), []byte("# Tutor"), 0644)
|
|
|
|
result := sb.RunCLI("check", "agents", "--json")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, `"name"`)
|
|
result.AssertAnyOutputContains(t, `"status"`)
|
|
}
|
|
|
|
func TestEnable_KindAgent_ParsesCorrectly(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets: {}
|
|
`)
|
|
|
|
// Create agents source dir
|
|
agentsDir := filepath.Join(filepath.Dir(sb.SourcePath), "agents")
|
|
os.MkdirAll(agentsDir, 0755)
|
|
|
|
// Disable an agent — --kind goes after -g (mode flag)
|
|
result := sb.RunCLI("disable", "-g", "--kind", "agent", "tutor")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, ".agentignore")
|
|
|
|
// Verify .agentignore was created
|
|
agentIgnorePath := filepath.Join(agentsDir, ".agentignore")
|
|
if !sb.FileExists(agentIgnorePath) {
|
|
t.Error(".agentignore should be created")
|
|
}
|
|
}
|
|
|
|
func TestUninstall_AgentsPositional_ParsesCorrectly(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets: {}
|
|
`)
|
|
|
|
// Positional "agents" with nonexistent agent — should parse correctly (no "unknown option")
|
|
result := sb.RunCLI("uninstall", "-g", "agents", "nonexistent")
|
|
result.AssertOutputNotContains(t, "unknown option")
|
|
}
|