Commit Graph
3 Commits
Author SHA1 Message Date
yetone e18aca1038 agents: an agent's own context window, and a routing group's own Compact at (ul3140773077392, NovaStudiosss on X)
ul3140773077392 on X: dsh compacts earlier than other harnesses at the same
window, so one global size per model fits none. An agent's sheet (Agents,
the agent's Settings line) now holds "Context window": a size for every
model, or model=size pairs (provider/model, group/<id>, provider/*, a bare
model id, *). Empty follows each model's own window. It is applied in
provider.CatalogFor, the choke point every agent's model list goes through,
so dsh's contextWindow, Codex's catalog and Claude Code's window all read
it, and a window set this way makes Codex/Claude compact at that window
(Entry.WindowSet). Stored in settings.AgentContexts, kept by a general
save (settingsapi); POST /api/settings/agent-contexts and
`magpie model window <agent> [model=size...|off]`.

NovaStudiosss on X: Routing, a group's Edit, Advanced already had "Context"
(the window agents are told). It now has "Compact at" beside it
(Group.Compact; compactSet reads it before the members' smallest), also
`magpie group ... compact=`.

GUI: agentwindow.js, loaded on demand through agentcompact.js so app.js
stays inside its budget (TestCoreScriptBudget passes; the "Context window
in {agent}" label reuses the existing "Context window" key). Every agent
with fields now has a sheet; agent-prefs' Pi expectation says so.

Run at the pushed head, on mote: go vet (darwin; linux -tags nogui;
windows) on provider, agent, cli, gui, settings, settingsapi; gofmt clean;
go test provider, cli, settings, settingsapi, gui (TestCoreScriptBudget
and cli's route table fixed here), agent -run Dsh; node --test agent-window
and group-compact (chromium and webkit, en zh zh-TW ja de, 900 and 420px),
agent-compact, agent-prefs, compact-at. Reds seen identically on a
detached origin/main 4e0026661: agent-prefs webkit "in the panel a
Settings line..." (#6139) and old-webkit "compat.js is the first" / "styles
hold up in Safari 15.0" (#5919, #3403).

Broken by hand, each red then restored: withAgentWindows out of CatalogFor
(TestAgentOwnContextWindow, TestDshOwnContextWindow); the group branch in
compactSet (TestGroupOwnCompactAt); the settingsapi keep line
(TestSettingsSaveKeepsWhatItDoesNotSend); the window row in the sheet
(agent-window tests); compact dropped from the group save
(group-compact tests).

Not tried: a real dsh with a real account (its compaction is dsh's own;
the test reads the window magpie hands it), the full GUI suite (queued
behind another run on mote), Windows and Linux runs of the new tests.
2026-11-12 23:01:29 +08:00
yetone 6b47bce670 cli: magpie model compact <agent> sets an agent's own Long conversations
3eb2bda4f added POST /api/settings/agent-compact with no command, and
internal/cli's TestEveryRouteHasACommandOrIsNamed went red in the full
suite run after the push (settings_parity_test.go:437). Rather than
park the route in notYet, the command it names is here:

  magpie model compact <codex|claude|grok>            says the agent's
  magpie model compact <agent> every|off|<size>       sets it

every takes the agent's own away (it follows the value for every
agent), off is Full window, a size such as 300k compacts there; another
word is refused and nothing is written. A first word that isn't one of
settings.CompactAgents goes to the command as before (on|off|<size>).
cliForRoute names it; the usage text and agent-wiring.md say it.

Run at this tree (3eb2bda4f + this), on mote: go vet ./internal/cli,
GOOS=windows go vet ./internal/cli, go test ./internal/cli: ok.
TestModelCompactAgentCmd broken by hand (the command setting the shared
value instead): red, "codex 300000, claude 300000".
Not tried: the command against a real agent's files (catalog.Changed is
nil in the test, as in TestModelCompactCmd).
2026-11-04 16:35:16 +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