Commit Graph
4 Commits
Author SHA1 Message Date
yetone d1f8d8aae7 agent: Cherry Studio adds magpie through its providers link (plugins#865)
Cherry Studio (CherryHQ) shows on the Agents page, and with
`magpie cherrystudio`, on macOS, Windows and Linux. Its row is the link
its main process takes, cherrystudio://providers/api-keys?v=1&data=, with
the gateway at <gw>/v1 as an OpenAI-compatible provider named magpie and
the named key agentKeyAt("cherrystudio"). Cherry Studio asks the user to
confirm it. magpie writes nothing into its store. "Added" is read
untouched from its 2.x database (Data/cherrystudio.sqlite, user_provider),
in the default userData and every one boot-config.json moved it to. A
database or boot-config that can't be read, or a 1.x userData (Local
Storage, no database), is unknown. The data is standard base64, because
Cherry Studio swaps raw + and / before parsing and back after. /api/open
lets that link through. aionui's database status is generalized into
dbStatus{has} so both apps share it. Icon: Cherry Studio's own logo, not
cherryin-color (a different product).

Run (mote, at this change on origin/main c66cdbea9; then rebased on
0f04dca6e and run again: vet of agent/gui/cli, Windows vet of agent/gui,
and the Cherry, AionUi, gateway-key and import-link tests, ok):
- gofmt -l clean; go vet ./internal/agent ./internal/gui ./internal/cli;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- go test -tags nogui -count=1 ./internal/agent ./internal/gui
  ./internal/cli: agent and cli ok; gui ok but TestCoreScriptBudget, red the
  same on a clean c66cdbea9 (#4526, 1533856 > 1533802)
- node --test import-row.test.cjs i18n-keys.test.cjs: import-row 20/20,
  chromium and webkit, en/zh/zh-TW/ja/de, and 420px wide; i18n-keys red
  only on "a plugin's words are its own", the same on clean c66cdbea9
  (#5332, #5426, #5482). No new strings.
- TestCherryStudioLinkParsedAs2_1_10 runs the link through 2.1.10's own
  parser (copied into testdata) and the renderer's zod checks, with
  gateways whose base64 spells + and /.
- Real try on mote (macOS 27.2, arm64): released Cherry Studio 2.1.10 in a
  sandbox HOME and --user-data-dir, with a sandbox magpie of this tree on
  127.0.0.1:3561 and a fake upstream. `magpie cherrystudio add` opened the
  dialog with base URL http://127.0.0.1:3561/v1 and the key
  magpie-cherrystudio. Add saved it, turned off as every Cherry provider
  is. `magpie cherrystudio` then said added, read while the app ran (WAL).
  Sync models listed fake/fake-1 from the gateway, and adding it turned
  the provider on. A chat got the fake upstream's reply, and magpie usage
  counted it as Cherry Studio's. A link sent while the first-run welcome
  page was up showed no dialog; after "set up later" it did.

Broken by hand, each red, then restored:
- URL-safe base64: TestCherryStudioLinkParsedAs2_1_10 (baseUrl decoded as
  /x~>/v1 and /xy\x7f?/v1)
- no closing quote/slash on the address match: TestCherryStudioHas
  (another port's provider counted)
- the /api/open prefix dropped: TestCherryStudioImportRow
- Cherry Studio dropped from /api/open's app case:
  TestImportLinkNothingOpens

Not tried: a real run on Windows or Linux (detection is unit tests
only); Cherry Studio 1.x, which reads as unknown; a real vendor upstream
(the try used a fake). Full suite not run at push.

Reported-by: mysterysqwq
2026-11-08 19:09:21 +08:00
yetone 3fd7e16983 agent: PenguinHarness is installed from the Agents page and served by magpie with nothing to set up
rankyurky asked on Discord #feedback for PenguinHarness (npm
@prismshadow/penguin-cli, command penguin). Every value comes from
Penguin's own source (0.2.17):

- Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) /
  $PENGUIN_PROJECT_ID (else default_project) /.project_config.toml.
  magpie writes [providers.magpie] (base_url, client_type, api_key),
  one [[models]] entry per magpie model (context_window, vision,
  max_tokens, [models.pricing] in usd_per_mtok) and default_model in
  Penguin's own inline spelling. Penguin's server reads the file again
  when its mtime changes, so no restart; a default naming no entry is
  refused by Penguin, so Check fails when one is missing.
- A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it.
  Disconnect restores the user's own default_model (or none), drops a
  magpie vision model, and removes the file when magpie made it.
  Penguin's own entries, providers and command_policy rules are kept.
- A sync that changes nothing writes nothing (bytes and mtime kept), so
  Penguin's watcher isn't woken.
- Install: curl -fsSL https://penguin.ooo/install.sh | sh, or
  irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or
  penguin update --yes for the tarball, except on Windows where
  update.ts refuses it.
- WSL: a penguin kind with no restart notice; the WSL test now expects
  an empty Notice for a kind with no restart.
- agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in
  NotPaths, or appdir dropped a value like "work" as a relative path.
- edit.SetTOMLArrayTables: replaces every [[name]] entry with key =
  value (with child tables) by blocks, or removes them; blank lines
  between replaced entries go with them, and an unchanged result isn't
  written.
- GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md
  and docs/subsystems/agent-wiring.md.

Run (worktree at ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
  ./internal/agentenv ./internal/appdir ./internal/usage: all ok but
  TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
  test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
  TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
  icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
  agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
  123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
  windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
  magpie serve and a fake upstream: penguin run -m "Say PONG" answered
  "PONG from fake" through magpie (usage agent "penguin",
  /v1/responses -> /v1/chat/completions); switching the model in magpie
  took effect with no Penguin restart; a no-op sync kept bytes and
  mtime; magpie penguin default restored the user's custom/my-own and
  left no magpie line; with no prior file it was created 0600 and
  removed on disconnect. The fixture is the file Penguin itself wrote.

- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
  'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
  TestSync', internal/edit, internal/agentenv and the internal/gui
  guards ok; gofmt clean.

Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).

Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
2026-10-27 01:38:45 +08:00
yetone 4b1994ad31 agent: AionUi, added through its add-provider link
seven7032 on Discord asked how to connect AionUi to magpie. AionUi
keeps its providers in its own SQLite database
(<userData>/aionui/aionui-backend.db, WAL mode), each key encrypted, so
there is no config file for magpie to write. The one supported way in
is its deeplink. AionUi 2.2.2's main process parses it
(parseDeepLinkUrl), and its renderer opens Settings -> Model with the
add form filled in, which the user confirms:

  aionui://add-provider?api_key=magpie-aionui&base_url=<gw>/v1&name=magpie&platform=custom

The AionUi row works the way Cindy's and Lody's do:
- Add magpie opens that link. /api/open allows the aionui://add-provider?
  prefix only. `magpie aionui add` opens it from the CLI.
- The key is agentKeyAt("aionui"), so it becomes the LAN key while
  sharing is on (added to TestPinnedGatewayKeyForEveryWriter).
- "custom" is AionUi's OpenAI-compatible platform. Its base URLs end in
  /v1, as its own OpenAI preset's does.
- Added reads providers.base_url for the gateway's address without
  touching the database (sessions.OpenUntouched, from the previous
  commit). A database that can't be read is unknown, never "not added".
  The last read is kept while the database and its log keep their size
  and time, for 15s at most, so the Agents poll doesn't copy a running
  AionUi's database every time.
- It is detected by userData/aionui (os.UserConfigDir()/AionUi on every
  OS).
- As with Cindy and Lody, the TUI leaves the row out (nothing to pick).

Tests:
- TestAionUiLink: the link's exact bytes.
- TestAionUiLinkParsedAs2_2_2: runs the link through
  testdata/aionui/deeplink-2.2.2.js, which is parseDeepLinkUrl copied
  byte for byte from 2.2.2's app.asar (out/main/index.js 50995-51021)
  plus the renderer's add-provider mapping and the form prefill. The
  result is action add-provider, route /settings/model, and the form gets
  platform custom, the /v1 base URL and the key.
- TestAionUiHas: a fixture database built from 2.2.2's real providers
  schema (taken from the database 2.2.2 made at first start). It covers
  none, another gateway, a row present only in the log of a running app,
  and a closed app, and checks that AionUi's folder is unchanged each
  time.
- TestAionUiUnreadableIsUnknown, TestAionUiStatusRereadsOnChange,
  TestAionUiDetect, TestAionUiImportRow (GUI: the row, unknown status,
  and /api/open refusing other aionui:// links).
- import-row.test.cjs gains the AionUi row (icon, known status in each
  language, the click opens the exact link, and it fits at 420px), in
  chromium and webkit across en, zh, zh-TW, ja and de. The same file
  now waits for the rows to settle before its alignment check: under
  load 105 one run caught Cindy's button mid-resize at 193.4px beside
  the picker's 194.4px. The old file passed 3/3 alone, so it is a
  timing assumption, not a layout bug.

Run at 18041fc5b (this change on origin/main 714ab8e8b):
- go test ./... -timeout 45m, through the suite lock: every package ok
  except internal/proc's TestNoCommandBypassesProc, red on
  internal/tui/keep.go:102 from 75e78a5a0 on main (#3567, which has a
  fix on skygunner's fork).
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet of agent, gui, cli and sessions clean.
- import-row.test.cjs: 20/20 in chromium and webkit.
- The whole GUI suite (make test-ui, 882 files) was still running at
  push, so it is not recorded here.
Rebased onto cbbf3163c, which changes GUI assets and api.go. At the
pushed head: go vet of the four packages is clean; go test
./internal/gui ok; the AionUi, Cindy and pinned-key agent tests are ok.
import-row.test.cjs at load ~210: one run had 19/20, and that run's
output wasn't kept, so I can't name the failing case. The next three
runs were 20/20.

Tried: magpie built at this commit with -tags nogui under a sandbox
HOME. `magpie aionui` printed "magpie aionui add  to add magpie" with
AionUi's folder and no database. With a copy of the real 2.2.2 database
holding one row at the gateway's /v1, it printed "magpie added".

Broken by hand:
- Dropping the aionui prefix from /api/open: TestAionUiImportRow red
  ("AionUi's link was not handed to the desktop").
- The reader put back to a plain mode=ro open: TestAionUiHas red
  ("AionUi's folder changed: aionui-backend.db ->
  aionui-backend.db,aionui-backend.db-shm,aionui-backend.db-wal").
Both were restored and are green.

Not tried: the add form, the saved row and gateway traffic. The
released AionUi 2.2.2 desktop app asks for an aionui.com sign-in before
any page, Settings included. That sign-in was not faked, and no
aionui.com account was available, so the link has never been opened in
a signed-in AionUi end to end. Also not tried: what AionUi saves for
platform custom when it is confirmed, AionUi's User-Agent (so none is
matched), and the aionui:// handler on Linux and Windows (Electron's
setAsDefaultProtocolClient, unverified there).
2026-10-25 16:49:29 +08:00
yetone e2b3eb7406 agent: an npm -g agent under mise's Node says its version and updates with that Node's npm, not "can't tell how it was installed" (flp on Discord)
On Windows with Node managed by mise, the Agents page read "无法判断安装方式"
for an agent installed with npm install -g. howInstalled decided from the
binary's path, and a mise shim leads nowhere near node_modules: on a Mac
or Linux it is a symlink to the mise binary; on Windows a copy of
mise-shim.exe (exe mode, the default), a .cmd plus a bash script running
`mise x --` (file), or a hard or symbolic link to mise.exe.

A shim is now recognised (a link to mise, or a file in mise's shims
folder: parent "mise", a .mode file, or MISE_DATA_DIR/shims) and mise is
asked which program it runs, `mise which <cmd>` from the home folder; how
it was installed is read from that program. On Windows mise names npm's
extensionless sh script, so the .cmd beside it is used. The update runs
that Node version's own npm with --prefix, then `mise reshim`: on Windows
npm install -g makes no shim for a new command (seen on the box), mise's
Unix npm wrapper reshims itself, so it is harmless there.

Siblings:
- asdf shims (scripts with "# asdf-plugin:" and `exec asdf exec`) are
  asked with `asdf which` the same way; asdf-nodejs's npm reshims itself
  and asdf has no Windows build.
- proc.UserBinDirs on Windows also looks in mise's shims folder
  (MISE_DATA_DIR, else XDG_DATA_HOME\mise, which mise follows on Windows,
  else %LOCALAPPDATA%\mise) for an agent PATH doesn't reach.
- Install side: npmIn accepts npm.exe beside node as well as npm.cmd.
- WSL agents get no update path (CLI skips them) and wsl.go's probe
  already lists mise/asdf shims: unchanged.
- MISE_DATA_DIR and ASDF_DIR join agentenv.Vars, so a test sandbox
  clears them (TestFolderVarsAreListed).

Fixtures are real bytes: internal/agent/testdata/mise-windows from mise
2026.10.7 on the Windows box (file-mode snow.cmd and snow, .mode files,
npm's snow.cmd/snow in the Node folder); the Mac layout and the asdf
shim's text from mise 2026.10.7 and asdf 0.20.2 release binaries in a
sandbox home.

Run:
- flp's own layout (where.exe claude: installs\node\24.20.0\claude,
  claude.cmd, shims\claude.exe; mise which claude names the extensionless
  script): TestMiseShimWindowsFiveAgents covers claude, pi, codex,
  opencode and codebuddy through shims\<cmd>.exe; run on the Windows box,
  red with the fix removed by hand, green restored.
- go test -tags nogui ./internal/agent ./internal/proc -run
  'Shim|HowInstalled|UpdateCLI|NpmIn|InstalledVersion'; with installedAt
  skipping the shim by hand TestMiseShimIsNodesNpm,
  TestUpdateCLIThroughMiseShim and TestAsdfShimIsNodesNpm go red, green
  again restored.
- Real mise on the Mac (sandbox home, mise 2026.10.7, node 22.23.3,
  snow-ai): detection through the real shim and `mise which`, and a real
  update 0.9.1 -> 0.9.2 through UpdateCLI.
- Real mise on Windows (the box, sandbox USERPROFILE/LOCALAPPDATA, mise
  2026.10.7, node 22.23.3, snow-ai): the Windows test binary's unit tests
  (TestMiseShimWindows, TestHowInstalledWindowsShim, TestNpmIn) pass;
  a temporary test through the real shim in exe, file and hardlink modes
  found npm.cmd --prefix <node>, version 0.9.2; after npm install -g
  snow-ai@0.9.1 a real UpdateCLI took it to 0.9.2 and reshimmed; snow.exe
  ran 0.9.2. Symlink mode was not tried (needs developer mode); it is
  the link-to-mise case the Mac covers. flp's own machine was not tried.
- go test -tags nogui -timeout 40m ./...; gofmt -l; GOOS=linux and
  GOOS=windows go vet -tags nogui ./...
2026-10-11 12:45:31 +08:00