agent: telemetry off for Crush, Kimi Code, Goose, Pi and Cline too (daoche_wuzui on X)
Settings > Privacy "Turn off telemetry for all agents" and each agent's own Telemetry row now also cover Crush (options.disable_metrics), Kimi Code (top-level telemetry in config.toml), Goose (GOOSE_TELEMETRY_ENABLED in config.yaml), Pi (enableInstallTelemetry; Pi itself, not its forks) and Cline CLI (telemetryOptOut in data/settings/global-settings.json). Each key was read from that app's source, docs or binary. Same rules as before: only missing keys are written, a user's own value is never overwritten, an unreadable file is unknown (TOML and YAML are parsed strictly). Antigravity (app and agy) has no local key: agy's EnableTelemetry is json:"-" and the setting lives on the Google account. Droid (org-set), OpenCode/omp (OTel is opt-in), Cursor CLI (account privacy mode) and Hermes (sends none) have none either. Grok Build, Kiro, CodeBuddy, Command Code and Amp were not looked at. Run (wsl-run, mote's disk is full): telemetry_more_test.go green; broken by hand twice (wrong off test: crush and cline red; lenient unreadable read: kimi and goose red). go vet for windows, darwin and linux nogui clean. internal/agent whole package: only TestGrokInstalled red, a WSL exec "Invalid argument" in a /tmp stand-in, not touched here; the one red this change caused (TestFolderVarsAreListed, CLINE_GLOBAL_SETTINGS_PATH) is fixed in agentenv.Vars. Real goose and crush binaries read the sandbox paths; not tried: that any of the five honours the written key at run time, Windows run.
This commit is contained in:
@@ -14,7 +14,7 @@ something else shows up as drift.
|
||||
| --- | --- | --- |
|
||||
| Agent description | `Agent` has an id, name, icon, `Bin` and `Dir` for detection, `Path`, `Fields` and `Native`. It also has optional hooks: `Notice`, `UA`, `ListsModels`, `Sync`, `Unwire`, `Join`/`Joined`, `Routed`, `Follow`, `RenameRefs`, `Check`, `LastUsed`, `Reached`, `Import`/`Added`, `Launch`, `SplitSuffix`, `Spelled` and `ModelAliases`. Each hook's comment says which agents need it. | [`agent.go`](../../internal/agent/agent.go) |
|
||||
| Fields and options | A `Field` has `Get`, `Set` and `Options`. `Set("")` returns the field to the agent's default and takes magpie's wiring out. `Quiet` fields follow another field until set (`Follows`, such as Claude Code's tiers). An `Option` carries the picker's facts: `Direct`, `Via`, `Same`, `Alias`, `Rate` and `Context`. The GUI's and TUI's pickers list `Agent.Picks`: with the agent in settings' `ownModelsHidden` (the switch at the top of its model list, #1642), a field that offers catalog models (`Ref`) leaves out the agent's own (no `Ref`), but for its default and the value it is set to. The CLI still takes an own model by name. | [`agent.go`](../../internal/agent/agent.go), [`route.go`](../../internal/agent/route.go) |
|
||||
| The agent's own telemetry | `Agent.Telemetry` (`Get`, `Set`) is the agent's documented switch for the usage data it sends its vendor: Codex's `[analytics] enabled = false`, Claude Code's env `DISABLE_TELEMETRY` and `DISABLE_ERROR_REPORTING`, Gemini CLI's and Qwen Code's `privacy.usageStatisticsEnabled = false` (OipsAnthony on X). It is not a `Field`, so profiles never carry it and Unwire leaves it. Off writes only keys the file lacks and records them in the stash (`<id>.telemetry`); a key the user set on refuses Off, naming it, and one they set off stays. On takes out only what magpie wrote and still holds magpie's value. An unreadable file is unknown: the row says so and can't be pressed. Offered for an agent on this computer only, never a WSL distro's (#3896). The GUI row is `telemetryRow` in the agent's Settings; the route is `POST /api/agents/telemetry/{id}`. Settings › Privacy's "Turn off telemetry for all agents" (`settings.AgentTelemetryOff`, `POST /api/settings/agent-telemetry`, `SetTelemetryAll`) is above every row: on, each agent here is turned off by the same rules and marked in the stash (`<id>.telemetry.all`) unless it was off already; an agent found later is turned off as `state()` sees it and by the gateway's `KeepTelemetryAllOff` loop; each row then shows off, held (`ErrTelemetryAllOff`), or why it couldn't. Off again, only the marked agents are turned back on, so each is as its own row had it. The setting is this computer's (`KeepOwn`), and an unreadable settings.json writes nothing. | [`telemetry.go`](../../internal/agent/telemetry.go), [`telemetry_all.go`](../../internal/agent/telemetry_all.go), [`api.go`](../../internal/gui/api.go) |
|
||||
| The agent's own telemetry | `Agent.Telemetry` (`Get`, `Set`) is the agent's documented switch for the usage data it sends its vendor: Codex's `[analytics] enabled = false`, Claude Code's env `DISABLE_TELEMETRY` and `DISABLE_ERROR_REPORTING`, Gemini CLI's and Qwen Code's `privacy.usageStatisticsEnabled = false` (OipsAnthony on X), Crush's `options.disable_metrics = true`, Kimi Code's top-level `telemetry = false` in config.toml, Goose's `GOOSE_TELEMETRY_ENABLED: false` in config.yaml, Pi's `enableInstallTelemetry = false` and Cline CLI's `telemetryOptOut = true` in global-settings.json (daoche_wuzui on X). Antigravity has none to write (agy's `EnableTelemetry` is `json:"-"`; it is the Google account's setting), nor do Droid (organisation-set), OpenCode and omp (OpenTelemetry is opt-in), Cursor CLI (account privacy mode) and Hermes (sends none). TOML and YAML files are read strictly (`topTelemetryFile`), so a file that doesn't parse is unknown. It is not a `Field`, so profiles never carry it and Unwire leaves it. Off writes only keys the file lacks and records them in the stash (`<id>.telemetry`); a key the user set on refuses Off, naming it, and one they set off stays. On takes out only what magpie wrote and still holds magpie's value. An unreadable file is unknown: the row says so and can't be pressed. Offered for an agent on this computer only, never a WSL distro's (#3896). The GUI row is `telemetryRow` in the agent's Settings; the route is `POST /api/agents/telemetry/{id}`. Settings › Privacy's "Turn off telemetry for all agents" (`settings.AgentTelemetryOff`, `POST /api/settings/agent-telemetry`, `SetTelemetryAll`) is above every row: on, each agent here is turned off by the same rules and marked in the stash (`<id>.telemetry.all`) unless it was off already; an agent found later is turned off as `state()` sees it and by the gateway's `KeepTelemetryAllOff` loop; each row then shows off, held (`ErrTelemetryAllOff`), or why it couldn't. Off again, only the marked agents are turned back on, so each is as its own row had it. The setting is this computer's (`KeepOwn`), and an unreadable settings.json writes nothing. | [`telemetry.go`](../../internal/agent/telemetry.go), [`telemetry_all.go`](../../internal/agent/telemetry_all.go), [`api.go`](../../internal/gui/api.go) |
|
||||
| The list of agents | `All` lists every agent magpie knows, then the WSL agents (`wslAgents`). `Clients` lists every agent whose requests the gateway knows by name, which `usage.Agents` reads. One file per agent: `claude.go`, `codex.go`, `opencode` in `agents.go`, and so on. | [`agents.go`](../../internal/agent/agents.go) |
|
||||
| Connect | `ConnectHow` picks the model an agent starts on and reports how. `How` is one of: `kept`, `again`, `joined`, `magpie`, `same`, `alike`, `default` or `first` (#726). With no models to give, it returns `NoModelsError` (code `no_models`). | [`applied.go`](../../internal/agent/applied.go) |
|
||||
| What magpie set | `Apply` sets a field and records it in `applied.json`. `Wired` says whether magpie is in the config. `Drift` reports `unwired`, `replaced`, `unreachable`, `proxied` or `bypassed`. `Reapply` sets the record again. `Keep` accepts the config as it is now, and keeps the agent connected (`applied.Kept`). An agent whose magpie is a provider of its own config (`Spelled`, not `Native`) is connected only when magpie set it up (`setUp`: a record, `Kept`, or a `<id>.connect.was` stash). A provider named magpie the user wrote by hand (`handWired`) is theirs: it isn't `Wired`, has no `Drift`, and neither `SyncCatalog`, `RenameProvider` nor `Disconnect` writes it; connecting in magpie takes it on (JFunfunfun on X, Pi on `magpie/<model>`; `TestPiHandWiredMagpieProviderIsTheirs`, `TestPiConnectedBeforeStaysConnected`, `TestHandWiredMagpieProviderSiblings`). | [`applied.go`](../../internal/agent/applied.go) |
|
||||
|
||||
@@ -1526,8 +1526,13 @@ func piLikeKeyed(at place, id, name, dir string, key func() string) *Agent {
|
||||
before := beforeMagpie{at.key(id + ".before.absent"), []string{path, modelsPath}}
|
||||
// the entries of enabledModels a sync took out (scope_gone.go)
|
||||
gone := at.key(id + ".scope.gone")
|
||||
var telemetry *Telemetry
|
||||
if id == "pi" {
|
||||
telemetry = piTelemetry(at, path)
|
||||
}
|
||||
return &Agent{
|
||||
ID: id, Name: name, Icon: id, Bin: id, Dir: dir, Path: path, Spelled: prefixed,
|
||||
Telemetry: telemetry,
|
||||
ID: id, Name: name, Icon: id, Bin: id, Dir: dir, Path: path, Spelled: prefixed,
|
||||
Restore: before.restore,
|
||||
Check: func() string {
|
||||
if p, _ := get("defaultProvider"); p != magpieID {
|
||||
@@ -1663,7 +1668,8 @@ func gooseIn(at place, cfg string) *Agent {
|
||||
keyEnv = func(string) string { return "" }
|
||||
}
|
||||
return &Agent{
|
||||
ID: "goose", Name: "Goose", Icon: "goose", Bin: "goose", Dir: filepath.Dir(path), Path: path, Spelled: prefixed, NoNames: true,
|
||||
Telemetry: gooseTelemetry(at, path),
|
||||
ID: "goose", Name: "Goose", Icon: "goose", Bin: "goose", Dir: filepath.Dir(path), Path: path, Spelled: prefixed, NoNames: true,
|
||||
UA: []string{"goose"},
|
||||
Check: func() string {
|
||||
if p, _ := gooseActive(path); p != gooseProviderID {
|
||||
@@ -2052,7 +2058,8 @@ func crushAt(at place, path, data string) *Agent {
|
||||
}
|
||||
}
|
||||
return &Agent{
|
||||
ID: "crush", Name: "Crush", Icon: "crush", Bin: "crush", Dir: filepath.Dir(path), Path: path, Spelled: prefixed,
|
||||
Telemetry: crushTelemetry(at, path),
|
||||
ID: "crush", Name: "Crush", Icon: "crush", Bin: "crush", Dir: filepath.Dir(path), Path: path, Spelled: prefixed,
|
||||
UA: []string{"crush"},
|
||||
Check: func() string {
|
||||
large, _ := pick("models.large.provider")
|
||||
|
||||
@@ -161,8 +161,14 @@ func clineIn(at place) *Agent {
|
||||
}
|
||||
return "cline"
|
||||
}
|
||||
// the setting its CLI reads for every telemetry event; its env path wins
|
||||
settingsPath := at.getenv("CLINE_GLOBAL_SETTINGS_PATH")
|
||||
if settingsPath == "" {
|
||||
settingsPath = filepath.Join(data, "settings", "global-settings.json")
|
||||
}
|
||||
return &Agent{
|
||||
ID: "cline", Name: "Cline", Icon: "cline", Aliases: []string{"cline-cli"}, Spelled: prefixed,
|
||||
Telemetry: clineTelemetry(at, settingsPath),
|
||||
ID: "cline", Name: "Cline", Icon: "cline", Aliases: []string{"cline-cli"}, Spelled: prefixed,
|
||||
UA: []string{"cline"},
|
||||
Bin: "cline", Dir: dir, Path: path,
|
||||
Sync: func() error {
|
||||
|
||||
@@ -294,7 +294,8 @@ func kimiIn(at place) *Agent {
|
||||
return err == nil && t != nil
|
||||
}
|
||||
return atomic(&Agent{
|
||||
ID: "kimi", Name: "Kimi Code", Icon: "kimi", Aliases: []string{"kimi-code", "kimi-cli"}, Spelled: prefixed,
|
||||
Telemetry: kimiTelemetry(at, path),
|
||||
ID: "kimi", Name: "Kimi Code", Icon: "kimi", Aliases: []string{"kimi-code", "kimi-cli"}, Spelled: prefixed,
|
||||
// kimi-cli (Python) says KimiCLI/…; Kimi Code 2.x, kimi-code-cli/…
|
||||
// (jiabubu on Discord: its requests showed the raw name)
|
||||
UA: []string{"kimicli", "kimi-code-cli"},
|
||||
|
||||
@@ -20,6 +20,25 @@ package agent
|
||||
// which is no telemetry.
|
||||
// - Gemini CLI and Qwen Code: privacy.usageStatisticsEnabled = false in
|
||||
// settings.json (settingsSchema.ts of each, default true).
|
||||
// - Crush: options.disable_metrics = true in crush.json (Options in
|
||||
// internal/config/config.go, read from its binary; crush also takes
|
||||
// DO_NOT_TRACK).
|
||||
// - Kimi Code: telemetry = false at the top of config.toml (app.py:
|
||||
// telemetry_disabled = not config.telemetry or KIMI_DISABLE_TELEMETRY).
|
||||
// - Goose: GOOSE_TELEMETRY_ENABLED: false in config.yaml (the key its
|
||||
// `goose configure` telemetry choice writes).
|
||||
// - Pi: enableInstallTelemetry = false in settings.json (docs/settings.md:
|
||||
// anonymous install/update reporting, default true; its env
|
||||
// PI_TELEMETRY wins over the file).
|
||||
// - Cline CLI: telemetryOptOut = true in data/settings/global-settings.json
|
||||
// (the setting its core reads for every telemetry event; default
|
||||
// false).
|
||||
//
|
||||
// Antigravity, Droid, OpenCode, Cursor CLI, Hermes and omp have none to
|
||||
// write: Antigravity's agy keeps it as the Google account's server-side
|
||||
// setting (its EnableTelemetry field is json:"-"), Droid's are set by an
|
||||
// organisation, OpenCode's and omp's OpenTelemetry export is opt-in,
|
||||
// Cursor's privacy mode is the account's, and Hermes sends none.
|
||||
//
|
||||
// None is written unless the user turns it off here. Off writes each key
|
||||
// the file doesn't have and remembers it in the stash; a key the user has
|
||||
@@ -33,13 +52,16 @@ package agent
|
||||
// each look, which would start a stopped distro (#3896).
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"strings"
|
||||
|
||||
toml "github.com/pelletier/go-toml/v2"
|
||||
"github.com/tidwall/jsonc"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
"github.com/yetone/magpie/internal/filememo"
|
||||
@@ -94,6 +116,7 @@ type telemetryFile struct {
|
||||
}
|
||||
|
||||
func isFalse(v any) bool { return v == false }
|
||||
func isTrue(v any) bool { return v == true }
|
||||
|
||||
// anyValue: an environment variable that is set, to anything but empty
|
||||
func anyValue(v any) bool {
|
||||
@@ -263,6 +286,58 @@ func jsonTelemetryFile(path string) telemetryFile {
|
||||
}
|
||||
}
|
||||
|
||||
// topTelemetryFile is a file whose keys sit at the top level, TOML or
|
||||
// YAML (the Kimi and Goose switches): parse reads it strictly, so a file
|
||||
// that doesn't parse is unknown and nothing is written to it.
|
||||
func topTelemetryFile(path, tag string, parse func([]byte, *map[string]any) error,
|
||||
set func(path string, k telemetryKey) error, del func(path, name string) error) telemetryFile {
|
||||
return telemetryFile{
|
||||
path: path,
|
||||
get: func(k telemetryKey) (any, bool, error) {
|
||||
m, err := filememo.ReadNow(tag, path, func(raw []byte) (map[string]any, error) {
|
||||
m := map[string]any{}
|
||||
if len(bytes.TrimSpace(edit.TrimBOM(raw))) == 0 {
|
||||
return m, nil
|
||||
}
|
||||
if err := parse(edit.TrimBOM(raw), &m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
})
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return nil, false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
v, has := m[k.name]
|
||||
return v, has, nil
|
||||
},
|
||||
set: func(k telemetryKey) error { return set(path, k) },
|
||||
del: func(k telemetryKey) error { return del(path, k.name) },
|
||||
}
|
||||
}
|
||||
|
||||
// tomlTopTelemetryFile is a TOML config's top-level keys.
|
||||
func tomlTopTelemetryFile(path string) telemetryFile {
|
||||
return topTelemetryFile(path, "telemetry toml",
|
||||
func(b []byte, m *map[string]any) error { return toml.Unmarshal(b, m) },
|
||||
func(path string, k telemetryKey) error {
|
||||
return edit.SetTOMLTop(path, edit.KV{Path: k.name, Value: k.value})
|
||||
},
|
||||
func(path, name string) error { return edit.DelTOMLTop(path, name) })
|
||||
}
|
||||
|
||||
// yamlTopTelemetryFile is a YAML config's top-level keys.
|
||||
func yamlTopTelemetryFile(path string) telemetryFile {
|
||||
return topTelemetryFile(path, "telemetry yaml",
|
||||
func(b []byte, m *map[string]any) error { return yaml.Unmarshal(b, m) },
|
||||
func(path string, k telemetryKey) error {
|
||||
return edit.SetYAMLTop(path, edit.KV{Path: k.name, Value: k.value})
|
||||
},
|
||||
func(path, name string) error { return edit.DelYAMLTop(path, name) })
|
||||
}
|
||||
|
||||
// codexTelemetry is Codex's: [analytics] enabled = false in config.toml.
|
||||
func codexTelemetry(at place, path string) *Telemetry {
|
||||
f := telemetryFile{
|
||||
@@ -324,6 +399,36 @@ func usageStatsTelemetry(at place, path, id string) *Telemetry {
|
||||
telemetryKey{name: "privacy.usageStatisticsEnabled", value: false, off: isFalse})
|
||||
}
|
||||
|
||||
// crushTelemetry is Crush's: options.disable_metrics in crush.json.
|
||||
func crushTelemetry(at place, path string) *Telemetry {
|
||||
return telemetrySwitch(at, jsonTelemetryFile(path), at.key("crush.telemetry"),
|
||||
telemetryKey{name: "options.disable_metrics", value: true, off: isTrue})
|
||||
}
|
||||
|
||||
// kimiTelemetry is Kimi Code's: telemetry in config.toml.
|
||||
func kimiTelemetry(at place, path string) *Telemetry {
|
||||
return telemetrySwitch(at, tomlTopTelemetryFile(path), at.key("kimi.telemetry"),
|
||||
telemetryKey{name: "telemetry", value: false, off: isFalse})
|
||||
}
|
||||
|
||||
// gooseTelemetry is Goose's: GOOSE_TELEMETRY_ENABLED in config.yaml.
|
||||
func gooseTelemetry(at place, path string) *Telemetry {
|
||||
return telemetrySwitch(at, yamlTopTelemetryFile(path), at.key("goose.telemetry"),
|
||||
telemetryKey{name: "GOOSE_TELEMETRY_ENABLED", value: false, off: isFalse})
|
||||
}
|
||||
|
||||
// piTelemetry is Pi's: its install and update reporting in settings.json.
|
||||
func piTelemetry(at place, path string) *Telemetry {
|
||||
return telemetrySwitch(at, jsonTelemetryFile(path), at.key("pi.telemetry"),
|
||||
telemetryKey{name: "enableInstallTelemetry", value: false, off: isFalse})
|
||||
}
|
||||
|
||||
// clineTelemetry is Cline CLI's: telemetryOptOut in its global settings.
|
||||
func clineTelemetry(at place, path string) *Telemetry {
|
||||
return telemetrySwitch(at, jsonTelemetryFile(path), at.key("cline.telemetry"),
|
||||
telemetryKey{name: "telemetryOptOut", value: true, off: isTrue})
|
||||
}
|
||||
|
||||
// ErrNoTelemetry: the agent has no telemetry switch magpie knows.
|
||||
var ErrNoTelemetry = errors.New("magpie knows no switch for this agent's telemetry")
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// daoche_wuzui on X: turn telemetry off for every agent where it can be.
|
||||
// Each of these has its own switch in its own config, from its source.
|
||||
var moreTelemetry = []struct {
|
||||
name, file, before, off string
|
||||
of func(home string) *Agent
|
||||
keys []string
|
||||
// theirs keeps telemetry on in the user's own words
|
||||
theirs string
|
||||
// own already turns it off
|
||||
own string
|
||||
}{
|
||||
{"crush", ".config/crush/crush.json", `{"options": {"context_paths": ["x"]}}`, `"disable_metrics": true`,
|
||||
func(h string) *Agent { return crush(h, filepath.Join(h, ".config")) }, []string{"options.disable_metrics"},
|
||||
`{"options": {"disable_metrics": false}}`, `{"options": {"disable_metrics": true}}`},
|
||||
{"kimi", ".kimi-code/config.toml", "default_model = \"a\"\n\n[providers.x]\nbase_url = \"u\"\n", "telemetry = false",
|
||||
kimi, []string{"telemetry"}, "telemetry = true\n", "telemetry = false\n"},
|
||||
{"goose", ".config/goose/config.yaml", "GOOSE_MODE: auto\n", "GOOSE_TELEMETRY_ENABLED: false",
|
||||
func(h string) *Agent { return goose(h, filepath.Join(h, ".config")) }, []string{"GOOSE_TELEMETRY_ENABLED"},
|
||||
"GOOSE_TELEMETRY_ENABLED: true\n", "GOOSE_TELEMETRY_ENABLED: false\n"},
|
||||
{"pi", ".pi/agent/settings.json", `{"theme": "dark"}`, `"enableInstallTelemetry": false`,
|
||||
pi, []string{"enableInstallTelemetry"}, `{"enableInstallTelemetry": true}`, `{"enableInstallTelemetry": false}`},
|
||||
{"cline", ".cline/data/settings/global-settings.json", `{"autoUpdateEnabled": true}`, `"telemetryOptOut": true`,
|
||||
cline, []string{"telemetryOptOut"}, `{"telemetryOptOut": false}`, `{"telemetryOptOut": true}`},
|
||||
}
|
||||
|
||||
// has: the file says off, however it spaces it
|
||||
func has(body, off string) bool {
|
||||
squash := strings.NewReplacer(" ", "", "\n", "")
|
||||
return strings.Contains(squash.Replace(body), squash.Replace(off))
|
||||
}
|
||||
|
||||
func TestMoreAgentsTelemetrySwitch(t *testing.T) {
|
||||
for _, c := range moreTelemetry {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
home, path := telemetryHome(t, c.file, c.before)
|
||||
a := c.of(home)
|
||||
if st := telemetryOf(t, a); st.Off || len(st.Own) != 0 || strings.Join(st.Keys, ",") != strings.Join(c.keys, ",") {
|
||||
t.Fatalf("before: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := readFile(path)
|
||||
if !has(got, c.off) {
|
||||
t.Fatalf("off:\n%s", got)
|
||||
}
|
||||
if st := telemetryOf(t, c.of(home)); !st.Off || len(st.Own) != 0 {
|
||||
t.Fatalf("after off: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err != nil || readFile(path) != got {
|
||||
t.Fatalf("off again: %v\n%s", err, readFile(path))
|
||||
}
|
||||
if err := c.of(home).SetTelemetry(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if after := readFile(path); has(after, c.off) || !strings.Contains(after, strings.Fields(c.before)[0]) {
|
||||
t.Fatalf("on:\n%s", after)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A value of the user's that keeps telemetry on is never written over; one
|
||||
// that already turns it off stays theirs when magpie's goes.
|
||||
func TestMoreAgentsTelemetryLeavesTheUsers(t *testing.T) {
|
||||
for _, c := range moreTelemetry {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
home, path := telemetryHome(t, c.file, c.theirs)
|
||||
if err := c.of(home).SetTelemetry(true); err == nil {
|
||||
t.Fatal("the user's on was written over")
|
||||
}
|
||||
if readFile(path) != c.theirs {
|
||||
t.Fatalf("written:\n%s", readFile(path))
|
||||
}
|
||||
home, path = telemetryHome(t, c.file, c.own)
|
||||
a := c.of(home)
|
||||
if st := telemetryOf(t, a); !st.Off || len(st.Own) != 1 {
|
||||
t.Fatalf("their own off: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := c.of(home).SetTelemetry(false); err == nil {
|
||||
t.Fatal("their own off was taken as magpie's")
|
||||
}
|
||||
if readFile(path) != c.own {
|
||||
t.Fatalf("changed:\n%s", readFile(path))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A config that doesn't parse is unknown: nothing is written.
|
||||
func TestMoreAgentsTelemetryUnreadable(t *testing.T) {
|
||||
bad := map[string]string{"crush": `{"options": `, "kimi": "[providers\ntelemetry = ", "goose": "a: [\n b: {", "pi": `{"x": [`, "cline": `{`}
|
||||
for _, c := range moreTelemetry {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
home, path := telemetryHome(t, c.file, bad[c.name])
|
||||
a := c.of(home)
|
||||
if _, err := a.Telemetry.Get(); err == nil {
|
||||
t.Fatal("an unreadable config read as a state")
|
||||
}
|
||||
if err := a.SetTelemetry(true); err == nil {
|
||||
t.Fatal("off written into an unreadable config")
|
||||
}
|
||||
if readFile(path) != bad[c.name] {
|
||||
t.Fatalf("written:\n%s", readFile(path))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Only Pi itself has the switch, not a fork of it.
|
||||
func TestPiForksHaveNoTelemetry(t *testing.T) {
|
||||
home, _ := telemetryHome(t, ".pi/agent/settings.json", `{}`)
|
||||
if pi(home).Telemetry == nil {
|
||||
t.Fatal("pi has none")
|
||||
}
|
||||
for _, a := range All() {
|
||||
if a.ID != "pi" && strings.HasPrefix(a.ID, "pi") && a.Telemetry != nil {
|
||||
t.Fatalf("%s has Pi's key", a.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Settings › Privacy reaches them too.
|
||||
func TestTelemetryAllReachesMoreAgents(t *testing.T) {
|
||||
home, _ := telemetryHome(t, ".config/crush/crush.json", `{}`)
|
||||
onPath(t, "crush", "kimi", "goose", "pi", "cline")
|
||||
for _, c := range moreTelemetry {
|
||||
if c.name != "crush" {
|
||||
writeAt(t, filepath.Join(home, c.file), c.before)
|
||||
}
|
||||
}
|
||||
if err := SetTelemetryAll(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, c := range moreTelemetry {
|
||||
if got := readFile(filepath.Join(home, c.file)); !has(got, c.off) {
|
||||
t.Errorf("%s not turned off:\n%s", c.name, got)
|
||||
}
|
||||
}
|
||||
if err := SetTelemetryAll(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if settings.Load().AgentTelemetryOff {
|
||||
t.Fatal("still on")
|
||||
}
|
||||
for _, c := range moreTelemetry {
|
||||
if got := readFile(filepath.Join(home, c.file)); has(got, c.off) {
|
||||
t.Errorf("%s not back on:\n%s", c.name, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ var Vars = []string{
|
||||
// Antigravity's gateway, which wins over its settings.json
|
||||
"AGY_LLM_GATEWAY_URL",
|
||||
// Cline: its folder, its data, its sessions and its MCP settings file
|
||||
"CLINE_DIR", "CLINE_DATA_DIR", "CLINE_SESSION_DATA_DIR", "CLINE_MCP_SETTINGS_PATH",
|
||||
"CLINE_DIR", "CLINE_DATA_DIR", "CLINE_SESSION_DATA_DIR", "CLINE_MCP_SETTINGS_PATH", "CLINE_GLOBAL_SETTINGS_PATH",
|
||||
// Pi and its forks (OmO, Senpi), whose profile and config are apart
|
||||
"PI_CODING_AGENT_DIR", "PI_CODING_AGENT_SESSION_DIR", "PI_CONFIG_DIR", "PI_PROFILE",
|
||||
"OMO_CODING_AGENT_DIR", "SENPI_CODING_AGENT_DIR",
|
||||
|
||||
Reference in New Issue
Block a user