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.
30 lines
959 B
Go
30 lines
959 B
Go
package settings
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// ranBefore are files a magpie (or the dial before it, copied over by
|
|
// Migrate) leaves in Dir once it has run: its settings, a provider, an
|
|
// account, the version it last ran as, the library, a profile, a plugin,
|
|
// an agent's stashed config, a request served, the id stats send.
|
|
var ranBefore = []string{
|
|
"settings.json", "providers.json", "logins.json", "last-version",
|
|
"library.json", "profiles.json", "plugins.json", "stash.json",
|
|
"usage.jsonl", "migrations.json", "install-id",
|
|
}
|
|
|
|
// RanBefore is whether a magpie has run here before: one of ranBefore's
|
|
// files is in Dir. It is asked at start, after Migrate and before anything
|
|
// writes into Dir. A file that can't be looked at counts as there:
|
|
// unknown is never new.
|
|
func RanBefore() bool {
|
|
for _, name := range ranBefore {
|
|
if _, err := os.Lstat(filepath.Join(Dir(), name)); !os.IsNotExist(err) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|