The owner (10-17): "所有的内置插件默认都应该是开启的", "尤其对新用户来说……
不然新用户都不知道有哪些功能". Since 3ccbe6bc1 (10-13) a new install was
written plugins.yml with the Essentials preset, which left Sessions, the
Library, routing groups, warm-ups and Observability off for every new user
(origin/main's binary, fresh sandbox HOME: those five "off").
- pluginrt.Settle() writes All when there is no plugins.yml, new install or
not; settings.RanBefore, which only told the two apart, is gone.
- plugins.yml gets `settled: 1`. A file below it is brought up once on
start: an Essentials preset becomes All, the user's own rows kept (a
plugin they turned off stays off). Every write (Set, SetConfig,
SetPreset) sets it, so `magpie plugin preset essentials` picked
afterwards stays the user's. An unreadable or unparsable file is left
alone, as before.
- Docs (plugin-runtime.md) and comments that said a new install starts
with Essentials.
Run (origin/main 72ed518bc + this):
- gofmt -l internal: clean; go vet pluginrt, cli, gui, settings: clean.
- go test ./internal/pluginrt/ ./internal/settings/: ok. New
TestSettleBringsUpAnEssentialsInstall; TestSettleAndSet and
TestBuiltinSwitch now check a new install has all 14 on.
- Broken by hand (Settle writing Essentials, the bring-up skipped):
TestSettleAndSet, TestSettleBringsUpAnEssentialsInstall and
TestBuiltinSwitch go red; restored, green.
- Real binary, sandbox HOME: a new install lists all 14 on and writes
`preset: all, settled: 1`; a plugins.yml of `preset: essentials` with
otel off comes up `preset: all`, groups/library/sessions/warmups on,
otel off.
- go test -count=1 -timeout 45m ./...: every package ok but internal/cli
(TestPluginLoginTakesTheLapseOff, passes 5/5 alone here and on
72ed518bc; filed #2748) and internal/gui (TestMainWindowCorners, #1936).
- GUI: builtins.test.cjs 4/4 (chromium + webkit; a first try under load
~445 had chromium's page.goto time out at 5s, #2542),
routing-groups-off.test.cjs pass. Only comments changed in those two.
P3 of docs/subsystems/plugin-runtime.md opens the gateway to plugins. The
observer point is first: it only reads, so it carries the least risk.
With plugins/otel off, the gateway exports nothing and does no observing
work. It keeps no reply whole and adds no request context.
- usage.Observer:
- Methods: Serve, Bodies, Begin(Request) Watch and Ledger(Record). Watch
has Attempt and End.
- Observe(o) registers an observer until its remove is called.
- ServeObservers is counted, and only Server.ListenAndServe calls it.
- ObservedBodies takes the most any observer wants.
- Record.SkipOTel becomes Watched, set by appendUsage for a request an
observer watched.
- The gateway's otel.go becomes observe.go:
- observeRequest asks each observer through Begin.
- attempt and end call each Watch. Bodies are added only when an
observer asks for them, and the whole reply only for WholeBodies.
- internal/otlp: the exporter (otel*.go) moves out of internal/usage, and
the gateway's per-request span state moves into request.go. otlp.New()
is an Exporter, a usage.Observer. What it sends is unchanged.
- plugins/otel:
- Apply registers otlp.New() and disposes of it when turned off.
- InUse is 1 while settings.OTelExport says to send. A user who exports
only through MAGPIE_OTEL_* keeps the plugin on under Essentials.
- pluginrt.KeepFresh: the process serving the gateway refreshes every 2s
when plugins.yml or settings.json changes. A switch made in the window or
the CLI reaches a running gateway, or a headless serve, without a restart.
- docs: plugin-runtime.md gets a P3 section, a gateway runtime path and an
updated failure section; reference.md says the export is the otel plugin.
Run at this tree on origin/main 82f48f093 (rebased onto 52ee84761 after,
which touches only the Linux tray icon):
- gofmt -l is clean. go vet passes on darwin, GOOS=linux -tags nogui and
GOOS=windows.
- go test -count=1 -timeout 25m ./...: ok, 55 packages, none failed.
- New tests:
- usage: TestObserverServesWithTheGateway and TestObserverLedgerAndBodies.
- gateway: TestObserverPoint, covering unwatched, no bodies, captured,
whole and whole streamed.
- plugins/otel: TestOnExportsOffSendsNothing (on, off, on, with a real
collector) and TestInUseByEnvironment.
- pluginrt: TestKeepFreshFollowsPluginsYml.
- The OTel tests moved with their code to internal/otlp.
Broken by hand, each red, then restored:
- Apply without Observe, and without its dispose.
- KeepFresh refreshing only once.
- InUse reading settings.json only.
- Ledger keeping Watched rows: 3 gateway OTel tests red.
- ObservedBodies taking the last observer's answer.
- Observe not serving a late registration.
- appendUsage not setting Watched.
- Whole bodies never kept.
- Bodies always on with no observer asking.
P1 of docs/subsystems/plugin-runtime.md. P0 (3ccbe6bc1) gave built-in
plugins a manifest, plugins.yml and a switch; their pages were still
app.js's own code. Now the window has a kernel a plugin draws its page
through, and the Gateway page moved into plugins/gateway to prove it.
What changed:
- internal/gui/assets/kernel.js (new): window.magpie. A plugin
registers with magpie.plugin(id, setup); ctx.slots.add("page", part)
puts its markup where index.html's <template data-slot="page"> is.
The shell calls its hooks through magpie.call, behind an error
boundary: a hook that throws, or whose promise fails, is logged and
its page shows "This page stopped working", what broke and Try
again, while every other page goes on. ctx.ui is the kit (button,
switch, the app menu, a settings row) and ui.form draws a plugin's
settings from their schema. ctx.config / onConfig carry the settings,
from boot.js before the first paint and from Plugins › Built-in after.
- internal/pluginrt/schema.go (new): a plugin's settings are a Go
struct (Manifest.Settings); SchemaOf makes the JSON Schema the form
is drawn from, and Validate is what SetConfig (config.go) takes into
plugins.yml. Compose drops a hand-edited value the schema refuses.
- plugins/gateway: the Gateway page as a plugin, Essential and in use
while a gateway key is there. One setting, callsPage (10/20/50/100,
20 by default). Its client is plugins/gateway/{keys.js,client.js},
moved out of app.js (and caller-keys.js) unchanged in behaviour.
- internal/gui: builtins.go takes POST {id, config} beside {id, on}
and lists each plugin's schema and config; boot.js carries
pluginConfig; /plugins/<id>/… files are served. Plugins › Built-in
draws a plugin's settings rows under its switch.
- Docs: plugin-runtime.md has "The window's kernel (P1)"; gui-shell.md,
subsystems/README.md and tests/README.md updated.
What was run:
- go test ./... (sandbox HOME, pinned caches): all packages ok;
gofmt -l clean; go vet on darwin, GOOS=linux -tags nogui and
GOOS=windows.
- New tests: TestSchemaOf, TestValidate, TestSetConfig,
TestBuiltinConfig, TestBuiltinClientsLoaded;
plugin-kernel.test.cjs (a page that throws breaks only itself and
Try again draws it, at 1100 and 420 in en, zh, zh-TW, ja, de;
callsPage from boot.js and from Plugins › Built-in), both engines.
- Broken by hand, each turned its test red: the boundary's catch
removed; Try again not putting the page's markup back; the Gateway
page's onConfig not re-reading callsPage; boot.js's pluginConfig
ignored; SetConfig skipping Validate.
- The full GUI suite in Chromium and WebKit (node --test *.test.cjs).
One red was this change's own. providers-fetching-retry lifts
providersWhileFetching out of app.js, which now asks providersPage,
and the lift lacked it. The test now lifts that too, and gains "a poll
under the Gateway page, a plugin's page that reads with Providers,
reads". That case goes red with providersPage dropped from the poll's
guard.
- The reds that were on origin/main a75de4c21 too are fixed in their
own commits after this one. Two of them came from P0's Built-in tab:
nav-sub-unroll and plugin-check-github-limit.
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.