Commit Graph
11 Commits
Author SHA1 Message Date
yetone 9ae7912210 agent: plain agy starts Antigravity CLI on magpie in a new terminal
agy takes magpie's gateway, key (GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL)
and --model only from how it is started, so a user on magpie had to copy
the launch command at every start (bestony on Discord). Now:

- magpie agy run [args…] execs the real agy with the env and --model when
  agy's settings.json is on magpie's model (a --model/-model the user
  gives wins), and runs agy untouched otherwise. On Windows agy is a child
  through proc and its exit code is passed through. It refuses when "agy"
  on PATH resolves to magpie itself. magpie agy env prints what run adds
  (PowerShell's function reads it, since the desktop exe has no console).
- update.ShellFunction puts a function named agy in a marked block
  (# >>> magpie agy >>> … # <<< magpie agy <<<) of each shell profile
  cliShells finds: .zshrc (ZDOTDIR), the bash profile a terminal reads
  (.bash_profile, or .bash_login/.profile on macOS when that is missing),
  config.fish once its folder exists, and the PowerShell 7 / Windows
  PowerShell profiles where the execution policy runs them. Only the block
  is written, in place, temp-and-rename, CRLF and BOM kept; a profile that
  can't be read is not written; only files inside the home are. The
  function falls back to `command agy` when the magpie it names is gone.
- Set to a magpie model writes the block, stepping out takes it out (the
  file comes back byte for byte), and Sync at start writes it for users
  already wired.
- Notice, Launch tooltip and the connect panel say plain agy works in a
  new terminal, with the command for a terminal open now. Strings in
  i18n.js for zh, zh-TW, ja, de. docs/reference.md and
  docs/subsystems/agent-wiring.md updated.

Run at this head (base a3d4f8c5c, origin/main just fetched):
- go test -tags nogui -count=1 -timeout 45m ./internal/agent/...
  ./internal/cli/... ./internal/update/... ./internal/gui/...
  ./internal/proc/... : all ok.
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... : clean. gofmt -l on the changed files: none.
- GUI (node --test, chromium + webkit): agy-launch, cursor-local-launch,
  agent-connect, agent-connect-no-models, agent-connect-all-hidden,
  agent-connected-unfolded, connect-address-kept, connect-snippet-shell,
  agent-notice-lang, agent-leave-magpie, agent-disconnect, copy-command,
  i18n-keys, gui-de, gui-ja, gui-zh-tw: 0 fail. Not the whole GUI suite.
- Real try, sandbox HOME under the scratchpad, nogui build, fake agy on
  PATH printing its args and the two env vars, env -i:
  magpie provider add deepseek + magpie agy deepseek/deepseek-chat wrote
  the block after the user's two .zshrc lines; `zsh -i -c 'agy -p hi'` got
  --model magpie/deepseek/deepseek-chat, GEMINI_API_KEY=magpie-agy and
  GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:38712; `agy --model x` kept x;
  wiring again left .zshrc's mtime alone and added .bash_profile once it
  existed, and `bash -l -i -c 'agy -p hi'` got the same; `magpie agy env x`
  refused; magpie agy default took both blocks out, .zshrc equal to the
  original, and plain agy ran with no env and no --model.

Broken by hand, each red, then restored:
- no fnInHome check: TestShellFunction, TestShellProfiles red.
- block appended instead of replaced in place: TestShellFunction red.
- unreadable profile treated as empty: TestShellFunction red.
- blank line before the block left on removal: TestShellFunction,
  TestWithFnBlock red.
- --model always added: TestAgyRun red.
- Sync without agyShell: TestAgyShell red. Stepping out without
  agyShell(false): TestAgyShell red.
- app.js typed row off, typed tooltip off: agy-launch 4 of 10 red each.

Not tried: PowerShell on Windows for real (vet only); WSL; a user's own
`alias agy` (an alias beats the function); a terminal already open needs
the copied command; macOS bash started non-login reads .bashrc, which
isn't written; a Documents folder redirected outside the profile isn't
written.
2026-10-27 07:30:16 +08:00
yetone ea1f9492bc cli: magpie tools lists, and magpie tool calls, the tools magpie's MCP servers give agents (iwinux)
iwinux on Discord (#feedback) wanted magpie's image generation, image
recognition and web search without going through an agent's MCP, and had
written a Python script for generate_image. magpie now has it:

  magpie tools [<name>]
  magpie tool <name> [--<param> <value>…] [<words>…] [-o <file|folder>] [--json]

Both ask the running gateway's own MCP servers (gateway.OwnMCPServers:
image, vision, web-search, plugin tools) over HTTP, with the local token
and the magpie-tool/1 User-Agent, so the tools, schemas, models from
Settings and usage counting are the ones an agent gets. Nothing is
started besides (#3318: the cases sit before startUp, beside mcp).

- Parameters are read against the tool's inputSchema: types (integer,
  number, boolean, array given once per item, object as JSON), enum, -
  and _ alike, --p v or --p=v. The words left over are the tool's one
  required text, else its prompt. An unknown flag or parameter, a missing
  required one, a bad value, a value given twice or both words and the
  same --param are refused with "nothing was called"; no request is sent.
- A file path a parameter takes (its description says file and path)
  is made absolute, since the gateway doesn't know the current folder.
- --help prints toolUsage (static): help is handled before anything runs.
- A still-being-made answer is waited on with generation_result (1s
  between asks, 30 min at most). The gateway's image server now says so
  in _meta too: usemagpie.ai/pending is the id, usemagpie.ai/files the
  files made ({url, inline}); an older gateway is read from its text.
- Images and videos are saved through imagemcp.Target (now exported):
  -o file or folder, else the current folder named from the prompt,
  numbered when more than one, never over a file that is there; a file
  not inline is downloaded by its path from the gateway asked (the token
  goes nowhere else). --json prints the raw answer and saves nothing.
- No magpie at the address: "magpie isn't running at <url>: open the app
  or run magpie serve". MAGPIE_GATEWAY=<url> points at another.

Docs: usage lines in magpie help, docs/reference.md (Use), the gateway
routing subsystem page (_meta and the CLI), README en/zh, site docs start
page en/zh/ja.

Tests (internal/cli/tool_cli_test.go, never the network; every test sets
MAGPIE_GATEWAY to its own httptest server):
- TestToolsListsTheServersTools, TestToolReadsParameters,
  TestToolRefusesWhatItDoesntKnowAndCallsNothing (no tools/call, no file),
  TestToolHelpCallsNothing (no request at all), TestToolSavesTheImage,
  TestToolWaitsOnWhatIsStillMade (pending _meta, then the old text form,
  download with the key from the gateway asked, not the URL's host),
  TestToolErrorIsSaid, TestToolSaysMagpieIsntRunning,
  TestToolDrawsThroughTheGateway (the real gateway.New().Handler() with a
  fake vendor: lists, draws, saves the vendor's PNG).
- TestImageMCPDrawsAndServesTheImage, ...SlowDrawingIsWaitedOn and
  ...MakesVideos now check the _meta. Red on the old behaviour: with
  withMeta setting nothing (what main answers) all three fail ("_meta
  map[], want pending img_…").
- Broken by hand: dropping the unknown-parameter check makes
  TestToolRefuses… red (the --model call was made); saving an inline
  image by its URL instead makes TestToolSavesTheImage red. Both restored.
- TestHelpOnEveryCommandDoesNothing covers tool and tools.

Run with this change on origin/main 630fd1d69, then rebased on cebd0d4c3
(internal/pii, internal/gui, docs and site/ changed between, nothing
this change touches): there
gofmt, go vet of cli/gateway/imagemcp, internal/cli, internal/imagemcp and
the gateway's TestImageMCP/TestVisionMCP/TestSearchMCP again, ok.
At 630fd1d69:
- gofmt -l: nothing. go vet ./...; GOOS=linux go vet -tags nogui
  ./internal/...; GOOS=windows go vet ./internal/...: clean.
- go test ./... -timeout 45m: internal/gateway, imagemcp and the rest ok;
  ten packages failed with "no space left on device" (the machine's disk
  was full from other runs). Those rerun when space was back: agent, cli,
  davsync, gui, library, sessions, settings, tui, usage, usageapi,
  wslrun, plugins/... ok. internal/provider crashes in
  TestUnreadLoginsWriteErrorsKeepCredentials with "close of synctest
  channel from outside bubble" (filememo.Forget), twice: that is #3632,
  open, on main since 091153bf7, nothing this change touches.
- Real try: a nogui build of this head as magpie serve on 127.0.0.1:3482
  under a scratch HOME, a custom provider pointed at a local fake images
  API. magpie tools listed image, vision and web-search with their
  parameters; generate_image "…" --size 1024x1024 -o hero.png saved a PNG
  and the vendor got prompt and size; --n 2 --quality high saved two
  numbered files; --model was refused before calling; analyze_image and
  web_search said what to set up (no vision model or search API there);
  --help asked nothing. Usage counted the calls as magpie's own.

Not tried: a real image vendor, a real vision or search model, a video,
a plugin's tool through magpie tool, Windows and Linux runs (vet only).
2026-10-26 18:42:35 +08:00
JoeyWu-tech b18a6a080b gateway, cli: magpie goroutines writes the running magpie's goroutine stacks to a file (#3362)
#3362's second ask: an app stuck at something could only be read by
killing it, which ends what was stuck. magpie heap and magpie cpu
already ask the running gateway for a profile over loopback; magpie
goroutines asks it for every goroutine's stack. That works on Windows
too, where there is no SIGUSR1.

GET /v1/magpie/goroutines (goroutines.go) answers the callers
/v1/magpie/heap answers (profileRefused: a program on this computer
over loopback, no browser mark, a loopback Host; a gateway key lets
nothing else in) with runtime/pprof's goroutine profile at debug=2,
the form a crash prints: each goroutine's state and wait ("[select,
4320 minutes]"), its frames with source lines, and who started it. It
is text/plain and no-store, and X-Magpie-Goroutine-Stats names the
process (pid, program, version, window, uptime, goroutine count).
Arguments are words in hex, never what they point at, so the dump
holds no keys, prompts or messages; it does name magpie's source files
and the program's path, which the usage says.

magpie goroutines [<file>] writes it to <file>, else
magpie-goroutines-<date>-<time>.txt in this folder, 0600 and never over
a file there, then prints the file and the process. --help, -h and help
print the usage and ask nothing; a flag it doesn't take, "-", a blank
name or a second file are refused before the gateway is asked. A
magpie older than this one answers 404 and is told to update; with
none answering, it says so.

The refused callers TestHeapProfileOnlyToThisComputer listed move into
profileCallersRefused, which the CPU test and the new one share.

Run on b437e4ad, go1.26.8. internal/gateway and internal/cli are the
same here and at the branch's head (tree 613df3a9), where the checks of
them ran:
- gofmt -l and go vet as in the commit before: clean.
- go test ./internal/gateway -run 'Goroutine|Heap|CPU|Profile': ok;
  ./internal/cli -run 'Goroutines|Heap|CPU|Help': ok.
- Broken by hand: goroutinesRefused letting every caller in makes
  TestGoroutineDumpOnlyToThisComputer red ("Origin null with a key":
  200); debug=1 for 2 makes it red (the parked goroutine isn't in the
  dump); without the route it is red (404), and so is
  TestGoroutinesWritesTheRunningGatewaysDump ("older than this one").
  Restored, green.
- Full suite at this commit, go test -tags nogui -count=1 -timeout 45m
  ./... (tree e5cf04af, 498s): 62 packages ok. 14 reds in 7 packages,
  none in a file this commit touches, each red on b437e4ad without it:
    internal/agent TestInstalledVersion, TestOmpDetectedWithPiDir,
    TestCursorFolderFromTheEditorIsNotTheCLI and TestZedAppPath:
    proc.Look keeps "not found" for a tool written in the tick of its
    folder's last change (#3141).
    internal/agent TestCodexDriftReached: Drift answers from the read of
    Codex's log taken before the test's last insert (#3398).
    internal/agent TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: their fixture build under
    /tmp meets a /tmp/.git that isn't a repository of this user's
    ("error obtaining VCS status: exit status 128").
    internal/claudebridge TestCallbackGoesPastTheAgentsProxy,
    internal/gateway TestClaudeToolCallbackOnANonLoopbackAddress,
    internal/gui TestGatewayHeldByAContainer and
    TestGatewayFixQuitsOnlyAMagpie: the processes this run started had
    their outgoing connections sent through a proxy (graftcp).
    internal/edit TestWriteAtomicReadOnlyHardLink and internal/testenv
    TestProgram: umask 077 here; the fixtures' own modes go through it
    (0444 is written as 0400).
    internal/netproxy TestBunProxyLoginWithReservedCharacters: Bun
    1.3.11 on PATH names port 80 in the request line (#3397).
Not tried: a real stuck app; magpie goroutines against the app on macOS
or Windows (the tests serve gateway.New().Handler() on loopback).
2026-10-24 21:33:06 +08:00
yetone 4a3e07f1cf model: magpie model spec sets a model's window, output, vision and levels at once
Dani Ariyanto on Discord (#feedback, 10-24): a custom provider's models
(kenari/*:free) had no window, reply limit, vision or reasoning known,
and there was no one place to say them.

  magpie model spec <provider/model>                 what it has, and whose each value is
  magpie model spec <provider/model> [--context <n>] [--output <n>] [--vision on|off|auto] [--reasoning <levels>|off|auto]
  magpie model spec '<provider>/*' --context <n> --output <n>
  magpie model spec <provider/model> --reset
  magpie model specs

It writes the stores magpie model context/output/images/efforts write
(providers.json contexts; settings.json modelOutputs, modelImages,
modelEfforts, modelReasonless), so every reader that went by those goes
by a spec: entryFor/EntryOf/Served, /v1/models, max_tokens, the GUI's
/api/providers badges and chips, and the agents' model lists. Every
part is checked before anything is written; a refused command writes
nothing. Agents are told once.

Readers that bypassed the stores and now honour them:
- provider.Efforts returns the kept levels, so the gateway fits a
  request to them (fitEffort): xhigh asked of a model kept to low-high
  goes as high. This reverses #92 (47e12df41), which narrowed only the
  lists handed out; docs/subsystems/gateway-routing.md says so.
- entryFor: levels given a model with none known make it Reasoning.
- gateway AutoVision picks by the user's ModelImages (seesAt).
- GUI gateway client: a reasonless model offers no level chips.

Run at this tree (base a93190ae1):
- go test -count=1 -timeout 45m ./internal/{provider,cli,gui,gateway,
  settings,tui,agent,catalog}: all ok (gateway 505s, agent 360s).
- GUI: gateway-*.test.cjs, model-reasonless, plugin-gateway, i18n-keys
  (25 files, both engines, the new file at 1100 and 420 in en, zh,
  zh-TW, ja, de): 225/225 pass. app.js untouched.
- gofmt -l empty; go vet darwin, linux -tags nogui, windows clean.
- Sandbox HOME, built binary, `magpie web` on 47821/47820 and a fake
  Chat vendor on 47811: before, kenari/glm-5:free had no window or
  levels; after spec 128k/16k/on/low-high, /v1/models said 128000,
  16000, image input, [low medium high]; max_tokens 100000 went as
  16000, xhigh as high, low as low; qwen-x with --reasoning off was
  sent no reasoning field; /api/providers had context 128000, output
  16000, images/imageSet, kept [low medium high], reasonless for qwen-x.
  A models.dev sync during the run (GLM-5 202752/131072) didn't move
  the spec; after --reset the vendor's values came back. Bad values,
  an unknown flag and --help wrote nothing (files hashed).

Rebased onto a6a3dbde8 (the ZCode mover's min, one line): at the
pushed head 5af093d8b's tree, ./internal/provider and ./internal/cli
-timeout 45m ok, and the spec tests in gateway and gui ok.

Broken by hand, each went red: AutoVision on raw sees; Efforts on the
full list; the Reasoning line removed; output, vision or context not
written; ParseLevels skipped; agents told twice; --context 0 taken;
help printing modelUsage; old client.js; the GUI named() image and
reasonless branches.

Not tried / not changed: no full go test ./... (another session's
full GUI suite was running). Codex's ChatGPT-model /models pass-through
and the Codex effort dropdown read catalog.Codex(), not a spec. The
TUI shows no spec badges. A Context-tab trace keeps the window it was
recorded with. Pre-existing and the same on origin/main a6a3dbde8: a
GLM-5 relay with no levels known has xhigh sent as high.
2026-10-24 05:31:59 +08:00
yetone 89521b03d6 cli, gateway: magpie cpu records the running magpie's CPU profile for 30s, for a report of high CPU (@LeiCheng42 on X)
@LeiCheng42 on X reports magpie using the most CPU while Codex runs. As
with magpie heap (e085d6e92), Activity Monitor and `sample` show Go's
frames as ???, so `magpie cpu [<file>] [--seconds N]` asks the magpie
serving the gateway for GET /v1/magpie/cpu?seconds=N: runtime/pprof's CPU
profile over 30s (5..120; else 400), gzipped protobuf, with the pid,
version, uptime, CPU time used over the window (getrusage / GetProcessTimes)
and since start, cores, GOMAXPROCS and goroutines in X-Magpie-CPU-Stats. It
tells the user to use magpie as when busy (run Codex) while it records,
writes <file> else magpie-cpu-<date>-<time>.pb.gz (0600), refuses a file
that is there before recording, and says "is magpie running?" at once when
nothing answers. --help writes nothing; an unknown flag, "-", a second file
or --seconds out of range are refused before anything is asked.

Only the profiling request waits: the gateway serves everything else
meanwhile. pprof keeps one CPU profile at a time, so a second ask gets 409
(cpuRecording), and a caller that hangs up stops the recording. The route
takes heap's guard: heapRefused's checks move into profileRefused, shared
by cpuRefused, so only a loopback, unproxied, browserless call to a
loopback Host gets it, with or without a gateway key or lanGuard.

Run at bad4508c4 + this: gofmt -l (nothing); go vet ./..., GOOS=linux go
vet -tags nogui ./..., GOOS=windows go vet ./... (clean); go test -tags
nogui -timeout 45m ./... under a sandbox HOME: every package ok except
internal/agent (45m timeout, #2544; again alone, in TestPortMovesEveryAgent)
and internal/gateway (TestTranslatedStreamKeepsClientAlive/chat_to_responses,
sibling of #2169/#2711, filed as #2737; alone with -timeout 45m only
/chat_to_anthropic, #2169; the test passes 5/5 alone). TestCPU* -race
-count=3 ok. Broken by hand: cpuRefused returning "" (19 failures in
TestCPUProfileOnlyToThisComputer); no one-at-a-time guard and no hang-up
stop (TestCPUProfileOneAtATime red each); no seconds bounds, no pre-check
of the file, no is-it-running check, no help case (each CLI test red).
Rebased on 2042123f4: go build ./..., gofmt -l, GOOS=windows and
GOOS=linux vet of internal/gateway and internal/cli clean; go test -run
'CPU|Cpu|Heap|Help' ./internal/cli ./internal/gateway ok.

Real use: the built binary's `magpie serve` under a sandbox HOME on
127.0.0.1:3493; `magpie cpu --seconds 5` saved a 0600 profile that go tool
pprof -top reads and printed the numbers; a concurrent second one got the
409 while GET / answered in ms; Origin: null and a rebound Host got 403;
--help wrote nothing; an existing file was refused. Not tried: the GUI
app's process, or the Windows box.
2026-10-17 20:52:13 +08:00
yetone e085d6e926 cli, gateway: magpie heap writes the running magpie's Go heap profile, with its memory numbers
A user on X (FatimaHill74421) reports the macOS app at 3.95 GB physical
footprint after ~12h (v0.1.1273, after 8a1b5916f's #2278 fix), and a macOS
`sample` shows Go's frames as ???. `magpie heap [<file>]` asks the magpie
that serves the gateway for GET /v1/magpie/heap: runtime/pprof's heap
profile after a GC (gzipped protobuf, go tool pprof reads it), with
HeapAlloc, live heap, HeapInuse, HeapSys, StackSys, Sys, NumGC and the
goroutine count in X-Magpie-Heap-Stats. It writes <file>, else
magpie-heap-<date>-<time>.pb.gz here (0600, never over a file), and prints
the path, the pid and the numbers. --help writes nothing; an unknown flag,
"-" or a second file is refused before anything is asked.

The route answers only a loopback, unproxied caller with no browser marks
calling localhost or a loopback IP. heapRefused checks this in the handler
itself, so a gateway key never lets in another machine, a listed page,
Origin null, a localhost page or a rebound Host, and it holds where Handler
is served without lanGuard.

Run at dccfefdf7: gofmt -l (nothing); go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... (clean); go build for darwin,
linux (nogui) and windows; go test -tags nogui -timeout 45m ./... under a
sandbox HOME: every package ok (gateway 1218s, cli 613s). Broken by hand:
heapRefused returning "" turns TestHeapProfileOnlyToThisComputer red
(19 failures).

Real use: the built binary's `magpie serve` under a sandbox HOME on
127.0.0.1:3481; `magpie heap` saved a 10 KB profile (0600) and printed the
numbers, go tool pprof -top read it, --help wrote nothing, and a curl with
Origin: null got 403. Not tried: the GUI app's own process, or the
Windows box.
2026-10-17 12:04:53 +08:00
yetone 8f03b78069 cli, gateway: magpie statusline prints the session's model and each account's windows for Claude Code's status line (#1997, kensenzhao)
kensenzhao asked for magpie's routing and quota in Claude Code's status
line. Claude Code runs the statusLine command on every update and cancels
the run that is still going, so the command must answer fast. It must never
make a vendor read.

- `magpie statusline [<provider|account>]` reads Claude Code's statusLine
  JSON from stdin. It prints "→ <served model>" from
  /v1/magpie/route?session=<session_id>, then each subscription account's
  windows ("claude a@x* 5h 62% 7d 41%"). `*` marks the account that served
  last. A window whose reset has passed shows 0%. With the gateway off it
  prints an empty line. Each request times out after 1s.
- /v1/magpie/quotas?kept=1 (provider.KeptQuotaReport) builds the same
  report from the kept cards (CachedCards) and never starts a vendor read.
  The plain endpoint can take up to 12s.
- magpie never writes statusLine into Claude Code's settings. The user
  adds `"statusLine": {"type": "command", "command": "magpie statusline"}`
  themselves (magpie statusline's help, docs/reference.md).

Run: go test -tags nogui ./internal/cli ./internal/provider
./internal/gateway in a sandbox HOME; gofmt -l; go vet natively and with
GOOS=linux and GOOS=windows.

Broken by hand, each went red:
- the CLI asking without kept=1 (TestStatuslineTellsRouteAndEveryAccount);
- dropping the route line (same test);
- KeptQuotaReport calling QuotaReport (TestKeptQuotaReportAsksNobody).

Real use: a built binary against a sandbox gateway on 127.0.0.1:3517.
- kept=1 answered in 0.07s and route in under 1ms.
- `magpie statusline` with Claude-style stdin printed an empty line, since
  the sandbox has no accounts.
- Its ~1.1s wall time matches `magpie version`, so that is process start.
Not tried: real accounts, or the line inside a real Claude Code statusLine.
2026-10-14 08:26:04 +08:00
yetone b26c083c84 cli: setting Claude Code's sonnet/opus/haiku/fable while it is on magpie says magpie is out, and help says the aliases take it out (#2000, marshalys)
`magpie claude sonnet` sets Claude Code's model to its own alias. That
isn't a model magpie serves, so magpie steps out (unroute) and puts back
the endpoint Claude Code had before magpie. In #2000 that endpoint was
DeepSeek's, which refused Sonnet with a 400. The command printed only
"✓ Claude Code model sonnet". An agent had run it as a read-only query of
the sonnet tier, and nothing in the output said the routing had changed.

set() now checks whether the agent was wired into magpie before the
write. When a non-empty value leaves it unwired, set() prints
"disconnected from magpie: <model> is <agent>'s own, sent to the endpoint
it had before magpie; magpie <agent> <model> with one of magpie's models
connects it again". This covers every agent and field set through
`magpie <agent> …`, not only Claude's aliases. Setting a field back to
default (empty) is left as it was. `magpie <agent> default` already says
it disconnects.

The behaviour itself is unchanged. On an Anthropic sign-in or a Claude
relay the aliases are a deliberate one-word way back to Claude Code's own
models.

`magpie claude help` now has a line under the aliases: "they are Claude
Code's own models, not magpie's: setting one takes magpie out; magpie
claude alone shows each".

Verified:
- TestClaudeAliasSaysItTookMagpieOut covers opus, sonnet, haiku and
  fable. It starts from a DeepSeek-style own endpoint (.invalid host),
  wires Claude Code to group/advanced and sets the alias. It checks the
  notice, that the old endpoint is back, that nothing is printed when the
  alias is set again while off magpie, and the help line.
- With the notice disabled by hand, the test fails:
  "magpie claude opus: <nil> "✓ Claude Code model opus\n", want it to say
  magpie is out" (and the same for the other three).
- TestAgentDefaultInAnyCase first went red on "codex model DEFAULT", so
  empty values are excluded.
- HOME=<sandbox> go test -tags nogui ./internal/cli: ok.
- gofmt -l clean. go vet and GOOS=linux/windows go vet -tags nogui
  ./internal/cli: clean.
2026-10-13 23:30:17 +08:00
bingqilinweimaotai 1af326806f sync: magpie's setup syncs to an encrypted file in a GitHub repository, beside WebDAV and S3 (#1130)
A third sync kind: github://owner/repo[/folder] keeps the same sealed
backup WebDAV and S3 keep, as <folder>/magpie/magpie.magpie-backup in a
repository the user already has, written through GitHub's Contents API
with a fine-grained token of its own (Contents read and write), kept in
sync.json apart from the library's GitHub token. The token goes only to
api.github.com: a redirect anywhere else is refused, and the passphrase
may not equal it. Each update is a commit; an empty repository is
initialised by the first backup. Settings › Sync gets a GitHub kind with
Repository, Branch, Folder and token; magpie github mirrors magpie s3.
Inactive servers of every kind are kept in Config.Servers (Other stays
for older clients).

Squashed from yetone/magpie#1130 at 6b5b1c693e1a3a23e177b4d376f3f7f70f3bc23d
onto main. Merge resolutions: the CLI moved to internal/cli since the PR
was cut, so github_cli_test.go moved there (package cli) and the github
command, its help line and `magpie help github` were wired in
internal/cli/main.go and help_cli.go; README's Sync row kept main's
links and took the PR's wording; i18n.js zh-TW kept both sides.
2026-10-13 15:25:06 +08:00
wei 4419ebf7d6 cli, agent: magpie <agent> <field> shows that field and a field's name or DEFAULT is no longer written as the agent's model (#1129, waitingsnow)
What: `magpie codex model` wrote model = "model" into config.toml (and
applied.json, stash.json); any agent's field name given alone, or as a
value, was set as its model, and `magpie codex DEFAULT` wrote
model = "DEFAULT". Now:
- `magpie <agent> <field>` (any case) prints that one field and writes
  nothing;
- a field's name given as a value is refused with a hint
  (`magpie claude effort Ultracode`);
- DEFAULT in any case takes magpie out, as `default` does;
- Claude Code's tier names (opus/sonnet/haiku/fable) still set the model,
  since agent.ModelAliases marks them, and the agent's help says so.
agent.Field matches key and label in any case; agent.Running is a var
so the cli tests can say Codex isn't open.

Why: ported from waitingsnow's #1129 (commits bbe75c91f, 00bb38581,
244b24a67) onto internal/cli, where the CLI moved after the PR was
opened. The PR's --help part landed earlier as 76db4c6c2 (#1457).

Run: the five new internal/cli tests fail on origin/main without the
cli change (TestAgentFieldNameShowsIt: "✓ Codex model model" and
model = "model" written; TestAgentDefaultInAnyCase: "✓ Codex model
DEFAULT"; the tier-name help line and the Ultracode hint missing) and
pass with it. gofmt -l clean; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows clean; go build for all three; go test -tags nogui ./...
green (an earlier run's internal/agent 10m timeout was a stuck open()
in TestWSLStoppedDistro under a 100%-full disk and load ~44; the WSL
tests pass alone and the full rerun passed).
2026-10-13 09:47:25 +08:00
yetone 23e764d0e0 cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are
to internal/cli (package cli), with git mv so history follows them. The
only code change is main() becoming cli.Main(version): the root's new
main.go keeps `var version` in package main, so -ldflags "-X
main.version=…" in the Makefile, the Dockerfile and magpie-releases, and
every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land
next to package main in the root.

Tests that read testdata by a root-relative path now go up one level
(../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links
point at internal/cli/.

Run:
- go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui)
- builds with tags production, dev, "production nogui"; windows
  -H windowsgui; linux CGO_ENABLED=0
- make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64
  android/arm64" VERSION=9.9.9-tidy: all four built, binary prints
  "magpie 9.9.9-tidy"
- docker build --build-arg VERSION=7.7.7-tidy: container prints
  "magpie 7.7.7-tidy"
- go test ./internal/cli (default and nogui): 152 tests, the same count
  as the root on main
- go test ./...: all packages pass (agent, gateway, library, provider
  timed out at 10m under other sessions' load and passed rerun alone
  with -timeout 40m; none of them changed)
- the built binary in a sandbox HOME: version, help, ls, providers,
  claude, and an unknown command's error
2026-10-12 20:40:22 +08:00