@Luxzinw on X asked for three things: sync billion-context's config, edit its settings in the Library's billion-context tab, and have running bili proxies reload after a change. Sync. billion-context.json goes in the library part (library.Bundle.Bili), by sync and backup file alike. magpie finds it the way bili's src/paths.ts does: BILI_CONFIG_FILE, else $XDG_CONFIG_HOME (or ~/.config, %USERPROFILE%\.config on Windows), then billion-context/billion-context.json. - The text is carried as written, comments kept. - magpie's summary recipe is carried at the canonical gateway address and localized to this computer's gateway when written, so two computers on different ports don't trade it back and forth. - A newer local file is never blindly overwritten. Before a carried file replaces a different one here, this computer's copy is kept with the backups. - An unreadable file, or one over 1 MiB, counts as unknown and is never carried as empty. A bundle without the file leaves this computer's alone. - A file naming a DSN is left out of keyless backups. - The credential store (<config>.summary-credentials.json) never travels. - A library with no such file hashes as before. - The new sync preview names the file when it would be added, changed or removed. Settings. GET/POST /api/library/bili/settings, and a Settings section under the agents in the tab: - In front: "Summarize with a fast model" (externalSummary), picked from the app's menu, never a <select>. It offers magpie's served models and the file's own recipes. "Fold only when nudged" (requireNudge) and "Nudge every N tokens" (nudgeGrowthTokens). - Under Advanced, collapsed: the compression philosophy (prompts.compressPhilosophy with acknowledgePromptsRisk, which bili needs before it reads a prompt override). Writes go through edit.PatchJSON and temp+rename, so unknown keys, comments and the BOM are kept. bili disables its whole compress section on one bad value, so magpie writes only values bili accepts. A magpie model becomes a providers.magpie recipe whose key is saved in bili's own credential store, the way bili writes it (0600, O_EXCL .lock, temp+rename). A user's own providers.magpie is never taken over. A file bili can't read is said so and left alone. Reload. After a change, and after sync writes the file, every running bili on loopback is sent POST /__bili/config/reload. bili reloads routes and compress there. The status line says whether it did, or that the agent needs a restart. Also: agentenv.Vars clears BILI_CONFIG_FILE in sandboxes, and the settings-parity list names the two routes for stage 3, as the other bili routes are. Run (mica, macOS): - At abcbc632e, this change on origin/main9a8219237. The three commits main gained before the push (e8001f73a,7af7a3aba,005178104) touch none of these files: - go test -count=1 -timeout 45m ./internal/agentenv ./internal/agent ./internal/cli ./internal/library ./internal/gui ./internal/davsync: all ok; - go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build: ok; - gofmt -l: nothing; - library-bili-settings, library-bili, i18n-keys and sync-scope .test.cjs, Chromium and WebKit, every language, 1100 and 420 wide: ok; - library-bili-settings was red in WebKit 1 run in 4: the tab was clicked by its index in a list read before the sidebar drew its own list, in another order, so the click reached another tab. A dump of the page at the miss showed Instructions still open. Both files now click the tab by its name. library-bili.test.cjs did the same twice and is changed with it. After the change: WebKit 6 runs in a row and both files in both engines, all green. - Full go test ./... at an earlier base,7eecbcc56: only TestFolderVarsAreListed and TestEveryRouteHasACommandOrIsNamed went red, both guard tests for this change. They are fixed here and pass in the run above. - Whole GUI suite at that base: 71 reds, none in the Library, i18n or sync. Each also fails without this change on origin/main459d668b3(68 there, and the rest pass at this head): - agent-details-ready: #6369, #6373 - api-key-theme: #6444 - account-arrange: #6010 - agent-switch-accounts: #5925 - aside-native: #6212 - agent-menu-label: #6371 - account-refresh-holds: #5814 - bark: filed as #6543 Broken by hand: - Collect not carrying the file: TestBiliFileCarried red. - The model pick without summary, or Advanced not kept open: the GUI test red (22 of 32). - On the old code the new Go tests don't compile, and the route test gets 404. Not tried: a real bili proxy reloading. The reload is tested against a fake /__bili/config/reload, and bili's source was read, not run. Not tried with a real WebDAV/S3/GitHub server between two computers either: the davsync tests use the fake server. When a running bili doesn't reload, the status line says to restart the agent.
60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
package davsync
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/backup"
|
|
"github.com/yetone/magpie/internal/library"
|
|
)
|
|
|
|
// A library that holds only billion-context.json is the user's, not an
|
|
// unset part a joining computer's library would be taken over by
|
|
// (#5642); one with no file hashes as before it was carried.
|
|
func TestBiliFileInLibraryPart(t *testing.T) {
|
|
empty := func() backup.Bundle {
|
|
return backup.Bundle{Library: &library.Bundle{MCP: []*library.Server{}, Skills: []*library.CarriedSkill{}}}
|
|
}
|
|
if !unset(empty(), "library") {
|
|
t.Fatal("an empty library is unset")
|
|
}
|
|
text := `{"compress":{"nudgeGrowthTokens":80000}}`
|
|
with := empty()
|
|
with.Library.Bili = &text
|
|
if unset(with, "library") {
|
|
t.Error("a library with billion-context.json said unset")
|
|
}
|
|
if hashes(with)["library"] == hashes(empty())["library"] {
|
|
t.Error("billion-context.json didn't change the library's hash")
|
|
}
|
|
}
|
|
|
|
// The sync's preview names billion-context.json when it would change,
|
|
// though the file is one string and not a list of items.
|
|
func TestBiliFileInPreview(t *testing.T) {
|
|
at := func(text string) backup.Bundle {
|
|
b := backup.Bundle{Library: &library.Bundle{MCP: []*library.Server{}, Skills: []*library.CarriedSkill{}}}
|
|
if text != "" {
|
|
b.Library.Bili = &text
|
|
}
|
|
return b
|
|
}
|
|
file := []Item{{Kind: "file", Name: "billion-context.json"}}
|
|
for _, c := range []struct {
|
|
from, to, change string
|
|
}{
|
|
{"", `{"compress":{}}`, "added"},
|
|
{`{"compress":{}}`, `{"compress":{"requireNudge":true}}`, "changed"},
|
|
{`{"compress":{}}`, "", "removed"},
|
|
} {
|
|
got := diffItems(itemsOf(at(c.from), "library"), itemsOf(at(c.to), "library"))
|
|
want := []Item{{Kind: file[0].Kind, Name: file[0].Name, Change: c.change}}
|
|
if !slices.Equal(got, want) {
|
|
t.Errorf("%q to %q: %+v", c.from, c.to, got)
|
|
}
|
|
}
|
|
if got := diffItems(itemsOf(at(`{}`), "library"), itemsOf(at(`{}`), "library")); len(got) != 0 {
|
|
t.Errorf("the same file: %+v", got)
|
|
}
|
|
}
|