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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/spf13/cobra v1.10.2
github.com/stretchr/testify v1.11.1
github.com/wagiedev/claude-agent-sdk-go v0.0.3
github.com/wagiedev/codex-agent-sdk-go v0.0.2
golang.org/x/sync v0.20.0
golang.org/x/term v0.43.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
20 changes: 18 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ github.com/docker/go-connections v0.7.0 h1:6SsRfJddP22WMrCkj19x9WKjEDTB+ahsdiGYf
github.com/docker/go-connections v0.7.0/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down Expand Up @@ -209,6 +211,8 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
Expand Down Expand Up @@ -237,6 +241,8 @@ github.com/pterm/pterm v0.12.83 h1:ie+YmGmA727VuhxBlyGr74Ks+7McV6kT99IB8EU80aA=
github.com/pterm/pterm v0.12.83/go.mod h1:xlgc6bFWyJIMtmLJvGim+L7jhSReilOlOnodeIYe4Tk=
github.com/redis/go-redis/v9 v9.20.0 h1:WnQYxLkgO2xiXTCJY0ldIiI8dNqCDlQAG+AtaH7a2a0=
github.com/redis/go-redis/v9 v9.20.0/go.mod h1:v/M13XI1PVCDcm01VtPFOADfZtHf8YW3baQf57KlIkA=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down Expand Up @@ -267,6 +273,8 @@ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/wagiedev/claude-agent-sdk-go v0.0.3 h1:MOI6WYkUgbK5yXtzfQyC1SDwUBfJHA1MDqy/5ANZojA=
github.com/wagiedev/claude-agent-sdk-go v0.0.3/go.mod h1:KZz7UJQJBJJkz9Yn9g02HQnnsIr9FiJtWDwNf3U/tMY=
github.com/wagiedev/codex-agent-sdk-go v0.0.2 h1:RtP9a7i4MYbO6CHkICO+ESjw4qaZSJyKULPpKXsWnfg=
github.com/wagiedev/codex-agent-sdk-go v0.0.2/go.mod h1:DRGJ5ybo7oGzG7NVk1O15PfHcpoIKBNWRGaocPruudI=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
Expand Down Expand Up @@ -313,8 +321,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand Down Expand Up @@ -410,3 +418,11 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI=
modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.46.1 h1:eFJ2ShBLIEnUWlLy12raN0Z1plqmFX9Qe3rjQTKt6sU=
modernc.org/sqlite v1.46.1/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=
8 changes: 7 additions & 1 deletion pkg/ai/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ const DefaultProvider = ProviderClaude

// SupportedProviders lists selectable provider IDs.
func SupportedProviders() []ProviderID {
return []ProviderID{ProviderClaude}
return []ProviderID{ProviderClaude, ProviderCodex}
}

// NewEngine creates an Engine for the given provider.
func NewEngine(provider ProviderID, log logrus.FieldLogger) (Engine, error) {
switch provider {
case "", ProviderClaude:
return newClaudeEngine(log), nil
case ProviderCodex:
return newCodexEngine(log), nil
default:
return nil, fmt.Errorf("unsupported provider: %s", provider)
}
Expand Down Expand Up @@ -60,6 +62,8 @@ func providerLabel(provider ProviderID) string {
switch provider {
case ProviderClaude:
return "Claude"
case ProviderCodex:
return "Codex"
default:
return string(provider)
}
Expand All @@ -69,6 +73,8 @@ func providerCapabilities(provider ProviderID) Capabilities {
switch provider {
case ProviderClaude:
return Capabilities{Streaming: true, Interrupt: true, Sessions: true}
case ProviderCodex:
return Capabilities{Streaming: true, Interrupt: true, Sessions: true}
default:
return Capabilities{}
}
Expand Down
112 changes: 112 additions & 0 deletions pkg/ai/factory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package ai

import (
"context"
"testing"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func testLogger() logrus.FieldLogger {
l := logrus.New()
l.SetLevel(logrus.FatalLevel)

return l
}

func TestNewEngine(t *testing.T) {
t.Parallel()

tests := []struct {
name string
provider ProviderID
wantType string
wantErr bool
errContain string
}{
{
name: "empty defaults to claude",
provider: "",
wantType: "*ai.claudeEngine",
},
{
name: "claude provider",
provider: ProviderClaude,
wantType: "*ai.claudeEngine",
},
{
name: "codex provider",
provider: ProviderCodex,
wantType: "*ai.codexEngine",
},
{
name: "unknown provider",
provider: "unknown",
wantErr: true,
errContain: "unsupported provider",
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

engine, err := NewEngine(tc.provider, testLogger())

if tc.wantErr {
require.Error(t, err)
assert.Contains(t, err.Error(), tc.errContain)
assert.Nil(t, engine)

return
}

require.NoError(t, err)
require.NotNil(t, engine)
assert.IsType(t, engine, engine, "engine type mismatch")

// Verify concrete type via provider ID.
if tc.provider == "" || tc.provider == ProviderClaude {
assert.Equal(t, ProviderClaude, engine.Provider())
} else {
assert.Equal(t, tc.provider, engine.Provider())
}
})
}
}

func TestSupportedProviders(t *testing.T) {
t.Parallel()

providers := SupportedProviders()

assert.Len(t, providers, 2)
assert.Contains(t, providers, ProviderClaude)
assert.Contains(t, providers, ProviderCodex)
}

func TestListProviderInfo(t *testing.T) {
t.Parallel()

infos := ListProviderInfo(context.Background(), testLogger(), ProviderClaude)

require.Len(t, infos, 2)

labels := make(map[ProviderID]string, len(infos))
defaults := make(map[ProviderID]bool, len(infos))

for _, info := range infos {
labels[info.ID] = info.Label
defaults[info.ID] = info.Default
assert.True(t, info.Capabilities.Streaming, "%s should support streaming", info.ID)
assert.True(t, info.Capabilities.Interrupt, "%s should support interrupt", info.ID)
assert.True(t, info.Capabilities.Sessions, "%s should support sessions", info.ID)
}

assert.Equal(t, "Claude", labels[ProviderClaude])
assert.Equal(t, "Codex", labels[ProviderCodex])
assert.True(t, defaults[ProviderClaude])
assert.False(t, defaults[ProviderCodex])
}
Loading
Loading