import: magpie no longer registers CC Switch's ccswitch:// scheme (asombrado_a on X)

889758605 (v0.1.3981, coder_shaun on X asking for one-click import from
relays' CC Switch links) made magpie claim ccswitch:// on every system:
Info.plist on macOS, HKCU\Software\Classes\ccswitch on Windows, and
magpie-ccswitch.desktop on Linux. That scheme is CC Switch's, and magpie
claiming another app's links is not something it should do (asombrado_a
on X: "Magpie为啥要注册 ccswitch://协议的深链").

From this version magpie registers magpie:// only: the ccswitch entry is
out of Info.plist, and the Windows and Linux registration is back to what
it was before 889758605. A start doesn't touch what an older version wrote
(the owner's call); uninstall still takes it out while it is magpie's, as
before. The ccswitch:// parser (importccswitch.go, its test and CC
Switch's example links) goes with it: with nothing registered, no link
reaches it, and ParseImport, ImportLink and `magpie import` take magpie://
links only. The docs' "CC Switch links" paragraph is out in en, zh and ja,
and llms-full.txt and the search indexes are regenerated.

TestRegisterScheme now holds that registration never asks about or claims
x-scheme-handler/ccswitch, and TestImportLink that a ccswitch:// argument
is not taken as an import link.

Run at this commit's tree (rebased on 1318864d1), on mica (mote's load was
38): gofmt clean; go vet darwin, GOOS=windows
(gui, uninstall, provider), GOOS=linux nogui (provider, uninstall);
go test provider, gui, uninstall, cli ok; node --test site/*.test.mjs
135 pass. Linux (wsl-run, magpie-desktop, -tags gtk3), at the tree before the rebase
(the scheme files are the same at this one): provider, uninstall ok; gui ok
except TestClipboardReadBack/copies_after_a_read_back,
which fails the same on origin/main 3ec89c522 (probe segfault, #7073); at this tree TestRegisterScheme*, TestImportLink
and TestImportIsReadOnce ok.
Pushed on 3e66d25d8, which landed after the run and changes internal/agent
only; not run again with it.
Not tried: a real Windows or Linux desktop with an older magpie's
ccswitch registration, which this leaves in place; macOS Launch Services
dropping the scheme once the updated bundle replaces the old one.
This commit is contained in:
yetone
2026-11-18 16:52:58 +08:00
parent 3e66d25d84
commit 03314b25a4
19 changed files with 21 additions and 644 deletions
-4
View File
@@ -20,10 +20,6 @@
<key>CFBundleURLName</key><string>com.yetone.magpie.import</string>
<key>CFBundleURLSchemes</key><array><string>magpie</string></array>
</dict>
<dict>
<key>CFBundleURLName</key><string>com.yetone.magpie.ccswitch</string>
<key>CFBundleURLSchemes</key><array><string>ccswitch</string></array>
</dict>
</array>
<key>NSHumanReadableCopyright</key><string>yetone</string>
</dict>
+3 -5
View File
@@ -11,8 +11,7 @@ import (
"github.com/yetone/magpie/internal/provider"
)
// An import link (magpie://import?… or ccswitch://v1/import?…, see
// provider.ParseImport) is parsed
// An import link (magpie://import?…, see provider.ParseImport) is parsed
// here, parked under a random id, and the window opens on the Providers tab
// with that id; the page fetches it once and asks the user before saving
// anything.
@@ -45,11 +44,10 @@ func stashImport(link string) string {
return id
}
// ImportLink is the link among a launch's arguments, if any: a magpie:// one,
// or a ccswitch:// one, which relays put on their pages for CC Switch.
// ImportLink is the link among a launch's arguments, if any.
func ImportLink(args []string) string {
for _, a := range args {
if l := strings.ToLower(a); strings.HasPrefix(l, provider.Scheme+":") || strings.HasPrefix(l, provider.CCSwitchScheme+":") {
if strings.HasPrefix(strings.ToLower(a), provider.Scheme+":") {
return a
}
}
+3 -7
View File
@@ -31,11 +31,6 @@ func TestImportIsReadOnce(t *testing.T) {
if rec, _ := get(id); rec.Code != 404 {
t.Fatalf("second read: %d", rec.Code)
}
// a relay's CC Switch link opens the same confirmation
id = stashImport("ccswitch://v1/import?resource=provider&app=claude&name=My%20Relay&endpoint=https%3A%2F%2Frelay.example&apiKey=sk-r")
if rec, in := get(id); rec.Code != 200 || in.Error != "" || in.Provider.ID != "my-relay" || in.Provider.Anthropic != "https://relay.example" || in.Provider.Key != "sk-r" {
t.Fatalf("%d %+v", rec.Code, in)
}
if _, in := get(stashImport("magpie://import?name=x")); in.Error == "" {
t.Fatal("a bad link reported no error")
}
@@ -73,7 +68,8 @@ func TestImportLink(t *testing.T) {
if ImportLink([]string{"MAGPIE://import?preset=x"}) == "" {
t.Fatal("missed an upper-case link")
}
if ImportLink([]string{"ccswitch://v1/import?resource=provider&app=claude&name=x"}) == "" {
t.Fatal("missed a CC Switch link")
// ccswitch:// is CC Switch's scheme, not magpie's
if ImportLink([]string{"ccswitch://v1/import?resource=provider&app=claude&name=x"}) != "" {
t.Fatal("took a CC Switch link")
}
}
+2 -39
View File
@@ -61,7 +61,7 @@ Terminal=false
`
if old, err := os.ReadFile(path); err == nil && strings.Contains(string(old), "Exec="+exe+" %u") && strings.Contains(string(old), "x-scheme-handler/magpie") &&
strings.Contains(string(old), "\nStartupWMClass="+programName+"\n") {
return errors.Join(iconErr, registerCCSwitch(dir, exe))
return iconErr
}
if err := os.MkdirAll(dir, 0o755); err != nil {
return err
@@ -70,44 +70,7 @@ Terminal=false
return err
}
_ = proc.Command("update-desktop-database", dir).Run()
return errors.Join(iconErr, proc.Command("xdg-mime", "default", "magpie.desktop", "x-scheme-handler/magpie").Run(), registerCCSwitch(dir, exe))
}
// ccSwitchEntry is the desktop entry that claims ccswitch:// links, apart
// from magpie's own so that it can be left out.
const ccSwitchEntry = "magpie-ccswitch.desktop"
// registerCCSwitch lets magpie open ccswitch:// links, the one-click import
// links relays make for CC Switch, but only when no other app has them: CC
// Switch installed here keeps its links. The desktop's default for the
// scheme is asked first; it is set to this entry only when empty or already
// this entry. No icon or window class of its own: it is never shown.
func registerCCSwitch(dir, exe string) error {
const mime = "x-scheme-handler/ccswitch"
out, _ := proc.Command("xdg-mime", "query", "default", mime).Output()
if def := strings.TrimSpace(string(out)); def != "" && def != ccSwitchEntry {
return nil
}
path := filepath.Join(dir, ccSwitchEntry)
entry := `[Desktop Entry]
Type=Application
Name=magpie (ccswitch:// links)
Exec=` + exe + ` %u
NoDisplay=true
MimeType=` + mime + `;
Terminal=false
`
if old, err := os.ReadFile(path); err == nil && string(old) == entry && strings.TrimSpace(string(out)) == ccSwitchEntry {
return nil
}
if err := os.MkdirAll(dir, 0o755); err != nil {
return err
}
if err := os.WriteFile(path, []byte(entry), 0o644); err != nil {
return err
}
_ = proc.Command("update-desktop-database", dir).Run()
return proc.Command("xdg-mime", "default", ccSwitchEntry, mime).Run()
return errors.Join(iconErr, proc.Command("xdg-mime", "default", "magpie.desktop", "x-scheme-handler/magpie").Run())
}
// installIcon puts magpie's icon where the entry's Icon=magpie is looked
+3 -39
View File
@@ -101,13 +101,8 @@ func TestRegisterScheme(t *testing.T) {
if err := registerScheme(); err != nil {
t.Fatal(err)
}
// ccswitch:// links are claimed too, asked first, and on the second
// run only asked
udd := "update-desktop-database\n" + dir + "\n"
want := udd + "xdg-mime\ndefault\nmagpie.desktop\nx-scheme-handler/magpie\n" +
"xdg-mime\nquery\ndefault\nx-scheme-handler/ccswitch\n" +
udd + "xdg-mime\ndefault\nmagpie-ccswitch.desktop\nx-scheme-handler/ccswitch\n" +
"xdg-mime\nquery\ndefault\nx-scheme-handler/ccswitch\n"
// ccswitch:// is CC Switch's: never asked about or claimed
want := "update-desktop-database\n" + dir + "\n" + "xdg-mime\ndefault\nmagpie.desktop\nx-scheme-handler/magpie\n"
if got, err := os.ReadFile(calls); err != nil || string(got) != want {
t.Fatalf("registration calls: %q, want %q (%v)", got, want, err)
}
@@ -168,7 +163,7 @@ func TestRegisterSchemeBindsAnOlderEntry(t *testing.T) {
t.Fatal(err)
}
checkDesktopBinding(t, data, string(got))
if c, err := os.ReadFile(calls); err != nil || string(c) != "update-desktop-database\nxdg-mime\nxdg-mime\nupdate-desktop-database\nxdg-mime\nxdg-mime\n" {
if c, err := os.ReadFile(calls); err != nil || string(c) != "update-desktop-database\nxdg-mime\n" {
t.Fatalf("registered %q, want once (%v)", c, err)
}
}
@@ -221,34 +216,3 @@ func TestKeepWebData(t *testing.T) {
})
}
}
// CC Switch installed here keeps ccswitch:// links: magpie leaves the
// desktop's default for the scheme alone, and writes no entry for it.
func TestRegisterSchemeLeavesCCSwitchItsLinks(t *testing.T) {
t.Setenv("FLATPAK_ID", "")
root := t.TempDir()
data := filepath.Join(root, "data")
t.Setenv("XDG_DATA_HOME", data)
bin := filepath.Join(root, "bin")
if err := os.Mkdir(bin, 0o755); err != nil {
t.Fatal(err)
}
calls := filepath.Join(root, "calls")
fakeDesktopTools(t, bin, calls, true)
if err := os.WriteFile(calls+".ccswitch", []byte("cc-switch.desktop\n"), 0o644); err != nil {
t.Fatal(err)
}
if err := registerScheme(); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(filepath.Join(data, "applications", ccSwitchEntry)); !os.IsNotExist(err) {
t.Fatalf("an entry for ccswitch:// was written: %v", err)
}
if c, _ := os.ReadFile(calls); strings.Contains(string(c), "default\nmagpie-ccswitch.desktop") {
t.Fatalf("took the default from CC Switch: %q", c)
}
// magpie's own scheme is still registered
if _, err := os.Stat(filepath.Join(data, "applications", "magpie.desktop")); err != nil {
t.Fatal(err)
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
package gui
// registerScheme: the Mac reads the schemes (magpie, ccswitch) from the bundle's Info.plist.
// registerScheme: the Mac reads the scheme from the bundle's Info.plist.
func registerScheme() error { return nil }
// keepWebData: the Mac's webview keeps its data by the bundle id.
+2 -36
View File
@@ -1,10 +1,7 @@
package gui
import (
"errors"
"os"
"path/filepath"
"strings"
"golang.org/x/sys/windows/registry"
)
@@ -16,43 +13,12 @@ func registerScheme() error {
if err != nil {
return err
}
return errors.Join(setScheme("magpie", exe), registerCCSwitch(exe))
}
// registerCCSwitch lets magpie open ccswitch:// links, the one-click import
// links relays make for CC Switch, but only while no other program has
// them: CC Switch installed here, per user or for the machine, keeps its
// links. The merged view (HKEY_CLASSES_ROOT) is asked, so both count; a
// handler whose program is gone is replaced.
func registerCCSwitch(exe string) error {
if run := schemeCommand(registry.CLASSES_ROOT, "ccswitch"); run != "" && !strings.EqualFold(filepath.Clean(run), filepath.Clean(exe)) {
if _, err := os.Stat(run); err == nil {
return nil
}
}
return setScheme("ccswitch", exe)
}
// schemeCommand is the program a scheme's open command runs, "" when none.
func schemeCommand(root registry.Key, scheme string) string {
k, err := registry.OpenKey(root, scheme+`\shell\open\command`, registry.QUERY_VALUE)
if err != nil {
return ""
}
defer k.Close()
v, _, _ := k.GetStringValue("")
run, _, _ := strings.Cut(strings.TrimPrefix(v, `"`), `"`)
return run
}
// setScheme points the per-user handler of scheme at exe.
func setScheme(scheme, exe string) error {
k, _, err := registry.CreateKey(registry.CURRENT_USER, `Software\Classes\`+scheme, registry.SET_VALUE)
k, _, err := registry.CreateKey(registry.CURRENT_USER, `Software\Classes\magpie`, registry.SET_VALUE)
if err != nil {
return err
}
defer k.Close()
_ = k.SetStringValue("", "URL:"+scheme)
_ = k.SetStringValue("", "URL:magpie")
_ = k.SetStringValue("URL Protocol", "")
icon, _, err := registry.CreateKey(k, `DefaultIcon`, registry.SET_VALUE)
if err == nil {
-312
View File
@@ -1,312 +0,0 @@
package provider
import (
"encoding/base64"
"encoding/json"
"net/url"
"slices"
"strings"
"github.com/pelletier/go-toml/v2"
)
// CCSwitchScheme is the URL scheme CC Switch (github.com/farion1231/cc-switch)
// registers. Relays put its one-click import links on their pages, so magpie
// reads them too:
//
// ccswitch://v1/import?resource=provider&app=claude&name=My%20Relay&endpoint=https://relay.example&apiKey=sk-…
// ccswitch://v1/import?resource=provider&app=claude&name=…&configFormat=json&config=<base64 of {"env":{…}}>
//
// The format is read from CC Switch's own parser
// (src-tauri/src/deeplink/parser.rs, provider.rs). Only resource=provider
// is something magpie has (prompts, MCP servers and skills are other
// resources). Parameters:
//
// app claude, claude-desktop, codex, gemini, agy, copilot,
// grokbuild, opencode, openclaw, hermes, pi, mcode, kimi, dsh
// or omp; it picks which endpoint the address is (below)
// name required
// endpoint the base URL; with several, comma separated, the first
// apiKey the API key
// apiFormat anthropic, openai_chat, openai_responses or gemini_native:
// which API the endpoint speaks. Without it, the app's own:
// Anthropic for claude, Responses for codex and grokbuild,
// Gemini for gemini and agy, Chat Completions for the rest
// model, haikuModel, sonnetModel, opusModel the model ids to show
// homepage the vendor's site
// iconUrl a picture, fetched only after the user confirms
// configFormat json (the default) or toml, with config: the base64 of the
// app's own settings. Its address, key and models fill what
// the other parameters leave out, as CC Switch does (claude:
// env.ANTHROPIC_*; codex: auth.OPENAI_API_KEY and
// config.toml's model provider; gemini: GEMINI_API_KEY and
// GOOGLE_GEMINI_BASE_URL). The rest of that config is not
// taken: it is the app's settings, not a provider's
//
// Everything else (enabled, notes, usage*, the CC Switch icon names) is
// dropped. The link goes through the same checks and the same confirmation
// as a magpie:// one: it becomes a magpie://import's parameters (see
// ParseImport), so nothing is saved until the user says yes.
const CCSwitchScheme = "ccswitch"
// ccSwitchLinkApps are the app= values CC Switch's parser accepts.
var ccSwitchLinkApps = []string{"agy", "copilot", "claude", "claude-desktop", "codex", "gemini", "grokbuild", "opencode", "openclaw", "hermes", "pi", "mcode", "kimi", "dsh", "omp"}
// ccSwitchConfigMax bounds the base64 config: a provider's settings are a
// few hundred bytes, and a URL much past this is not one.
const ccSwitchConfigMax = 256 << 10
// ccSwitchQuery translates a ccswitch://v1/import link into the parameters
// of a magpie import.
func ccSwitchQuery(u *url.URL) (url.Values, error) {
if !strings.EqualFold(u.Host, "v1") {
return nil, errorf("ccswitch://%s: magpie reads ccswitch://v1/import links only", u.Host)
}
if u.Path != "/import" {
return nil, errorf("ccswitch link path %q is not /import", u.Path)
}
in := u.Query()
get := func(k string) string { return strings.TrimSpace(in.Get(k)) }
if r := get("resource"); r != "provider" {
if r == "" {
return nil, errorf("the ccswitch link has no resource=")
}
return nil, errorf("magpie takes providers from a ccswitch link; this one is a %q", r)
}
app := get("app")
if !slices.Contains(ccSwitchLinkApps, app) {
return nil, errorf("the ccswitch link's app= is not an app CC Switch knows: %q", app)
}
name := get("name")
if name == "" {
return nil, errorf("the ccswitch link has no name=")
}
if in.Has("configUrl") {
return nil, errorf("the ccswitch link's configUrl= is not supported: the config is inline, or not at all")
}
endpoint, key := get("endpoint"), get("apiKey")
format := strings.TrimSpace(in.Get("apiFormat"))
models := []string{get("model"), get("haikuModel"), get("sonnetModel"), get("opusModel")}
if raw := get("config"); raw != "" {
cfg, err := ccSwitchConfig(raw, get("configFormat"))
if err != nil {
return nil, err
}
c, err := cfg.read(app)
if err != nil {
return nil, err
}
if key == "" {
key = c.key
}
if endpoint == "" {
endpoint = c.endpoint
}
if format == "" {
format = c.format
}
for i, m := range c.models {
if models[i] == "" {
models[i] = m
}
}
}
if i := strings.IndexByte(endpoint, ','); i >= 0 {
endpoint = endpoint[:i] // the first is the one requests go to
}
endpoint = strings.TrimSpace(endpoint)
kind, err := ccSwitchKind(app, format)
if err != nil {
return nil, err
}
out := url.Values{}
out.Set("name", name)
if endpoint != "" {
out.Set(kind, endpoint)
}
if key != "" {
out.Set("key", key)
}
var ids []string
for _, m := range models {
if m = strings.TrimSpace(m); m != "" && !slices.Contains(ids, m) {
ids = append(ids, m)
}
}
out.Set("models", strings.Join(ids, ","))
// a picture or a site that isn't an https URL is dropped, not a reason
// to turn the whole link away: CC Switch does the same
if h := get("homepage"); h != "" && page(h) != "" {
out.Set("website", h)
}
if ic := get("iconUrl"); ic != "" {
if _, err := iconURL(ic); err == nil {
out.Set("icon", ic)
}
}
return out, nil
}
// ccSwitchKind is which of magpie's endpoints the link's address is.
func ccSwitchKind(app, format string) (string, error) {
switch format {
case "":
switch app {
case "claude", "claude-desktop":
return "anthropic", nil
case "codex", "grokbuild":
return "responses", nil
case "gemini", "agy":
return "gemini", nil
}
return "chat", nil
case "anthropic":
return "anthropic", nil
case "openai_chat":
return "chat", nil
case "openai_responses":
return "responses", nil
case "gemini_native":
return "gemini", nil
}
return "", errorf("the ccswitch link's apiFormat= is anthropic, openai_chat, openai_responses or gemini_native, not %q", format)
}
// ccSwitchSettings is what a link's config yields.
type ccSwitchSettings struct {
endpoint, key, format string
models [4]string // model, haiku, sonnet, opus
}
type ccSwitchCfg map[string]any
// ccSwitchConfig decodes the config parameter as CC Switch does: base64
// with the quirks of a URL ("+" arriving as a space, padding left off, the
// URL-safe alphabet), then JSON or TOML.
func ccSwitchConfig(raw, format string) (ccSwitchCfg, error) {
if len(raw) > ccSwitchConfigMax {
return nil, errorf("the ccswitch link's config= is too large")
}
raw = strings.ReplaceAll(strings.Trim(raw, "\r\n"), " ", "+")
raw = strings.TrimRight(raw, "=")
b, err := base64.RawStdEncoding.DecodeString(raw)
if err != nil {
if b, err = base64.RawURLEncoding.DecodeString(raw); err != nil {
return nil, errorf("the ccswitch link's config= is not base64")
}
}
var m map[string]any
switch format {
case "", "json":
err = json.Unmarshal(b, &m)
case "toml":
err = toml.Unmarshal(b, &m)
default:
return nil, errorf("the ccswitch link's configFormat= is json or toml, not %q", format)
}
if err != nil || m == nil {
return nil, errorf("the ccswitch link's config= is not a %s object", orElse(format, "json"))
}
return m, nil
}
func orElse(s, def string) string {
if s == "" {
return def
}
return s
}
func (c ccSwitchCfg) str(path ...string) string {
var v any = map[string]any(c)
for _, k := range path {
m, ok := v.(map[string]any)
if !ok {
return ""
}
v = m[k]
}
s, _ := v.(string)
return strings.TrimSpace(s)
}
func (c ccSwitchCfg) obj(k string) ccSwitchCfg {
m, _ := c[k].(map[string]any)
return m
}
// read takes the address, key and models an app's own settings hold.
func (c ccSwitchCfg) read(app string) (ccSwitchSettings, error) {
var s ccSwitchSettings
switch app {
case "claude", "claude-desktop":
env := c.obj("env")
if env == nil {
return s, errorf("the ccswitch link's claude config needs an env object")
}
s.key = orElse(env.str("ANTHROPIC_AUTH_TOKEN"), env.str("ANTHROPIC_API_KEY"))
s.endpoint = env.str("ANTHROPIC_BASE_URL")
s.models = [4]string{env.str("ANTHROPIC_MODEL"), env.str("ANTHROPIC_DEFAULT_HAIKU_MODEL"), env.str("ANTHROPIC_DEFAULT_SONNET_MODEL"), env.str("ANTHROPIC_DEFAULT_OPUS_MODEL")}
case "gemini", "agy":
env := c
if e := c.obj("env"); e != nil {
env = e
}
s.key = env.str("GEMINI_API_KEY")
s.endpoint = orElse(env.str("GOOGLE_GEMINI_BASE_URL"), env.str("GEMINI_BASE_URL"))
s.models[0] = env.str("GEMINI_MODEL")
case "codex":
return c.readCodex()
}
return s, nil
}
// readCodex reads {"auth":{"OPENAI_API_KEY":…},"config":"<config.toml>"},
// or a config.toml itself. The key a provider table reads from an
// environment variable (env_key) is the computer's own, not the link's, and
// is never taken.
func (c ccSwitchCfg) readCodex() (ccSwitchSettings, error) {
var s ccSwitchSettings
doc := map[string]any(c)
if text := c.str("config"); text != "" {
doc = nil
if err := toml.Unmarshal([]byte(text), &doc); err != nil {
return s, errorf("the ccswitch link's codex config is not TOML")
}
} else if c.obj("auth") != nil {
doc = nil
}
root := ccSwitchCfg(doc)
s.key = c.obj("auth").str("OPENAI_API_KEY")
s.models[0] = root.str("model")
id := root.str("model_provider")
var tbl ccSwitchCfg
if provs := root.obj("model_providers"); provs != nil {
if tbl = provs.obj(id); tbl == nil && len(provs) == 1 {
for _, v := range provs {
tbl, _ = v.(map[string]any)
}
}
}
if tbl != nil {
s.endpoint = tbl.str("base_url")
if s.key == "" {
s.key = tbl.str("experimental_bearer_token")
}
switch tbl.str("wire_api") {
case "chat":
s.format = "openai_chat"
case "responses":
s.format = "openai_responses"
}
if s.key == "" && tbl.str("env_key") != "" {
return s, errorf("the ccswitch link gives its key through the environment variable %s, which a link can't read: add the key yourself", tbl.str("env_key"))
}
}
return s, nil
}
-167
View File
@@ -1,167 +0,0 @@
package provider
import (
"os"
"reflect"
"strings"
"testing"
)
// testdata/ccswitch_links.txt holds CC Switch's own example links, copied
// as written from its repository (deplink.html and the site integration
// guide at 3c76d3b), one per line.
func ccSwitchLinks(t *testing.T) []string {
t.Helper()
b, err := os.ReadFile("testdata/ccswitch_links.txt")
if err != nil {
t.Fatal(err)
}
var out []string
for _, l := range strings.Split(string(b), "\n") {
if strings.TrimSpace(l) != "" {
out = append(out, l)
}
}
return out
}
func TestCCSwitchOwnExamples(t *testing.T) {
type want struct {
Name, Chat, Responses, Anthropic, Gemini, Key string
Models []string
}
got := map[string]want{}
n := 0
for _, l := range ccSwitchLinks(t) {
p, err := ParseImport(l)
if !strings.Contains(l, "resource=provider") {
// prompts, MCP servers and skills are not providers
if err == nil || !strings.Contains(err.Error(), "providers") {
t.Errorf("%.60s: %v", l, err)
}
continue
}
if err != nil {
t.Errorf("%.90s: %v", l, err)
continue
}
n++
if p.ID != "example-ai" && p.ID != "example-gemini" {
t.Errorf("%.90s: id %q", l, p.ID)
}
app := l[strings.Index(l, "app=")+4:]
app = app[:strings.IndexByte(app, '&')]
got[app+"/"+map[bool]string{true: "config", false: "params"}[strings.Contains(l, "config=")]+"/"+p.Name+p.Key+strings.Join(p.Models, ",")] = want{p.Name, p.Chat, p.Responses, p.Anthropic, p.Gemini, p.Key, p.Models}
}
if n != 11 {
t.Fatalf("%d provider links in the examples", n)
}
for _, c := range []struct {
key string
w want
}{
// endpoint, apiKey: claude's address is Anthropic's
{"claude/params/Example AIsk-test-key123", want{Name: "Example AI", Anthropic: "https://api.example.com", Key: "sk-test-key123"}},
// the config's env, with its three tiers
{"claude/config/Example AIsk-test-key123example-chat,example-fast,example-pro", want{Name: "Example AI", Anthropic: "https://api.example.com", Key: "sk-test-key123", Models: []string{"example-chat", "example-fast", "example-pro"}}},
// the key in the URL, the address in the config
{"claude/config/Example AIsk-test-key123", want{Name: "Example AI", Anthropic: "https://api.example.com", Key: "sk-test-key123"}},
// codex: config.toml's provider table, wire_api responses
{"codex/config/Example AIsk-test-key123example-coder", want{Name: "Example AI", Responses: "https://api.example.com/v1", Key: "sk-test-key123", Models: []string{"example-coder"}}},
{"codex/params/Example AIsk-test-key123", want{Name: "Example AI", Responses: "https://api.example.com/v1", Key: "sk-test-key123"}},
{"gemini/config/Example GeminiAIzaSy-test-key123", want{Name: "Example Gemini", Gemini: "https://api.example.com", Key: "AIzaSy-test-key123"}},
// apiFormat names the API an app of any kind speaks
{"opencode/params/Example AIsk-test-key123example-chat", want{Name: "Example AI", Anthropic: "https://api.example.com/v1", Key: "sk-test-key123", Models: []string{"example-chat"}}},
{"pi/params/Example AIsk-test-key123example-chat", want{Name: "Example AI", Chat: "https://api.example.com/v1", Key: "sk-test-key123", Models: []string{"example-chat"}}},
} {
if g, ok := got[c.key]; !ok {
t.Errorf("no example gave %q; have %v", c.key, got)
} else if !reflect.DeepEqual(g, c.w) {
t.Errorf("%s:\n got %+v\nwant %+v", c.key, g, c.w)
}
}
}
func TestCCSwitchIconAndUsageDropped(t *testing.T) {
for _, l := range ccSwitchLinks(t) {
if !strings.Contains(l, "iconUrl=") {
continue
}
p, err := ParseImport(l)
if err != nil || p.IconURL == "" {
t.Fatalf("iconUrl: %q, %v", p.IconURL, err)
}
}
// a usage script (CC Switch's balance query) is code: never taken
p, err := ParseImport("ccswitch://v1/import?resource=provider&app=claude&name=x&endpoint=https%3A%2F%2Fa.example&usageScript=KHsKfSk%3D&usageEnabled=true&usageBaseUrl=https%3A%2F%2Fevil.example")
if err != nil || p.BalanceURL != "" {
t.Fatalf("%+v %v", p, err)
}
}
func TestCCSwitchRefused(t *testing.T) {
const base = "ccswitch://v1/import?resource=provider&app=claude&name=x&endpoint=https%3A%2F%2Fa.example"
for name, c := range map[string]struct{ link, why string }{
"other version": {strings.Replace(base, "//v1/", "//v2/", 1), "v1"},
"other path": {strings.Replace(base, "/import?", "/export?", 1), "/import"},
"no resource": {strings.Replace(base, "resource=provider&", "", 1), "resource"},
"unknown app": {strings.Replace(base, "app=claude", "app=nope", 1), "app"},
"no name": {strings.Replace(base, "name=x&", "", 1), "name"},
"plain http": {strings.Replace(base, "https", "http", 1), "https"},
"javascript": {strings.Replace(base, "https%3A%2F%2Fa.example", "javascript%3Aalert(1)", 1), "base URL"},
"file": {strings.Replace(base, "https%3A%2F%2Fa.example", "file%3A%2F%2F%2Fetc%2Fpasswd", 1), "base URL"},
"bad format": {base + "&apiFormat=grpc", "apiFormat"},
"remote config": {base + "&configUrl=https%3A%2F%2Fa.example%2Fc.json", "configUrl"},
"config not base64": {base + "&config=%25%25%25", "base64"},
"config not json": {base + "&config=bm90IGpzb24", "json"},
"config huge": {base + "&config=" + strings.Repeat("A", 300<<10), "large"},
"claude no env": {base + "&config=e30", "env"},
"key with newline": {base + "&apiKey=sk%0Aevil", "key"},
"no address": {"ccswitch://v1/import?resource=provider&app=claude&name=x", "base URL"},
"codex env_key": {"ccswitch://v1/import?resource=provider&app=codex&name=x&config=" +
b64(`{"config":"model_provider=\"p\"\n[model_providers.p]\nbase_url=\"https://a.example/v1\"\nenv_key=\"HOME_SECRET\""}`), "HOME_SECRET"},
"name only a symbol": {"ccswitch://v1/import?resource=provider&app=claude&name=%2A%2A&endpoint=https%3A%2F%2Fa.example", "id"},
} {
t.Run(name, func(t *testing.T) {
p, err := ParseImport(c.link)
if err == nil {
t.Fatalf("accepted: %+v", p)
}
if !strings.Contains(err.Error(), c.why) {
t.Fatalf("%q does not say %q", err, c.why)
}
})
}
if _, err := ParseImport("ccswitch://v1/import?resource=provider&app=claude&name=x&endpoint=https%3A%2F%2Fa.example&homepage=javascript%3Aalert(1)"); err != nil {
t.Fatalf("a bad homepage turned the link away: %v", err)
}
}
// a ccswitch link is as safe as a magpie one: the balance host rule and
// the id rules are the shared ones
func TestCCSwitchNamedAsSubscription(t *testing.T) {
p, err := ParseImport("CCSWITCH://V1/import?resource=provider&app=claude&name=claude&endpoint=https%3A%2F%2Fa.example")
if err != nil || p.ID == "claude" {
t.Fatalf("%+v %v", p, err)
}
}
func b64(s string) string {
const a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
var out []byte
for i := 0; i < len(s); i += 3 {
var v uint
n := 0
for j := 0; j < 3; j++ {
v <<= 8
if i+j < len(s) {
v |= uint(s[i+j])
n++
}
}
for j := 0; j <= n; j++ {
out = append(out, a[(v>>(18-6*uint(j)))&63])
}
}
return string(out)
}
+1 -9
View File
@@ -53,13 +53,6 @@ const Scheme = "magpie"
// ParseImport reads an import link into the provider it describes.
func ParseImport(link string) (Provider, error) {
u, err := url.Parse(strings.TrimSpace(link))
if err == nil && strings.EqualFold(u.Scheme, CCSwitchScheme) {
q, err := ccSwitchQuery(u)
if err != nil {
return Provider{}, err
}
return importFromQuery(q)
}
if err != nil || !strings.EqualFold(u.Scheme, Scheme) {
return Provider{}, errors.New("not a magpie:// link")
}
@@ -74,8 +67,7 @@ func ParseImport(link string) (Provider, error) {
}
// importFromQuery is ParseImport after the link's shape is known: q holds
// the parameters in the list above, from a magpie:// link or translated from
// a ccswitch:// one (ccSwitchQuery).
// the parameters in the list above.
func importFromQuery(q url.Values) (Provider, error) {
var err error
get := func(k string) string { return strings.TrimSpace(q.Get(k)) }
-14
View File
@@ -1,14 +0,0 @@
ccswitch://v1/import?resource=mcp&apps=claude%2Ccodex&config=eyJtY3BTZXJ2ZXJzIjp7ImNvbnRleHQ3Ijp7ImNvbW1hbmQiOiJucHgiLCJhcmdzIjpbIi15IiwiQHVwc3Rhc2gvY29udGV4dDctbWNwIl0sImVudiI6e319LCJzZXF1ZW50aWFsLXRoaW5raW5nIjp7ImNvbW1hbmQiOiJucHgiLCJhcmdzIjpbIi15IiwiQG1vZGVsY29udGV4dHByb3RvY29sL3NlcnZlci1zZXF1ZW50aWFsLXRoaW5raW5nIl0sImVudiI6e319fX0%3D
ccswitch://v1/import?resource=prompt&app=claude&name=%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5%E4%B8%93%E5%AE%B6&content=IyDku6PnoIHlrqHmn6XkuJPlrrYKCuS9oOaYr%2BS4gOS9jeaciee7j%2BmqjOeahOS7o%2BeggeWuoeafpeWRmOOAguWuoeafpeS7o%2BeggeaXtu%2B8jOWFiOaMh%2BWHuuS8muWvvOiHtOmUmeivr%2BeahOmXrumimO%2B8jOWGjee7meWHuuS%2FruaUueW7uuiuruOAgg%3D%3D&description=%E4%B8%93%E6%B3%A8%E4%BB%A3%E7%A0%81%E8%B4%A8%E9%87%8F
ccswitch://v1/import?resource=provider&app=claude&name=Example%20AI&apiKey=sk-test-key123&configFormat=json&config=eyJlbnYiOnsiQU5USFJPUElDX0JBU0VfVVJMIjoiaHR0cHM6Ly9hcGkuZXhhbXBsZS5jb20iLCJBUElfVElNRU9VVF9NUyI6IjYwMDAwMCJ9fQ%3D%3D
ccswitch://v1/import?resource=provider&app=claude&name=Example%20AI&configFormat=json&config=eyJlbnYiOnsiQU5USFJPUElDX0FVVEhfVE9LRU4iOiJzay10ZXN0LWtleTEyMyIsIkFOVEhST1BJQ19CQVNFX1VSTCI6Imh0dHBzOi8vYXBpLmV4YW1wbGUuY29tIiwiQU5USFJPUElDX01PREVMIjoiZXhhbXBsZS1jaGF0IiwiQU5USFJPUElDX0RFRkFVTFRfSEFJS1VfTU9ERUwiOiJleGFtcGxlLWZhc3QiLCJBTlRIUk9QSUNfREVGQVVMVF9TT05ORVRfTU9ERUwiOiJleGFtcGxlLWNoYXQiLCJBTlRIUk9QSUNfREVGQVVMVF9PUFVTX01PREVMIjoiZXhhbXBsZS1wcm8ifX0%3D
ccswitch://v1/import?resource=provider&app=claude&name=Example%20AI&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-test-key123&iconUrl=https%3A%2F%2Fraw.githubusercontent.com%2Ffarion1231%2Fcc-switch%2Fmain%2Fsrc-tauri%2Ficons%2F128x128.png
ccswitch://v1/import?resource=provider&app=claude&name=Example+AI&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-test-key123&usageScript=KHsKICByZXF1ZXN0OiB7CiAgICB1cmw6ICJ7e2Jhc2VVcmx9fS91c2VyL2JhbGFuY2UiLAogICAgbWV0aG9kOiAiR0VUIiwKICAgIGhlYWRlcnM6IHsKICAgICAgIkF1dGhvcml6YXRpb24iOiAiQmVhcmVyIHt7YXBpS2V5fX0iCiAgICB9CiAgfSwKICBleHRyYWN0b3I6IGZ1bmN0aW9uIChyZXNwb25zZSkgewogICAgaWYgKHJlc3BvbnNlLmVycm9yKSB7CiAgICAgIHJldHVybiB7IGlzVmFsaWQ6IGZhbHNlLCBpbnZhbGlkTWVzc2FnZTogU3RyaW5nKHJlc3BvbnNlLmVycm9yLm1lc3NhZ2UgfHwgcmVzcG9uc2UuZXJyb3IpIH07CiAgICB9CiAgICByZXR1cm4gewogICAgICByZW1haW5pbmc6IE51bWJlcihyZXNwb25zZS5iYWxhbmNlKSwKICAgICAgdW5pdDogIlVTRCIKICAgIH07CiAgfQp9KQ
ccswitch://v1/import?resource=provider&app=claude&name=Example+AI&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-test-key123&usageScript=KHsKICByZXF1ZXN0OiB7CiAgICB1cmw6ICJ7e2Jhc2VVcmx9fSIucmVwbGFjZSgvXC8rJC8sICIiKS5yZXBsYWNlKC9cL3YxJC8sICIiKSArICIvdjEvdXNhZ2UiLAogICAgbWV0aG9kOiAiR0VUIiwKICAgIGhlYWRlcnM6IHsKICAgICAgIkF1dGhvcml6YXRpb24iOiAiQmVhcmVyIHt7YXBpS2V5fX0iLAogICAgICAiVXNlci1BZ2VudCI6ICJjYy1zd2l0Y2gvMS4wIgogICAgfQogIH0sCiAgZXh0cmFjdG9yOiBmdW5jdGlvbiAocmVzcG9uc2UpIHsKICAgIHZhciBxdW90YSA9IHJlc3BvbnNlLnF1b3RhIHx8IHt9OwogICAgdmFyIHJlc3VsdCA9IHsKICAgICAgaXNWYWxpZDogcmVzcG9uc2UuaXNWYWxpZCAhPT0gZmFsc2UsCiAgICAgIHVuaXQ6IHJlc3BvbnNlLnVuaXQgfHwgcXVvdGEudW5pdCB8fCAiVVNEIgogICAgfTsKICAgIGlmICh0eXBlb2YgcmVzcG9uc2UucGxhbk5hbWUgPT09ICJzdHJpbmciKSByZXN1bHQucGxhbk5hbWUgPSByZXNwb25zZS5wbGFuTmFtZTsKICAgIGlmICh0eXBlb2YgcmVzcG9uc2UucmVtYWluaW5nID09PSAibnVtYmVyIiAmJiByZXNwb25zZS5yZW1haW5pbmcgPj0gMCkgewogICAgICByZXN1bHQucmVtYWluaW5nID0gcmVzcG9uc2UucmVtYWluaW5nOwogICAgfQogICAgaWYgKHF1b3RhLmxpbWl0ID4gMCkgewogICAgICByZXN1bHQudXNlZCA9IHF1b3RhLnVzZWQ7CiAgICAgIHJlc3VsdC50b3RhbCA9IHF1b3RhLmxpbWl0OwogICAgfQogICAgaWYgKCFyZXN1bHQuaXNWYWxpZCkgewogICAgICByZXN1bHQuaW52YWxpZE1lc3NhZ2UgPSByZXNwb25zZS5zdGF0dXMKICAgICAgICA%2FIFN0cmluZyhyZXNwb25zZS5zdGF0dXMpCiAgICAgICAgOiAi5p%2Bl6K%2Bi5aSx6LSlIjsKICAgIH0KICAgIHJldHVybiByZXN1bHQ7CiAgfSwKfSk%3D&usageAutoInterval=30
ccswitch://v1/import?resource=provider&app=codex&name=Example%20AI&configFormat=json&config=eyJhdXRoIjp7Ik9QRU5BSV9BUElfS0VZIjoic2stdGVzdC1rZXkxMjMifSwiY29uZmlnIjoibW9kZWxfcHJvdmlkZXIgPSBcImV4YW1wbGVcIlxubW9kZWwgPSBcImV4YW1wbGUtY29kZXJcIlxuXG5bbW9kZWxfcHJvdmlkZXJzLmV4YW1wbGVdXG5uYW1lID0gXCJFeGFtcGxlIEFJXCJcbmJhc2VfdXJsID0gXCJodHRwczovL2FwaS5leGFtcGxlLmNvbS92MVwiXG53aXJlX2FwaSA9IFwicmVzcG9uc2VzXCIifQ%3D%3D
ccswitch://v1/import?resource=provider&app=codex&name=Example+AI&endpoint=https%3A%2F%2Fapi.example.com%2Fv1&apiKey=sk-test-key123&usageScript=KHsKICByZXF1ZXN0OiB7CiAgICB1cmw6ICJ7e2Jhc2VVcmx9fS9hcGkvdXNlci9zZWxmIiwKICAgIG1ldGhvZDogIkdFVCIsCiAgICBoZWFkZXJzOiB7CiAgICAgICJBdXRob3JpemF0aW9uIjogIkJlYXJlciB7e2FjY2Vzc1Rva2VufX0iLAogICAgICAiTmV3LUFwaS1Vc2VyIjogInt7dXNlcklkfX0iCiAgICB9CiAgfSwKICBleHRyYWN0b3I6IGZ1bmN0aW9uIChyZXNwb25zZSkgewogICAgaWYgKHJlc3BvbnNlLnN1Y2Nlc3MgJiYgcmVzcG9uc2UuZGF0YSkgewogICAgICByZXR1cm4gewogICAgICAgIHBsYW5OYW1lOiByZXNwb25zZS5kYXRhLmdyb3VwLAogICAgICAgIHJlbWFpbmluZzogcmVzcG9uc2UuZGF0YS5xdW90YSAvIDUwMDAwMCwKICAgICAgICB1c2VkOiByZXNwb25zZS5kYXRhLnVzZWRfcXVvdGEgLyA1MDAwMDAsCiAgICAgICAgdW5pdDogIlVTRCIKICAgICAgfTsKICAgIH0KICAgIHJldHVybiB7IGlzVmFsaWQ6IGZhbHNlLCBpbnZhbGlkTWVzc2FnZTogU3RyaW5nKHJlc3BvbnNlLm1lc3NhZ2UgfHwgIuafpeivouWksei0pSIpIH07CiAgfQp9KQ&usageBaseUrl=https%3A%2F%2Fapi.example.com&usageAccessToken=test-access-token&usageUserId=1&usageAutoInterval=30
ccswitch://v1/import?resource=provider&app=gemini&name=Example%20Gemini&configFormat=json&config=eyJHRU1JTklfQVBJX0tFWSI6IkFJemFTeS10ZXN0LWtleTEyMyIsIkdPT0dMRV9HRU1JTklfQkFTRV9VUkwiOiJodHRwczovL2FwaS5leGFtcGxlLmNvbSJ9
ccswitch://v1/import?resource=provider&app=opencode&name=Example%20AI&endpoint=https%3A%2F%2Fapi.example.com%2Fv1&apiKey=sk-test-key123&apiFormat=anthropic&model=example-chat
ccswitch://v1/import?resource=provider&app=pi&name=Example%20AI&endpoint=https%3A%2F%2Fapi.example.com%2Fv1&apiKey=sk-test-key123&apiFormat=openai_chat&model=example-chat
ccswitch://v1/import?resource=skill&repo=example%2Fclaude-skills&branch=main
ccswitch://v1/import?resource=provider&app=claude&name=Example%20AI&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-xxxx
+3 -3
View File
@@ -46,7 +46,7 @@ f3475239bc3eacef0f4ee96f19bf35171b647be5fb3913e2ebaf62e56cd2f31a docs/grok-app.
82dc4e3c03c0a8412dbf8d47eb38d08f882662ed4a0165c56aed8bb72472e9a4 docs/hermes.html
91408b1b9744ea84d175b25c58b53b045eb4721236053b145151a3ef184800d1 docs/huaweicloud.html
fd149e201a1538f5f565e6aef5d74800bc55edb398e7f2f3aca51522ffbcde68 docs/images.html
249dab0d96b3fc7020624327d095d1beb085c1d0dceb121ccc0e4cc29c467535 docs/import.html
f0eea48f0a32d63038891aecb5f8f67fd470bcc82d08b853e2072dbe400a42cc docs/import.html
cff1128a2e605a505ba1a0eca20917b6699b787412e358750604eb3eb081a2b2 docs/integrate.html
2b621281527fca8b6874bb7f9d4089f299e7250b2fc065c7ad89a71d05b7f915 docs/intent.html
146befdd5c94abb899d9c70d7a8adf9ea20228faa04e9888ca6ab108092f3981 docs/ja/agent-drift.html
@@ -97,7 +97,7 @@ dcb90288ef0b9252c223b8c51e6f798c4a0c84e610e4aeaf356aefa092f478ae docs/ja/grok-a
7151c30b4648559fc2fc473441c776013375517ab39108392aab755b1abd95fa docs/ja/hermes.html
8162698b9669fcc37e43a018b311b50a5a5c20acc55242607dc4eb93125fe0fb docs/ja/huaweicloud.html
d4b3245c623adbdd27e530d1222d98991de22b688c1cdb0e66955f179eea2735 docs/ja/images.html
6864db1b77faa935a61b72423ae5bb109687bdc315b591f51a4221dd86511531 docs/ja/import.html
0c6e178a623f225dc1e2882b5bc68ae136de3f37844690662e303abc544e83e3 docs/ja/import.html
f063a06ffc57785ad0f8f40f0b2f0bd2ae897ec9d6f290cf664bae2e12d899ed docs/ja/intent.html
1b66f014f31ee045cd77fc406f0a94fc11f6219fbeae70776847bfea4a9a3a39 docs/ja/jcode.html
0738f0b058f859370c5885bbd3d2b087bc36cfbed9f73b3a52983d4c6ec25f3f docs/ja/jetbrains-air.html
@@ -296,7 +296,7 @@ e61d1b02c2bda617d79447210777bb4150154fb6647d1aa2ac3143e0b712d6a7 docs/zh/glm.ht
a9c87ff95e3d530036ffeb0b8eb7ca0b0014517597c7cb88c561e531c58a7ef4 docs/zh/hermes.html
cb88657af0abdc41c0dd805f5557ff5b8b7a2cad2176c2803eb8c9fa61d7e7b3 docs/zh/huaweicloud.html
1f1b59af2d59e6dffedca08fb73cf79016236d4fa58092af44ddbc39d0dade84 docs/zh/images.html
e647c18c0620975014136f265f4c6284e6cb491d1528f798a067ec312bce8d7e docs/zh/import.html
884e502462f8c35c7abf9164c1c6603f20f7bd9c8869de76777c75836c05007e docs/zh/import.html
5f864bffe7b682d1f72b3beefb214bf756669bb7a4128a47adf8d9f2d7ba0806 docs/zh/integrate.html
b7853c115226ffe6a92999a7facee9b8d1f67b04534f2ba298672571c169d801 docs/zh/intent.html
196f06ada68f61e11da15534bab83f9c45a6103b2d7d05fe9770a043c6c3df49 docs/zh/jcode.html
-1
View File
@@ -318,7 +318,6 @@ href = <span class="s">"https://usemagpie.ai/import#"</span> + urlencode({
<tr><td>Linux</td><td>By a desktop entry (<code>x-scheme-handler/magpie</code>), written by the installer and again on first run.</td></tr>
<tr><td>Terminal</td><td><code>magpie import &lt;link&gt;</code> shows the same summary and asks before adding.</td></tr>
</table></div>
<p><b>CC Switch links.</b> magpie also opens the <code>ccswitch://v1/import?resource=provider&amp;…</code> links relays make for CC Switch (<code>app</code>, <code>name</code>, <code>endpoint</code>, <code>apiKey</code>, <code>apiFormat</code>, <code>model</code>, or a base64 <code>config</code>), with the same confirmation. Only providers are taken, not prompts, MCP servers or skills. magpie claims the scheme only when no other app has it, so CC Switch, if installed, keeps its links (on macOS, where both can claim it, the system picks).</p>
<p>Import links need magpie 0.1.8 or later. When magpie is already running, the link goes to that instance and its window comes forward.</p>
</article>
</main>
-1
View File
@@ -318,7 +318,6 @@ href = <span class="s">"https://usemagpie.ai/import#"</span> + urlencode({
<tr><td>Linux</td><td>デスクトップエントリ(<code>x-scheme-handler/magpie</code>)で登録します。インストーラが書き込み、初回起動時にも再度書き込みます。</td></tr>
<tr><td>ターミナル</td><td><code>magpie import &lt;リンク&gt;</code> が同じ概要を表示し、追加前に確認します。</td></tr>
</table></div>
<p><b>CC Switch のリンク。</b>magpie は、リレーが CC Switch 向けに作る <code>ccswitch://v1/import?resource=provider&amp;…</code> リンクも開きます(<code>app</code>、<code>name</code>、<code>endpoint</code>、<code>apiKey</code>、<code>apiFormat</code>、<code>model</code>、または base64 の <code>config</code>)。確認は同じです。取り込むのはプロバイダーだけで、プロンプト、MCP、スキルは対象外です。ほかのアプリがスキームを持っていない場合にだけ登録するため、CC Switch があればそちらが開きます(両方が宣言できる macOS ではシステムが選びます)。</p>
<p>インポートリンクには magpie 0.1.8 以降が必要です。magpie がすでに起動している場合、リンクはそのインスタンスに渡され、ウィンドウが前面に表示されます。</p>
</article>
</main>
-1
View File
@@ -318,7 +318,6 @@ href = <span class="s">"https://usemagpie.ai/import#"</span> + urlencode({
<tr><td>Linux</td><td>通过桌面文件(<code>x-scheme-handler/magpie</code>)注册,安装器写一次,首次运行时再写一次。</td></tr>
<tr><td>终端</td><td><code>magpie import &lt;链接&gt;</code> 显示同样的摘要,添加前会询问。</td></tr>
</table></div>
<p><b>CC Switch 链接。</b>magpie 也能打开中转站为 CC Switch 做的 <code>ccswitch://v1/import?resource=provider&amp;…</code> 链接(<code>app</code>、<code>name</code>、<code>endpoint</code>、<code>apiKey</code>、<code>apiFormat</code>、<code>model</code>,或 base64 的 <code>config</code>),同样要用户确认。只收供应商,不收提示词、MCP 和技能。只有没有别的应用占用这个协议时,magpie 才会注册它:装了 CC Switch 就仍由它打开(macOS 上两者都能声明,由系统选择)。</p>
<p>导入链接需要 magpie 0.1.8 或更新版本。magpie 已在运行时,链接会交给那个实例,并把它的窗口调到前台。</p>
</article>
</main>
-2
View File
@@ -11045,8 +11045,6 @@ An import link is a suggestion. The user decides.
| Linux | By a desktop entry (`x-scheme-handler/magpie`), written by the installer and again on first run. |
| Terminal | `magpie import <link>` shows the same summary and asks before adding. |
**CC Switch links.** magpie also opens the `ccswitch://v1/import?resource=provider&…` links relays make for CC Switch (`app`, `name`, `endpoint`, `apiKey`, `apiFormat`, `model`, or a base64 `config`), with the same confirmation. Only providers are taken, not prompts, MCP servers or skills. magpie claims the scheme only when no other app has it, so CC Switch, if installed, keeps its links (on macOS, where both can claim it, the system picks).
Import links need magpie 0.1.8 or later. When magpie is already running, the link goes to that instance and its window comes forward.
---
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long