Kimi (a sponsor) reported: "伙伴卡编辑器默认区为 China,建议按用户区域分流".
A partner given only by regions started at its first one, and Kimi
Code's partner card lists China first, so a user abroad was offered the
China plan's endpoints, key page and catalog.
Now, when a partner's first region is China's or Global's and the other
is listed too, a new provider of it starts at the one where the user is:
China's in mainland China, Global's elsewhere. The place is read from
this computer's time zone: LocalZone ($TZ, /etc/localtime) on macOS and
Linux, the registry's TimeZoneKeyName on Windows. Asia/Shanghai,
Asia/Urumqi and their old names (Chongqing, Harbin, Kashgar, PRC) and
Windows' "China Standard Time" are mainland China; Hong Kong, Macau and
Taipei have zones of their own and get Global. Windows' China Standard
Time also covers Hong Kong, which Windows doesn't tell apart. A zone
that can't be read keeps the partner's first region, as before.
It is decided in validPartners, where the partner's default endpoints
are filled in, so every add path takes it: the GUI editor (its region
picker marks the region at the preset's endpoints, and Get a key and the
site link follow), the TUI's and CLI's add (FromPreset). The default
region's key page, site, siteHost and catalog become the preset's with
its endpoints, as atRegionOf does for a provider.
Which regions count: only one with id cn/china/global/intl or named
China, China Mainland, Mainland China, Global or International. Checked
against each partner in site/partners.js: Kimi (China, Global, "Pay as
you go · China", "Pay as you go · Global") switches between its two
plans only; APIKEY.FAN (Default, Direct) gives its own top-level
endpoints, so no region is defaulted; WandAPI, CoreCode, Sidrune and
FastAIToken have no regions. yylx (a built-in preset, not a partner)
lists Auto first and would stay at Auto anyway.
Providers already added keep their region: a provider stores its own
endpoints when it is added, and its region is read from them
(regionOf), so a user who moves keeps theirs. The list kept on disk
from before is fixed at the next fetch, which runs at start.
Tests:
- TestPartnerStartsAtTheUsersRegion, from usemagpie.ai/api/partners as
served on 2026-10-27 (testdata/partners-2026-10-27.json): abroad Kimi
Code starts at api.kimi.ai, keys /go/kimi/keys/global, site host
www.kimi.ai, catalog kimi-code-plan-global; in China and with no zone
at api.kimi.com and China's; a provider added in China stays there
after the user is abroad and the list is fetched again; APIKEY.FAN
starts at its own endpoints either way.
- TestHomeRegion: Kimi's four regions, yylx's Auto first, Global first,
plans only, no Global; chinaZone for Shanghai, Urumqi, PRC, China
Standard Time, Hong Kong, Taipei, Singapore, New York, UTC and "".
- Broken by hand: with the region back at p.Regions[0], the test fails
"abroad: a new Kimi Code provider is at {chat:https://api.kimi.com/
coding/v1 … catalog:kimi-code-plan-cn}, want {… api.kimi.ai …
kimi-code-plan-global}" and "the preset's endpoints … aren't its home
region's". With the key page/site/catalog line dropped, it fails on
keys https://usemagpie.ai/go/kimi/keys (not …/keys/cn) in China.
- go test -tags nogui -count=1 -timeout 45m ./internal/provider
./internal/cli ./internal/tui at 56de2d192 + these two commits: cli
ok, tui ok. internal/provider has three reds that are already on
main, and they fail the same way at origin/main 14e4d8040, just
fetched, run alone -count=3: TestFetchAsksASharedBaseOnce,
TestFetchAsksOneListOnceForTwoBasesOfIt and
TestFetchUnionsProtocolListsWithoutChat (#3854). The first run, with
nothing skipped, also crashed in TestUnreadLoginsWriteErrorsKeepCredentials
("close of synctest channel from outside bubble", #3632, red on main),
so the second run skipped that one test. No full ./... run: the
machine's disk was full (ENOSPC) from other sessions' caches.
- go build; GOOS=linux go build -tags nogui; GOOS=windows go build.
- Rebased onto 14e4d8040 (45 files changed on main since 56de2d192,
none of them these): go build, go vet ./internal/provider and
-run 'TestPartner|TestHomeRegion|TestPreset' ./internal/provider ok
at the pushed head; the package run above was not repeated there.
- gofmt -l: nothing; go vet, GOOS=linux go vet -tags nogui and
GOOS=windows go vet on internal/provider: clean; GOOS=windows go build.
Not tried: the Windows registry read on a real Windows machine (the
Windows box didn't answer ssh); the GUI editor with a real partner list
in a sandbox; the GUI suite (no file under internal/gui changed).