Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func SetAnthropicAPIKey(key string) {
// aliases maps short names to full agent names
var aliases = map[string]string{
"claude": "claude-code",
"agent": "cursor",
}

// resolveAlias returns the canonical agent name, resolving aliases
Expand Down
27 changes: 27 additions & 0 deletions internal/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ func TestAgentRegistry(t *testing.T) {
}
}

func TestCanonicalNameAliases(t *testing.T) {
tests := []struct {
input string
want string
}{
{input: "claude", want: "claude-code"},
{input: "agent", want: "cursor"},
{input: "cursor", want: "cursor"},
}

for _, tt := range tests {
if got := CanonicalName(tt.input); got != tt.want {
t.Errorf("CanonicalName(%q) = %q, want %q", tt.input, got, tt.want)
}
}
}

func TestGetSupportsAgentAlias(t *testing.T) {
a, err := Get("agent")
if err != nil {
t.Fatalf("Get(agent) returned error: %v", err)
}
if a.Name() != "cursor" {
t.Fatalf("Get(agent) resolved to %q, want %q", a.Name(), "cursor")
}
}

func TestAvailableAgents(t *testing.T) {
agents := Available()
if len(agents) < len(expectedAgents) {
Expand Down
19 changes: 19 additions & 0 deletions internal/daemon/server_jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ func TestHandleEnqueueAgentAvailability(t *testing.T) {
tests := []struct {
name string
requestAgent string
defaultAgent string
mockBinaries []string // binary names to place in PATH
expectedAgent string // expected agent stored in job
expectedCode int // expected HTTP status code
Expand All @@ -933,6 +934,21 @@ func TestHandleEnqueueAgentAvailability(t *testing.T) {
expectedAgent: "claude-code",
expectedCode: http.StatusCreated,
},
{
name: "explicit agent alias resolves to cursor",
requestAgent: "agent",
mockBinaries: []string{"agent"},
expectedAgent: "cursor",
expectedCode: http.StatusCreated,
},
{
name: "default agent alias resolves to cursor",
requestAgent: "",
defaultAgent: "agent",
mockBinaries: []string{"agent"},
expectedAgent: "cursor",
expectedCode: http.StatusCreated,
},
{
name: "explicit codex kept when available",
requestAgent: "codex",
Expand All @@ -959,6 +975,9 @@ func TestHandleEnqueueAgentAvailability(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
// Each subtest gets its own server/DB to avoid SHA dedup conflicts
server, _, _ := newTestServer(t)
if tt.defaultAgent != "" {
server.configWatcher.Config().DefaultAgent = tt.defaultAgent
}

// Isolate PATH: only mock binaries + git (no real agent CLIs)
origPath := os.Getenv("PATH")
Expand Down
Loading