Lxxyx on X (https://x.com/Lxxyx_/status/2109506752656150974): magpie has too much in it. This is P0 of making magpie's parts plugins, as DeepSeek Harness does: a runtime, plugins.yml, and the first five built-in plugins the user can switch off. - internal/pluginrt: a registry (Register from init), a manifest (API caret range, Requires/Provides, Essential, InUse, Apply, Parts, Defaults) and Reconcile: the plugins no longer wanted, with whatever needs a service they provided, are disposed newest first; the wanted ones are applied once their services are there. A plugin that fails or panics is failed and the rest run. TestPluginsImportOnlyCore keeps the boundary: nothing outside plugins/ imports one, none imports another. - plugins.yml (appdir.Config()): default → preset (essentials | all) → the user's rows → in use. A new install is written Essentials, a magpie that ran here before (settings.RanBefore) All, so existing users keep everything. Writes are locked, whole and keep a .bak; a file that doesn't parse is an error, never empty, and is never written over. - plugins/groups, library, otel, sessions, warmups. In P0 a plugin off is the window's alone: its page, sections and rows (data-feature) leave the window; the gateway, TUI and CLI serve the same, nothing is deleted. One in use stays on. - The window: Plugins › Built-in, the first tab, a switch per plugin; GET/POST /api/plugins/builtin; boot.js says which are off before the first paint. CLI: magpie plugin builtin [on|off <id>], plugin preset, plugin dump [--json]. - docs/subsystems/plugin-runtime.md, gui-shell.md. Run: go test ./internal/pluginrt/ ./internal/settings/ ./internal/gui/; gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./.... GUI: builtins.test.cjs in Chromium and WebKit, 5 languages, 1100/800/420; list-sort, mobile-web, routing-keys-fold, routing-sessions pass. By hand under a sandbox HOME: a new install gets essentials, an existing one all, a broken plugins.yml is refused and kept, dump works. Full suite results after the rebase are in the push notes.
31 lines
688 B
Go
31 lines
688 B
Go
package settings
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// An empty folder is a new install; any one of ranBefore's files says a
|
|
// magpie ran here before.
|
|
func TestRanBefore(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
if RanBefore() {
|
|
t.Fatal("an empty folder ran before")
|
|
}
|
|
for _, name := range ranBefore {
|
|
t.Run(name, func(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
if err := os.MkdirAll(Dir(), 0o700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(Dir(), name), []byte("{}"), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !RanBefore() {
|
|
t.Fatalf("%s there, and not ran before", name)
|
|
}
|
|
})
|
|
}
|
|
}
|