"cursor" joins retiredBuiltins (migrate.go), so PluginServes("cursor")
holds moved or not, and the built-in's code goes, as Zed's did in
c0605abc2 and Kiro's in the commit before this.
Removed:
- gateway/cursor.go (the Connect/protobuf translator) and its tests
(cursor_test, cursor_conversation_test, cursor_maxmode_test,
cursor_precision_test, cursor_stepusage_test), and gateway.go's
Account.Agent == "cursor" dispatch to serveCursor;
- provider/cursor_usage.go (the usage card, cursorToken, cursorKeychain)
and provider/cursor_picker.go, with their tests;
- from cursor.go: the built-in account (cursorAccount), its model list
through `cursor-agent models` (cursorModels, parseCursorModels,
cursorModelL), its sign-in (startCursorSignIn, cursorLinkWhole,
cursorLoginUUID), the API client version (CursorClientVersion,
cursorVersionFallback, cursorVersionRe) and the token refresh
(CursorToken, cursorRefresh, tokenExpiry);
- StartSignIn's "cursor" case (signin.go), the usage fetch
(subscription_usage.go), the login-list case and quota (login_usage.go)
and the account (account.go);
- "cursor" from Native (provider.go) and asksOwnBackend (modelprefs.go).
Kept, because the mover, the plugin paths or other code need them:
- cursor.go's PLUGIN-SERVED notice (TestMovedBuiltinsSayTheirPlugin);
cursorIdentity, cursorStatus, parseCursorAbout, readCursorToken,
cursorTokenOf, cursorKeychainToken and cursorAuthFile: migrate_side.go
and plugin_accounts.go ask whose account the agent is through them;
- cursorLoginURL (grok.go and claude_signin.go use it), cursorContext and
withCursorContexts (the plugin's model contexts), CursorExecutable and
isCursorAgent (the Cursor agent itself);
- cursor_models.go whole: CursorBase (agent/legacy.go), CursorVariants
(groupfast.go, the plugin's fast pick), cursorPicks and the collapse
(provider.go, models.go);
- accountIDs, builtinOrder, models.go's "cursor" live branch and
servedByCursor, as Zed's and Kiro's commits left theirs. The live
collapse and cursorPicks now only ever meet a built-in list, which a
retired Cursor never has; they are left for a cleanup of their own.
- gateway/cursor_local_models_test.go (the Cursor agent, not the
built-in) and the gateway's plugin_*_test.go parity tests.
Tests changed in meaning:
- cursor_signin_test.go became cli_signin_test.go: its two generic
runCLISignIn tests stay (grok's), TestCursorSignInJoinsAWrappedLink
goes with cursorLinkWhole.
- cursor_test.go keeps parseCursorModels as a test helper (the old
parser, for the collapse tests' fixtures); TestParseCursorModels,
TestCursorClientVersion, TestTokenExpiry and TestCursorLegacyPicks go,
and cursor_names_test.go's TestCursorAvailableNames: they tested the
built-in account's list and picks. Cursor's plugin lists its own
picker models with their efforts (index.mjs), so magpie's collapse
never runs for it; moving the two tests onto the plugin showed that.
- TestFetchNewWaitsForASlowSignIn (#1789) and
TestFetchNewListsAgainForAnAnswerWhileListing (#1147) are gone: both
were about a CLI account whose models `cursor-agent models` lists,
and no built-in left lists its models through its CLI.
- internal/gui/providers_fetching_unix_test.go
(TestProvidersAnswerWhileListsComeIn, #541) is gone: its slow vendor
was the built-in's `cursor-agent models`. The guarantee (the
Providers page answers while an account's list comes in) has no test
now; re-homing it onto an HTTP-listed account (Antigravity, Copilot)
needs exported test hooks and is left as a follow-up.
- TestNative drops its Cursor case; TestLeftAloneRunsNoCLI fakes and
expects claude and devin only; isolate() and
TestAccountDiscoveryOffReadsNoSignIn no longer set cursorKeychain
(cursorTokenOf reads the Keychain on macOS only, as before).
- Dropped as built-in only: the Cursor case of the required-tools test,
TestCodexToolImageCursor, TestCursorSplitParallelCallsKeepTheirResults.
Run at this tree (load ~300, so narrow runs only):
- gofmt -l internal: clean
- go vet -tags nogui ./... ; GOOS=linux and GOOS=windows the same: ok
- staticcheck -tags nogui -checks U1000 ./internal/provider/: clean;
with -tests=false over provider and gateway: nothing Cursor or Kiro
- go test -tags nogui -count=1 -run 'Cursor|Kiro|Migrat|Mov|Retired|
SignIn|AsksOwnBackend|Plugin|HandOver|NoWayBack|Adopt|Hide|
RequiredTools|ToolImage|Split|Discovery|Account|Isolat' over
provider, gateway, cli, gui: gateway ok 446s, cli ok 67s, gui ok 51s;
provider failed TestCursorAvailableNames, TestCursorLegacyPicks,
TestFetchNewWaitsForASlowSignIn (above) and
TestSetUpstreamNameRefusesAnAccountBackend (Kiro's, fixed in that
commit)
- every other test naming "cursor" or cursor-agent, by name, over the
same four packages: gateway and cli ok; TestNative,
TestLeftAloneRunsNoCLI, TestFetchNewListsAgainForAnAnswerWhileListing
and TestProvidersAnswerWhileListsComeIn failed (above)
- after the changes: gofmt clean, vet ok on all three; -run 'Cursor|
Kiro|Migrat|Mov|Retired|SignIn|AsksOwnBackend|Plugin|HandOver|
NoWayBack|Adopt|Hide|Discovery|Account|Native|LeftAlone|SetUpstream|
FetchNew|Hold|DailyCredits|NotSignedIn|ModelTest|Providers': provider
ok 141s, gui ok 21s, cli ok 22s (gateway untouched since its ok run)
Not run: the whole packages, the full suite, the GUI node suite.
51 lines
2.2 KiB
Go
51 lines
2.2 KiB
Go
package provider
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
)
|
|
|
|
// Native is the API a client does best to ask a model on, for the gateway
|
|
// to relay it as it is.
|
|
func TestNative(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
|
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
|
catalog.Reset()
|
|
t.Cleanup(catalog.Reset)
|
|
// Copilot's model list says which APIs serve each model
|
|
if err := catalog.SaveLive("copilot", "https://api.githubcopilot.com", []catalog.Model{
|
|
{ID: "gpt-5.5", APIs: []string{"responses"}}, {ID: "claude-sonnet-5", APIs: []string{"chat", "anthropic"}}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
openai := Provider{ID: "openai", Chat: "https://api.openai.com/v1", Responses: "https://api.openai.com/v1"}
|
|
copilot := Provider{ID: "copilot", Chat: "https://api.githubcopilot.com", Responses: "https://api.githubcopilot.com", Anthropic: "https://api.githubcopilot.com"}
|
|
for _, c := range []struct {
|
|
name string
|
|
p Provider
|
|
model string
|
|
want Protocol
|
|
}{
|
|
{"chat only", Provider{ID: "relay", Chat: "https://relay.test/v1"}, "glm-4.6", Chat},
|
|
{"responses only", Provider{ID: "resp", Responses: "https://resp.test/v1"}, "m", Responses},
|
|
{"ChatGPT sign-in", Provider{ID: "codex", Responses: CodexBase, Account: &Account{Agent: "codex"}}, "gpt-5.5", Responses},
|
|
{"GPT on OpenAI's API", openai, "gpt-5.5", Responses},
|
|
{"o-series on OpenAI's API", openai, "o3", Responses},
|
|
{"other on OpenAI's API", openai, "whisper-x", Chat},
|
|
{"Chat and Responses elsewhere", Provider{ID: "both", Chat: "https://x.test/v1", Responses: "https://x.test/v1"}, "gpt-5.5", Chat},
|
|
{"anthropic only", Provider{ID: "anthropic", Anthropic: "https://api.anthropic.com"}, "claude-sonnet-5", Anthropic},
|
|
{"Copilot GPT", copilot, "gpt-5.5", Responses},
|
|
{"Copilot Claude", copilot, "claude-sonnet-5", Anthropic},
|
|
{"Claude Code", Provider{ID: "claude", Anthropic: "https://api.anthropic.com", Account: &Account{Agent: "claude"}}, "claude-sonnet-5", ""},
|
|
{"nothing", Provider{ID: "none"}, "m", ""},
|
|
} {
|
|
if got := c.p.Native(c.model); got != c.want {
|
|
t.Errorf("%s: %q, want %q", c.name, got, c.want)
|
|
}
|
|
}
|
|
}
|