YujunT46308 on X (magpie 0.1.3519, MiniMax Code 3.1.13 CN): with the app's data folder moved to another parent (localRuntimeDataParentDir), magpie went on writing ~/.minimax/config.yaml, which the app no longer reads. How MiniMax Code 3.1.13 finds it, read from its own app.asar (dist/main/modules/local-runtime/data-dir.js, resolveLocalRuntimeDataDirSelection; @mavis/config's config.js for the runtime): MINIMAX_DATA_DIR, then MAVIS_DATA_DIR, then the desktop setting, then ~/.minimax. Settings' data-folder move keeps the parent as config.localRuntimeDataParentDir in its electron-store file (storage.ipc.js: minimax-agent-cn-config.json for the China build, minimax-agent-config.json for the global one) in Electron userData, named by app-identity.js: "MiniMax" (CN) / "MiniMax Agent". The data folder is <parent>/.minimax. What changed: - appdir.MiniMaxDirIn resolves the folder in that order, reading the store under ~/Library/Application Support on a Mac and %APPDATA% on Windows. A missing, unreadable or unparseable store, or a parent that isn't an absolute string, is ~/.minimax, as electron-store itself reads a file it can't parse as its defaults. - internal/agent's MiniMaxDir (detection, connect, restore, Sync, Check) and internal/sessions' MiniMaxDir (Usage's calls) both use it; the Library's skills follow a.Dir. WSL's mcode still uses the distro's ~/.minimax (no desktop app there). - MAVIS_DATA_DIR joins agentenv's variables, so tests sandbox it. - agent-wiring.md and reference.md say where the folder comes from. Run: - On mote, the real MiniMax Code 3.1.13 CN arm64 dmg: launched with no setting, userData was ~/Library/Application Support/MiniMax holding minimax-agent-cn-config.json; with config.localRuntimeDataParentDir set to a folder, the next launch created <parent>/.minimax/config.yaml. appdir.MiniMaxDir() against that real store printed <parent>/.minimax. (The test data I made on mote was removed after.) - mote-run go test -count=1 ./internal/appdir ./internal/agentenv ./internal/sessions ./internal/library: ok. ./internal/agent -run 'MiniMax|Minimax|WSL|Env|Spelled|Handwired': ok. - win-run go test -run MiniMax ./internal/appdir ./internal/agent ./internal/sessions: ok, TestMiniMaxDirIn and TestMiniMaxCodeMovedByDesktop ran (not skipped) with %APPDATA% paths. - gofmt -l clean; go vet of the touched packages for darwin, windows and linux (nogui, CGO off) ok. Broken by hand: with the desktop store read turned off, TestMiniMaxDirIn and TestMiniMaxCodeMovedByDesktop go red (the folder reads as ~/.minimax). Not tried: the Windows desktop app itself (userData %APPDATA%\MiniMax is Electron's appData plus the app name, the same rule seen on the Mac); the global build's store with a real install; a store mid-rollback (the app's guard writes the restored parent back to the same key on its next launch). A user who also runs the mcode CLI without MINIMAX_DATA_DIR has it on ~/.minimax, which magpie now leaves alone while the desktop folder is moved.
93 lines
3.1 KiB
Go
93 lines
3.1 KiB
Go
package appdir
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
// MiniMaxDir is the data folder MiniMax Code keeps config.yaml, its
|
|
// sessions and its skills in. Every place magpie reads or writes MiniMax
|
|
// Code's files goes through here.
|
|
func MiniMaxDir() string {
|
|
home, _ := os.UserHomeDir()
|
|
return MiniMaxDirIn(home)
|
|
}
|
|
|
|
// MiniMaxDirIn is MiniMaxDir with home as the user's home folder. It is
|
|
// found as MiniMax Code 3.1.13 finds it (the desktop app's
|
|
// local-runtime/data-dir.js resolveLocalRuntimeDataDirSelection, and
|
|
// @mavis/config's config.js for the mcode runtime): $MINIMAX_DATA_DIR,
|
|
// else $MAVIS_DATA_DIR, else the desktop app's own setting — Settings'
|
|
// data folder, which moves the folder to <parent>/.minimax and keeps the
|
|
// parent as config.localRuntimeDataParentDir in its electron-store file —
|
|
// else ~/.minimax. YujunT46308 on X (MiniMax Code 3.1.13 CN): with the
|
|
// folder moved, magpie wrote ~/.minimax/config.yaml, which the app no
|
|
// longer read. A desktop file that is missing, can't be read or doesn't
|
|
// parse is the default folder, as electron-store reads one it can't parse
|
|
// as its defaults.
|
|
func MiniMaxDirIn(home string) string {
|
|
for _, v := range []string{"MINIMAX_DATA_DIR", "MAVIS_DATA_DIR"} {
|
|
if d := strings.TrimSpace(Getenv(v)); d != "" {
|
|
return d
|
|
}
|
|
}
|
|
if p := miniMaxDesktopParent(home, runtime.GOOS); p != "" {
|
|
return filepath.Join(p, ".minimax")
|
|
}
|
|
return filepath.Join(home, ".minimax")
|
|
}
|
|
|
|
// miniMaxDesktopStores are MiniMax Code Desktop's electron-store files,
|
|
// under its Electron userData, named for its app name (app-identity.js:
|
|
// "MiniMax" for the China build, com.minimax.agent.cn, "MiniMax Agent"
|
|
// for the global one) and its store (storage.ipc.js STORE_NAME). The China
|
|
// build's is first: on a computer with both, the first that sets a parent
|
|
// is the one followed.
|
|
var miniMaxDesktopStores = [][2]string{
|
|
{"MiniMax", "minimax-agent-cn-config.json"},
|
|
{"MiniMax Agent", "minimax-agent-config.json"},
|
|
}
|
|
|
|
// miniMaxDesktopParent is the parent folder MiniMax Code Desktop moved its
|
|
// data folder to, or "" when it moved none. Electron's userData is in
|
|
// ~/Library/Application Support on a Mac and %APPDATA% on Windows; the app
|
|
// ships for no other system.
|
|
func miniMaxDesktopParent(home, goos string) string {
|
|
var base string
|
|
switch goos {
|
|
case "darwin":
|
|
base = filepath.Join(home, "Library", "Application Support")
|
|
case "windows":
|
|
if base = Getenv("APPDATA"); base == "" {
|
|
base = filepath.Join(home, "AppData", "Roaming")
|
|
}
|
|
default:
|
|
return ""
|
|
}
|
|
for _, s := range miniMaxDesktopStores {
|
|
b, err := os.ReadFile(filepath.Join(base, s[0], s[1]))
|
|
if err != nil {
|
|
continue
|
|
}
|
|
var st struct {
|
|
Config struct {
|
|
Parent any `json:"localRuntimeDataParentDir"`
|
|
} `json:"config"`
|
|
}
|
|
if json.Unmarshal(b, &st) != nil {
|
|
continue
|
|
}
|
|
// the app takes only a string, trimmed, made absolute
|
|
// (setConfiguredLocalRuntimeDataParentDir); a relative one would
|
|
// be its working folder's, which isn't magpie's
|
|
p, _ := st.Config.Parent.(string)
|
|
if p = strings.TrimSpace(p); p != "" && filepath.IsAbs(p) {
|
|
return filepath.Clean(p)
|
|
}
|
|
}
|
|
return ""
|
|
}
|