update: a Daily channel, one release a day that passed its tests, for the app and Docker (fishmagic80 on X)
fishmagic80 on X: Stable is too slow (community plugins need a newer
magpie than it has), every release is too fast, and Docker users have
nothing in between. Daily sits between them.
What it is:
- site/worker.js keepDaily: at the daily cut (20:00 UTC, the quarter-hour
cron) the newest tag whose commit has a successful Test run and whose
release has all 17 assets is picked and kept in LEDGER "daily". A day
with none keeps the day before's; a failed GitHub read writes nothing.
/api/latest?channel=daily (503 until a pick exists), /download/daily/<p>,
and an urgent release overlays it as on Stable.
- .github/workflows/docker-daily.yml reads that feed and points
ghcr.io/yetone/magpie:daily at the picked version's image.
- App: settings.UpdateDaily ("daily"); update.Channel()/Picked() (Stable()
kept); the feed is asked channel=daily, never falls back to GitHub's
latest, What's new lists every change since yours. Settings > About >
Update channel has Every version / Daily / Stable; the version row says
"Up to date on Daily (· {v} is out on Every version)". CLI: magpie
update channel [stable|daily|every].
- Words in en, zh, zh-TW, ja, de, on top of 7f832b2f2's 尝鲜版/搶先版/先行版
for Every version (kept as it landed).
- The channel row wraps its switch under its name when narrow (ja at
420px was 18px past the window with three segments).
- app.js budget +338: the segment, its line and the two Up to date on
Daily words, packed to one t() per choice; Settings and renderUpdate
draw on every window, nothing lazy to move them to.
- Docs: docs/reference.md, site docs (docker, privacy in en/zh/ja),
llms-full.txt, search indexes.
Red on the old code (a daily-old worktree, then only settings allowing
"daily"): the feed was not asked channel=daily, 40 notes instead of all,
Picked false, notesKey "zh" not "zh|daily", the Daily row showed
"available"; the GUI tests had no Daily segment.
Run on mote at this commit's tree (on origin/main ec1a1a7a5; the Daily pick itself is live on the deployed worker: /api/latest?channel=daily answers 0.1.4171, /download/daily 302s to its dmg):
- go test -count=1 ./internal/settings ./internal/settingsapi
./internal/update ./internal/cli ./internal/gui: all ok (TestCoreScriptBudget
included).
- GUI, chromium and webkit, every language: update-*.test.cjs (22 files),
i18n-*.test.cjs, settings-search.test.cjs: 554 of 554 pass.
- site: node --test site/*.test.mjs, 132 of 132 (130 before the rebuild).
- gofmt -l clean; go vet darwin, windows (gui/update/cli) and
GOOS=linux -tags nogui.
Also: site/public/search/*.json and llms-full.txt rebuilt
(search-index.mjs, llms-full.mjs); they still listed Antigravity's old
sign-in after 9cd5f3652, so the two site freshness tests were red.
Filed: #6730, engines.magpie is never read, so a plugin needing a newer
magpie installs on Stable (0.1.3078) and fails without saying why
(page-amp-usage >=0.1.3681, middleware-company-guard >=0.1.3841,
page-day-card >=0.1.3427).
Not tried: a real self-update on Daily, a real docker-daily workflow run,
the whole GUI suite, the worker's unauthenticated GitHub reads under a
rate limit.
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
name: Docker daily
|
||||
|
||||
# ghcr.io/yetone/magpie:daily is the newest release's image, moved once a
|
||||
# day: magpie releases many times a day, and Renovate opened a PR for each
|
||||
# one (YaoFur on X, "改成每天凌晨更新一次"). At 20:00 UTC (04:00 in
|
||||
# China) it points :daily at whatever :latest is then, by digest; it never
|
||||
# builds, and never touches latest, stable, edge or a version's tags.
|
||||
# Releases themselves go out as fast as ever.
|
||||
# ghcr.io/yetone/magpie:daily is the image of the Daily channel's release
|
||||
# (Settings › Update channel › Daily; fishmagic80 on X, YaoFur's Renovate
|
||||
# before that): once a day, the newest release out by 20:00 UTC (04:00 in
|
||||
# China) whose own CI run passed and that has all its files, or an urgent
|
||||
# one at once. Which release that is, is decided in one place only,
|
||||
# site/worker.js's keepDaily, and served at /api/latest?channel=daily. This
|
||||
# only reads that answer and points :daily at the image already built for
|
||||
# that version (docker.yml); it never builds, and never touches latest,
|
||||
# stable, edge or a version's tags. While the feed can't be read the tag
|
||||
# stays where it was. Releases themselves go out as fast as ever.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 20 * * *'
|
||||
- cron: '53 * * * *'
|
||||
# a release's image is pushed: an urgent one is Daily at once
|
||||
workflow_run:
|
||||
workflows: [Docker]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
@@ -18,10 +26,11 @@ concurrency:
|
||||
|
||||
env:
|
||||
IMAGE: ghcr.io/${{ github.repository_owner }}/magpie
|
||||
FEED: https://usemagpie.ai/api/latest?channel=daily
|
||||
|
||||
jobs:
|
||||
daily:
|
||||
if: github.repository == 'yetone/magpie'
|
||||
if: github.repository == 'yetone/magpie' && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -35,19 +44,28 @@ jobs:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Point daily at the newest release's image
|
||||
- name: Point daily at the Daily release's image
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if ! BODY=$(curl -fsS --retry 3 --max-time 30 "$FEED"); then
|
||||
echo "::warning::the Daily feed couldn't be read; $IMAGE:daily stays where it was"
|
||||
exit 0
|
||||
fi
|
||||
V=$(jq -r '.version // empty' <<<"$BODY")
|
||||
if [[ ! "$V" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "::warning::the Daily feed named no release ($V); $IMAGE:daily stays where it was"
|
||||
exit 0
|
||||
fi
|
||||
# an image is the platforms' manifests in it, however its index
|
||||
# is written
|
||||
digest() { docker buildx imagetools inspect "$1" --format '{{json .}}' | jq -er '[.manifest.manifests[]?.digest] | sort | join(",") | select(. != "")'; }
|
||||
WANT=$(digest "$IMAGE:latest") # no latest image is a red run
|
||||
WANT=$(digest "$IMAGE:$V") # no image for the Daily release is a red run
|
||||
HAVE=$(digest "$IMAGE:daily" 2>/dev/null || true)
|
||||
if [[ "$HAVE" == "$WANT" ]]; then
|
||||
echo "$IMAGE:daily is latest already ($WANT)"
|
||||
echo "$IMAGE:daily is $V already ($WANT)"
|
||||
exit 0
|
||||
fi
|
||||
docker buildx imagetools create -t "$IMAGE:daily" "$IMAGE:latest"
|
||||
docker buildx imagetools create -t "$IMAGE:daily" "$IMAGE:$V"
|
||||
GOT=$(digest "$IMAGE:daily")
|
||||
echo "$IMAGE:daily is now latest ($GOT, was ${HAVE:-none})"
|
||||
echo "$IMAGE:daily is now $V ($GOT, was ${HAVE:-none})"
|
||||
test "$GOT" == "$WANT"
|
||||
|
||||
+26
-11
@@ -3415,7 +3415,8 @@ release page's redirect when the API is rate-limited), with its
|
||||
check as the feed's: the ed25519 signature against the key built into the
|
||||
binary, the version in the signed message, each file's hash from the signed
|
||||
list. A release read this way must be signed whatever its version. The
|
||||
Stable channel and a `MAGPIE_UPDATE_FEED` of your own don't fall back.
|
||||
Stable and Daily channels and a `MAGPIE_UPDATE_FEED` of your own don't
|
||||
fall back.
|
||||
|
||||
Settings → Network → *Update source* (`"updateSource"` in settings.json,
|
||||
`magpie settings set updateSource github`, this computer's own) chooses where an
|
||||
@@ -3424,9 +3425,9 @@ usemagpie.ai, then GitHub. `site` (usemagpie.ai only) never goes to GitHub,
|
||||
for the release or for a file. `github` (GitHub only) reads the release from
|
||||
`yetone/magpie-releases` without asking the feed, and downloads files from
|
||||
github.com (through a `--mirror` when one is given, then GitHub's API route);
|
||||
usemagpie.ai is not asked. On the Stable channel the list of releases is only
|
||||
the site's, so `github` still reads it from the feed and downloads from
|
||||
GitHub. A `MAGPIE_UPDATE_FEED` of your own is never overridden. Every source
|
||||
usemagpie.ai is not asked. On the Stable and Daily channels the release is
|
||||
only the site's pick, so `github` still reads it from the feed and downloads
|
||||
from GitHub. A `MAGPIE_UPDATE_FEED` of your own is never overridden. Every source
|
||||
is held to the same signature and hashes (`Release.verify`).
|
||||
|
||||
Release files are downloaded from usemagpie.ai's copy on Cloudflare R2
|
||||
@@ -3531,11 +3532,23 @@ trusted to the site over HTTPS and the SHA-256 the site gives.
|
||||
|
||||
### Update channel
|
||||
|
||||
magpie takes every version as it comes out unless you choose Stable, in
|
||||
*Settings → About → Update channel* or with `magpie update channel stable`
|
||||
magpie takes every version as it comes out unless you choose Daily or
|
||||
Stable, in *Settings → About → Update channel* or with
|
||||
`magpie update channel daily` or `magpie update channel stable`
|
||||
(`magpie update channel every` goes back; `magpie update channel` prints
|
||||
the one in use). It is saved as `"updateChannel": "stable"` in
|
||||
settings.json, and the app and `magpie update` both follow it.
|
||||
the one in use). It is saved as `"updateChannel": "daily"` or `"stable"`
|
||||
in settings.json, and the app and `magpie update` both follow it.
|
||||
|
||||
Daily is one version a day. Each day at 20:00 UTC it becomes the newest
|
||||
release out by then whose Test run on `main` passed (the run on the
|
||||
release's own commit) and that has all of its 17 files; a day with no
|
||||
such release keeps the day before's. A release marked urgent goes to Daily
|
||||
at once. What's new lists every version since yours as one list, and the
|
||||
Version row names the newest out on Every version as it does on Stable.
|
||||
The site works it out every quarter hour
|
||||
(`https://usemagpie.ai/api/latest?channel=daily`,
|
||||
`usemagpie.ai/download/daily/<platform>`); the Docker image's `daily` tag
|
||||
follows it.
|
||||
|
||||
Stable is one version a week. Each Monday at 00:00 UTC it becomes the
|
||||
newest release that had been out for three days by then (Friday 00:00
|
||||
@@ -3834,9 +3847,11 @@ VPN such as Tailscale or WireGuard; a reverse proxy or tunnel forwarding to
|
||||
Magpie over loopback needs a gateway key from its clients, as the network does.
|
||||
|
||||
The image's tags: `latest` is the newest release, and magpie releases
|
||||
several times a day. `daily` is the newest release as of 20:00 UTC, moved
|
||||
once a day (`.github/workflows/docker-daily.yml`), for Renovate or
|
||||
Watchtower to update at most daily (with Renovate, pin its digest);
|
||||
several times a day. `daily` is the desktop app's Daily channel: once a
|
||||
day at 20:00 UTC, the newest release whose CI run passed, or an urgent one
|
||||
at once (`.github/workflows/docker-daily.yml` follows
|
||||
`usemagpie.ai/api/latest?channel=daily`), for Renovate or Watchtower to
|
||||
update at most daily (with Renovate, pin its digest);
|
||||
`stable` is the desktop app's Stable channel, one a week. `0.1.N` is one
|
||||
release, `0.1` the newest of its line, and `edge` every change on `main`.
|
||||
|
||||
|
||||
@@ -191,8 +191,9 @@ const usage = `magpie — one place to pick every agent's model
|
||||
http(s):// or socks5:// proxy for it; --mirror: a GitHub download mirror put
|
||||
before the github.com URL (none unless given; still checked against usemagpie.ai's SHA-256)
|
||||
magpie update mirror [<prefix>|off] the mirror every update, the app's own too, is downloaded through
|
||||
magpie update channel [stable|every] which versions updates offer: stable (one a week, an urgent one at
|
||||
once) or every version as it comes out (the default)
|
||||
magpie update channel [stable|daily|every] which versions updates offer: stable (one a week), daily (one
|
||||
a day that passed its tests), an urgent one at once on both, or every
|
||||
version as it comes out (the default)
|
||||
magpie update auto [on|off] [download|notify] [30m|1h|6h|24h]
|
||||
whether the app looks for updates by itself, how often (6h), and whether
|
||||
it downloads one at once or only says it is out (notify: for metered networks)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// magpie update channel stable|every saves Settings' Update channel
|
||||
// magpie update channel stable|daily|every saves Settings' Update channel
|
||||
// (ssharpcc on X); with nothing after it, it only says which; anything
|
||||
// else is refused and nothing is saved.
|
||||
func TestUpdateChannelCmd(t *testing.T) {
|
||||
@@ -26,6 +26,9 @@ func TestUpdateChannelCmd(t *testing.T) {
|
||||
{[]string{"update", "channel", "every"}, "", false},
|
||||
{[]string{"update", "channel", "Stable"}, "stable", false},
|
||||
{[]string{"update", "channel", "all"}, "", false},
|
||||
{[]string{"update", "channel", "daily"}, "daily", false},
|
||||
{[]string{"update", "channel", "Daily"}, "daily", false},
|
||||
{[]string{"update", "channel", "weekly"}, "daily", true},
|
||||
} {
|
||||
err := updateCmd(c.args)
|
||||
if (err != nil) != c.bad {
|
||||
|
||||
+18
-11
@@ -107,33 +107,40 @@ func updateMirrorCmd(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// updateChannelCmd is `magpie update channel [stable|every]`: which
|
||||
// versions an update is offered (settings.UpdateChannel, ssharpcc on X):
|
||||
// Stable, one a week and an urgent one at once, or every version as it
|
||||
// comes out. With none, it says which.
|
||||
// updateChannelCmd is `magpie update channel [stable|daily|every]`: which
|
||||
// versions an update is offered (settings.UpdateChannel, ssharpcc and
|
||||
// fishmagic80 on X): Stable, one a week and an urgent one at once; Daily,
|
||||
// one a day that passed its tests and an urgent one at once; or every
|
||||
// version as it comes out. With none, it says which.
|
||||
func updateChannelCmd(args []string) error {
|
||||
s := settings.Load()
|
||||
if len(args) > 1 {
|
||||
return fmt.Errorf("magpie update channel takes stable or every")
|
||||
return fmt.Errorf("magpie update channel takes stable, daily or every")
|
||||
}
|
||||
if len(args) == 1 {
|
||||
switch strings.ToLower(strings.TrimSpace(args[0])) {
|
||||
case "stable":
|
||||
s.UpdateChannel = settings.UpdateStable
|
||||
case "daily":
|
||||
s.UpdateChannel = settings.UpdateDaily
|
||||
case "every", "all":
|
||||
s.UpdateChannel = ""
|
||||
default:
|
||||
return fmt.Errorf("magpie update channel takes stable or every, not %q", args[0])
|
||||
return fmt.Errorf("magpie update channel takes stable, daily or every, not %q", args[0])
|
||||
}
|
||||
if err := settings.Save(s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if s.UpdateChannel == settings.UpdateStable {
|
||||
fmt.Println("update channel: stable", muted.Render("· a version a week, the newest out three days as the week began, and an urgent one at once · magpie update channel every: each one as it comes out"))
|
||||
switch s.UpdateChannel {
|
||||
case settings.UpdateStable:
|
||||
fmt.Println("update channel: stable", muted.Render("· a version a week, the newest out three days as the week began, and an urgent one at once · magpie update channel daily: one a day · every: each one as it comes out"))
|
||||
return nil
|
||||
case settings.UpdateDaily:
|
||||
fmt.Println("update channel: daily", muted.Render("· a version a day, the newest that passed its tests, and an urgent one at once · magpie update channel stable: one a week · every: each one as it comes out"))
|
||||
return nil
|
||||
}
|
||||
fmt.Println("update channel: every version", muted.Render("· each one as it comes out · magpie update channel stable: one a week, an urgent one at once"))
|
||||
fmt.Println("update channel: every version", muted.Render("· each one as it comes out · magpie update channel daily: one a day · stable: one a week; an urgent one at once on both"))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -220,8 +227,8 @@ func updateCmd(args []string) error {
|
||||
}
|
||||
if !update.Newer(rel.Version, version) {
|
||||
if update.Released(version) {
|
||||
if update.Stable() {
|
||||
fmt.Println(green.Render("✓"), "magpie", version, muted.Render("is up to date on the stable channel (stable is "+rel.Version+")"))
|
||||
if ch := update.Channel(); ch != "" {
|
||||
fmt.Println(green.Render("✓"), "magpie", version, muted.Render("is up to date on the "+ch+" channel ("+ch+" is "+rel.Version+")"))
|
||||
} else {
|
||||
fmt.Println(green.Render("✓"), "magpie", version, muted.Render("is the latest"))
|
||||
}
|
||||
|
||||
@@ -4275,6 +4275,10 @@ input.words.window-in { width: 96px; font-variant-numeric: tabular-nums; }
|
||||
/* the masking rules' add row: its words in full, then on a line of their
|
||||
own a name, prefix or regex, the match taking the room left, Add */
|
||||
.row.pref.rule-row { flex-wrap: wrap; row-gap: 8px; }
|
||||
/* three channels: the switch goes under its name when the row is narrow */
|
||||
.row.pref.update-channel-row { flex-wrap: wrap; row-gap: 8px; }
|
||||
.row.pref.update-channel-row .who { flex: 1 1 14em; min-width: 0; }
|
||||
.prefs .row.pref.update-channel-row .val { max-width: 100%; }
|
||||
.row.pref.rule-row .who { flex: 1 1 100%; }
|
||||
.row.pref.rule-row .sub { white-space: normal; }
|
||||
/* Busy models last: six choices don't fit beside their words in a phone-wide
|
||||
|
||||
+13
-10
@@ -20252,14 +20252,15 @@ function renderSettings() {
|
||||
segs(UPDATE_EVERY.map((m) => [m, m < 60 ? t("{n} min", { n: m }) : t("{n} h", { n: m / 60 })]), s.updateEvery || 360,
|
||||
(updateEvery) => savePrefs({ ...keep, updateEvery }))).classList.add("update-every-row", ...(s.noAutoUpdate ? ["off"] : []));
|
||||
// which versions an update offers (ssharpcc on X): every one as it comes
|
||||
// out, or Stable, one a week and an urgent one at once, chosen by the
|
||||
// update feed. It holds for the version row's Check too, so it stays lit
|
||||
// with automatic updates off.
|
||||
row(t("Update channel"), s.updateChannel === "stable"
|
||||
? t("One version a week, out for three days first, and urgent fixes at once. What's new lists every change since yours")
|
||||
: t("Every version as soon as it is out"), "",
|
||||
segs([["every", t("Every version")], ["stable", t("Stable")]], s.updateChannel === "stable" ? "stable" : "every",
|
||||
(v) => savePrefs({ ...keep, updateChannel: v === "stable" ? "stable" : "" }))).classList.add("update-channel-row");
|
||||
// out; Daily, one a day that passed its tests (fishmagic80 on X); or
|
||||
// Stable, one a week; urgent ones at once on both, chosen by the update
|
||||
// feed. It holds for the version row's Check too, so it stays lit with
|
||||
// automatic updates off.
|
||||
const uc = ["stable", "daily"].includes(s.updateChannel) ? s.updateChannel : "every";
|
||||
row(t("Update channel"), t(uc === "stable" ? "One version a week, out for three days first, and urgent fixes at once. What's new lists every change since yours"
|
||||
: uc === "daily" ? "One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours" : "Every version as soon as it is out"), "",
|
||||
segs([["every", t("Every version")], ["daily", t("Daily")], ["stable", t("Stable")]], uc,
|
||||
(v) => savePrefs({ ...keep, updateChannel: v === "every" ? "" : v }))).classList.add("update-channel-row");
|
||||
// whether a newer version found is downloaded at once, or only said to
|
||||
// be out and downloaded on a click (#2296): a metered network or a
|
||||
// proxy billed by traffic. It holds for the version row's Check too.
|
||||
@@ -22705,8 +22706,10 @@ async function renderUpdate(r, u) {
|
||||
again(1000);
|
||||
break;
|
||||
case "latest":
|
||||
// Stable's says the newest out (ylspcm on X)
|
||||
sub.textContent = u.newest ? t("Up to date on Stable · {v} is out on Every version", { v: u.newest }) : t(u.channel ? "Up to date on Stable" : "Up to date");
|
||||
// Stable's and Daily's say the newest out (ylspcm on X)
|
||||
sub.textContent = u.channel === "daily"
|
||||
? t(u.newest ? "Up to date on Daily · {v} is out on Every version" : "Up to date on Daily", { v: u.newest })
|
||||
: u.newest ? t("Up to date on Stable · {v} is out on Every version", { v: u.newest }) : t(u.channel ? "Up to date on Stable" : "Up to date");
|
||||
if (u.newest) btn(t("Switch to Every version"), () => savePrefs({ ...prefsKeep(prefs), updateChannel: "" }));
|
||||
btn(t("Check"), check);
|
||||
break;
|
||||
|
||||
@@ -4107,6 +4107,10 @@ const I18N = {
|
||||
"Up to date": "已是最新",
|
||||
"Up to date on Stable": "稳定版已是最新",
|
||||
"Up to date on Stable · {v} is out on Every version": "稳定版已是最新 · 尝鲜版已有 {v}",
|
||||
"Daily": "每日版",
|
||||
"Up to date on Daily": "每日版已是最新",
|
||||
"Up to date on Daily · {v} is out on Every version": "每日版已是最新 · 尝鲜版已有 {v}",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "每天一个版本,选通过测试的最新版;紧急修复立即推送。「更新内容」会列出你当前版本以来的全部改动",
|
||||
"Switch to Every version": "改用尝鲜版",
|
||||
"What's new": "更新内容",
|
||||
"The release notes since the last update": "上次更新以来的更新说明",
|
||||
@@ -9400,6 +9404,10 @@ const I18N = {
|
||||
"Up to date": "已是最新",
|
||||
"Up to date on Stable": "穩定版已是最新",
|
||||
"Up to date on Stable · {v} is out on Every version": "穩定版已是最新 · 搶先版已有 {v}",
|
||||
"Daily": "每日版",
|
||||
"Up to date on Daily": "每日版已是最新",
|
||||
"Up to date on Daily · {v} is out on Every version": "每日版已是最新 · 搶先版已有 {v}",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "每天一個版本,選通過測試的最新版;緊急修正立即推送。「更新內容」會列出你目前版本以來的全部變更",
|
||||
"Switch to Every version": "改用搶先版",
|
||||
"What's new": "更新內容",
|
||||
"The release notes since the last update": "上次更新以來的更新說明",
|
||||
@@ -14708,6 +14716,10 @@ const I18N = {
|
||||
"Up to date": "最新です",
|
||||
"Up to date on Stable": "安定版では最新です",
|
||||
"Up to date on Stable · {v} is out on Every version": "安定版では最新です · 先行版では {v} が出ています",
|
||||
"Daily": "デイリー版",
|
||||
"Up to date on Daily": "デイリー版では最新です",
|
||||
"Up to date on Daily · {v} is out on Every version": "デイリー版では最新です · 先行版では {v} が出ています",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "テストに通った最新のバージョンを 1 日 1 回、緊急の修正はすぐに届けます。新機能には今のバージョン以降のすべての変更がまとめて表示されます",
|
||||
"Switch to Every version": "先行版に切り替える",
|
||||
"What's new": "新機能",
|
||||
"The release notes since the last update": "前回のアップデート以降のリリースノート",
|
||||
@@ -20025,6 +20037,10 @@ const I18N = {
|
||||
"Up to date": "Aktuell",
|
||||
"Up to date on Stable": "Aktuell auf Stabil",
|
||||
"Up to date on Stable · {v} is out on Every version": "Aktuell auf Stabil · Unter Jede Version ist {v} erschienen",
|
||||
"Daily": "Täglich",
|
||||
"Up to date on Daily": "Aktuell auf Täglich",
|
||||
"Up to date on Daily · {v} is out on Every version": "Aktuell auf Täglich · Unter Jede Version ist {v} erschienen",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "Eine Version pro Tag, die neueste mit bestandenen Tests, dringende Korrekturen sofort. Neuigkeiten listet alle Änderungen seit Ihrer Version",
|
||||
"Switch to Every version": "Zu Jede Version wechseln",
|
||||
"What's new": "Neuigkeiten",
|
||||
"The release notes since the last update": "Die Versionshinweise seit dem letzten Update",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -24,6 +24,15 @@ const words = {
|
||||
de: { name: "Update-Kanal", every: "Jede Version", stable: "Stabil", auto: "Automatische Updates", off: "Aus", everySub: "Jede Version, sobald sie erscheint", stableSub: "Eine Version pro Woche" },
|
||||
};
|
||||
|
||||
// Daily (fishmagic80 on X): one a day, between the two
|
||||
const dailyWords = {
|
||||
en: { daily: "Daily", dailySub: "One version a day" },
|
||||
zh: { daily: "每日版", dailySub: "每天一个版本" },
|
||||
"zh-TW": { daily: "每日版", dailySub: "每天一個版本" },
|
||||
ja: { daily: "デイリー版", dailySub: "1 日 1 回" },
|
||||
de: { daily: "Täglich", dailySub: "Eine Version pro Tag" },
|
||||
};
|
||||
|
||||
function settingsPayload(lang, ctl) {
|
||||
const s = {
|
||||
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd",
|
||||
@@ -108,7 +117,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const rowOf = (name) => page.locator("#about .row.pref", { has: page.locator(".name", { hasText: new RegExp("^" + name + "$") }) });
|
||||
const channel = rowOf(w.name), auto = rowOf(w.auto);
|
||||
await channel.waitFor();
|
||||
assert.deepEqual((await channel.locator(".opt").allInnerTexts()).map((s) => s.trim()), [w.every, w.stable]);
|
||||
assert.deepEqual((await channel.locator(".opt").allInnerTexts()).map((s) => s.trim()), [w.every, dailyWords[lang].daily, w.stable]);
|
||||
assert.equal((await channel.locator(".opt.on").innerText()).trim(), w.every);
|
||||
await channel.locator(".sub", { hasText: w.everySub }).waitFor();
|
||||
|
||||
@@ -143,6 +152,19 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await channel.waitFor();
|
||||
assert.equal((await channel.locator(".opt.on").innerText()).trim(), w.stable);
|
||||
|
||||
// Daily
|
||||
await showRow(page, channel);
|
||||
before = await scrolls(page);
|
||||
await channel.locator(".opt", { hasText: dailyWords[lang].daily }).click();
|
||||
await channel.locator(".sub", { hasText: dailyWords[lang].dailySub }).waitFor();
|
||||
assert.equal((await channel.locator(".opt.on").innerText()).trim(), dailyWords[lang].daily);
|
||||
assert.equal(ctl.saves.at(-1).updateChannel, "daily");
|
||||
assert.equal(await scrolls(page), before, "the click must not scroll the page");
|
||||
await page.reload();
|
||||
await aboutTab();
|
||||
await channel.waitFor();
|
||||
assert.equal((await channel.locator(".opt.on").innerText()).trim(), dailyWords[lang].daily);
|
||||
|
||||
// back to every version
|
||||
await showRow(page, channel);
|
||||
before = await scrolls(page);
|
||||
|
||||
@@ -25,6 +25,15 @@ const words = {
|
||||
de: { newest: "Aktuell auf Stabil · Unter Jede Version ist 0.1.410 erschienen", stable: "Aktuell auf Stabil", every: "Aktuell", go: "Zu Jede Version wechseln" },
|
||||
};
|
||||
|
||||
// Daily's (fishmagic80 on X): the same, under its own name
|
||||
const dailyWords = {
|
||||
en: { newest: "Up to date on Daily · 0.1.410 is out on Every version", daily: "Up to date on Daily" },
|
||||
zh: { newest: "每日版已是最新 · 尝鲜版已有 0.1.410", daily: "每日版已是最新" },
|
||||
"zh-TW": { newest: "每日版已是最新 · 搶先版已有 0.1.410", daily: "每日版已是最新" },
|
||||
ja: { newest: "デイリー版では最新です · 先行版では 0.1.410 が出ています", daily: "デイリー版では最新です" },
|
||||
de: { newest: "Aktuell auf Täglich · Unter Jede Version ist 0.1.410 erschienen", daily: "Aktuell auf Täglich" },
|
||||
};
|
||||
|
||||
function settingsPayload(lang, ctl) {
|
||||
const s = {
|
||||
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd",
|
||||
@@ -59,8 +68,8 @@ function server(lang, ctl) {
|
||||
return json(settingsPayload(lang, ctl));
|
||||
}
|
||||
if (url.pathname === "/api/update") {
|
||||
if (ctl.channel !== "stable") return json({ state: "latest", current: "0.1.400", latest: "0.1.410" });
|
||||
return json({ state: "latest", current: "0.1.400", latest: "0.1.390", channel: "stable", ...(ctl.newest ? { newest: ctl.newest } : {}) });
|
||||
if (ctl.channel !== "stable" && ctl.channel !== "daily") return json({ state: "latest", current: "0.1.400", latest: "0.1.410" });
|
||||
return json({ state: "latest", current: "0.1.400", latest: "0.1.390", channel: ctl.channel, ...(ctl.newest ? { newest: ctl.newest } : {}) });
|
||||
}
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
@@ -134,6 +143,22 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await openPart(page, "about");
|
||||
await page.waitForFunction((s) => document.querySelector("#about .row.pref .sub.say")?.textContent === s, w.stable);
|
||||
assert.equal(await row.locator("button", { hasText: w.go }).count(), 0);
|
||||
|
||||
// Daily, the newest out on every version: named, and the switch
|
||||
ctl.channel = "daily";
|
||||
ctl.newest = "0.1.410";
|
||||
await page.reload();
|
||||
await settingsDrawn(page);
|
||||
await openPart(page, "about");
|
||||
await page.waitForFunction((s) => document.querySelector("#about .row.pref .sub.say")?.textContent === s, dailyWords[lang].newest);
|
||||
await row.locator("button", { hasText: w.go }).waitFor();
|
||||
// Daily with nothing newer
|
||||
ctl.newest = "";
|
||||
await page.reload();
|
||||
await settingsDrawn(page);
|
||||
await openPart(page, "about");
|
||||
await page.waitForFunction((s) => document.querySelector("#about .row.pref .sub.say")?.textContent === s, dailyWords[lang].daily);
|
||||
assert.equal(await row.locator("button", { hasText: w.go }).count(), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
+22
-17
@@ -49,12 +49,13 @@ type updater struct {
|
||||
mirror string // error: the mirror the failed download came through (#893)
|
||||
network bool // error: the network broke the download off (update.Network)
|
||||
staged string
|
||||
// stable: latest was found on Settings' Stable channel; newest, the
|
||||
// newest release on every version when that is newer than this one
|
||||
// and Stable has nothing newer (ylspcm on X)
|
||||
stable bool
|
||||
newest string
|
||||
aside string // Windows: where install moved the running exe, to put back
|
||||
// channel: the channel latest was found on, Settings' Stable or Daily
|
||||
// ("" every version); newest, the newest release on every version when
|
||||
// that is newer than this one and the channel has nothing newer
|
||||
// (ylspcm on X)
|
||||
channel string
|
||||
newest string
|
||||
aside string // Windows: where install moved the running exe, to put back
|
||||
// in a .app: its binary, where this process started from
|
||||
bundleExe string
|
||||
// a version this computer wouldn't start (Smart App Control, #894),
|
||||
@@ -134,9 +135,10 @@ type updateJSON struct {
|
||||
// row says so in the app's language instead of the raw error
|
||||
Network bool `json:"network,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
// Channel: "stable" when the answer is Settings' Stable channel's;
|
||||
// latest on it, Newest is the newest version out on every version,
|
||||
// when newer than this one: Stable's "up to date" isn't the newest
|
||||
// Channel: "stable" or "daily" when the answer is Settings' Stable or
|
||||
// Daily channel's; latest on it, Newest is the newest version out on
|
||||
// every version, when newer than this one: the channel's "up to date"
|
||||
// isn't the newest
|
||||
Channel string `json:"channel,omitempty"`
|
||||
Newest string `json:"newest,omitempty"`
|
||||
Done int64 `json:"done,omitempty"` // downloading: bytes so far
|
||||
@@ -529,15 +531,18 @@ func (u *updater) run() {
|
||||
if lang == "" {
|
||||
lang = notesLang(trayLang(s.Lang, systemLang))
|
||||
}
|
||||
stable := s.UpdateChannel == settings.UpdateStable
|
||||
channel := s.UpdateChannel
|
||||
if channel != settings.UpdateStable && channel != settings.UpdateDaily {
|
||||
channel = ""
|
||||
}
|
||||
rel, err := update.LatestIn(cctx, lang)
|
||||
// Stable has nothing newer than this one: the newest on every version
|
||||
// Stable or Daily has nothing newer than this one: the newest on every version
|
||||
// is asked too, which the version row names. A bare "Up to date" on
|
||||
// Stable, with newer releases out, read as the check being wrong, and
|
||||
// the app was installed again by hand each time (ylspcm on X). Asked
|
||||
// before u.mu, which the pages' reads need.
|
||||
newest := ""
|
||||
if stable && err == nil && !update.Newer(rel.Version, Version) {
|
||||
if channel != "" && err == nil && !update.Newer(rel.Version, Version) {
|
||||
if every, e := update.LatestEvery(cctx, lang); e == nil && update.Newer(every.Version, Version) {
|
||||
newest = every.Version
|
||||
}
|
||||
@@ -546,9 +551,9 @@ func (u *updater) run() {
|
||||
defer u.mu.Unlock()
|
||||
u.newest = newest
|
||||
if err == nil && u.latest != nil && update.Newer(u.latest.Version, rel.Version) {
|
||||
if stable != u.stable {
|
||||
if channel != u.channel {
|
||||
// an older version than the one found before, on another
|
||||
// channel: Settings' Update channel went to Stable since
|
||||
// channel: Settings' Update channel went to Stable or Daily since
|
||||
// (ssharpcc on X). What was downloaded from every version
|
||||
// isn't put in, and the version found is the feed's again, as
|
||||
// if never found.
|
||||
@@ -597,7 +602,7 @@ func (u *updater) run() {
|
||||
u.state, u.err = "error", err.Error()
|
||||
return
|
||||
}
|
||||
u.latest, u.notesIn, u.stable = rel, lang, stable
|
||||
u.latest, u.notesIn, u.channel = rel, lang, channel
|
||||
if update.Released(Version) && update.Newer(rel.Version, Version) {
|
||||
u.behind = update.NoteBehind(Version, rel.Version, update.UrgentIn(rel.Notes))
|
||||
if u.behind.Urgent == "" {
|
||||
@@ -772,8 +777,8 @@ func (u *updater) jsonIn(lang string) updateJSON {
|
||||
}
|
||||
}
|
||||
j := updateJSON{State: u.state, Current: Version, Error: u.err, Retry: u.retry}
|
||||
if u.stable && u.latest != nil {
|
||||
j.Channel = settings.UpdateStable
|
||||
if u.channel != "" && u.latest != nil {
|
||||
j.Channel = u.channel
|
||||
if u.state == "latest" {
|
||||
j.Newest = u.newest
|
||||
}
|
||||
|
||||
@@ -138,6 +138,17 @@ func TestWhatsNewKeyedByChannel(t *testing.T) {
|
||||
if got := notesKey("zh"); got != "zh|stable" {
|
||||
t.Fatalf("stable: %q", got)
|
||||
}
|
||||
s.UpdateChannel = settings.UpdateDaily
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := notesKey("zh"); got != "zh|daily" {
|
||||
t.Fatalf("daily: %q", got)
|
||||
}
|
||||
s.UpdateChannel = settings.UpdateStable
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("MAGPIE_NOTES_FEED", "http://127.0.0.1:1/") // never the real one
|
||||
oldV := Version
|
||||
Version = "0.1.100"
|
||||
@@ -241,8 +252,11 @@ func TestStableUpToDateNamesNewest(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
asked.Add(1)
|
||||
v := "0.1.13"
|
||||
if r.URL.Query().Get("channel") == "stable" {
|
||||
switch r.URL.Query().Get("channel") {
|
||||
case "stable":
|
||||
v = "0.1.11"
|
||||
case "daily":
|
||||
v = "0.1.12"
|
||||
}
|
||||
json.NewEncoder(w).Encode(update.Release{Version: v})
|
||||
}))
|
||||
@@ -283,6 +297,17 @@ func TestStableUpToDateNamesNewest(t *testing.T) {
|
||||
if j := row(); j["state"] != "latest" || j["channel"] != "stable" || j["newest"] != nil {
|
||||
t.Fatalf("stable, the newest installed: %v", j)
|
||||
}
|
||||
// Daily (fishmagic80 on X): the same, under its own name
|
||||
channel(settings.UpdateDaily)
|
||||
Version = "0.1.12"
|
||||
if j := row(); j["state"] != "latest" || j["channel"] != "daily" || j["newest"] != "0.1.13" {
|
||||
t.Fatalf("daily, 0.1.13 out: %v", j)
|
||||
}
|
||||
Version = "0.1.11"
|
||||
if j := row(); j["state"] != "available" || j["latest"] != "0.1.12" || j["channel"] != "daily" {
|
||||
t.Fatalf("daily, behind it: %v", j)
|
||||
}
|
||||
Version = "0.1.13"
|
||||
channel("")
|
||||
before := asked.Load()
|
||||
if j := row(); j["state"] != "latest" || j["channel"] != nil || j["newest"] != nil || asked.Load()-before != 1 {
|
||||
|
||||
@@ -269,8 +269,8 @@ func (n *whatsNew) get(ctx context.Context, all bool, lang string) whatsNewJSON
|
||||
// language, and the channel, whose cap on how many are shown (MostNotes)
|
||||
// differs.
|
||||
func notesKey(lang string) string {
|
||||
if update.Stable() {
|
||||
return lang + "|" + settings.UpdateStable
|
||||
if ch := update.Channel(); ch != "" {
|
||||
return lang + "|" + ch
|
||||
}
|
||||
return lang
|
||||
}
|
||||
|
||||
@@ -598,7 +598,9 @@ type Settings struct {
|
||||
// version as it comes out, the default; UpdateStable ("stable") one a
|
||||
// week, the newest that had been out three days as the week began, or
|
||||
// an urgent one (a security hole, a ban risk, lost data) at once, from
|
||||
// the update feed's ?channel=stable (ssharpcc on X). Settings' Update
|
||||
// the update feed's ?channel=stable (ssharpcc on X); UpdateDaily
|
||||
// ("daily") one a day, the newest that passed its tests, or an urgent
|
||||
// one at once, from ?channel=daily (fishmagic80 on X). Settings' Update
|
||||
// channel and magpie update channel set it.
|
||||
UpdateChannel string `json:"updateChannel,omitempty"`
|
||||
// Vision is the model that describes an image to a model that can't see
|
||||
@@ -1374,6 +1376,10 @@ const AnyProvider = "*/"
|
||||
// at once.
|
||||
const UpdateStable = "stable"
|
||||
|
||||
// UpdateDaily is UpdateChannel's Daily: a version a day, the newest that
|
||||
// passed its tests and has all its files, an urgent one at once.
|
||||
const UpdateDaily = "daily"
|
||||
|
||||
// The values of Settings.UpdateSource; "" is automatic.
|
||||
const (
|
||||
UpdateSourceSite = "site"
|
||||
@@ -1575,8 +1581,9 @@ var (
|
||||
Warmups = []string{"", "week", "all"}
|
||||
// TrayEvery are TrayUsageEvery's values, in minutes.
|
||||
TrayEvery = []int{1, 3, 5, 10, 30}
|
||||
// UpdateChannels are UpdateChannel's values: every version, Stable.
|
||||
UpdateChannels = []string{"", UpdateStable}
|
||||
// UpdateChannels are UpdateChannel's values: every version, Daily,
|
||||
// Stable.
|
||||
UpdateChannels = []string{"", UpdateDaily, UpdateStable}
|
||||
// UpdateEveries are UpdateEvery's values, in minutes.
|
||||
UpdateEveries = []int{30, 60, 360, 1440}
|
||||
// TextSizes are TextSize's values, in percent. None is under 100: the
|
||||
@@ -2603,7 +2610,7 @@ func saveOwn(s Settings, recording, reads bool) error {
|
||||
return fmt.Errorf("magpie checks for updates every %v minutes, not %d", UpdateEveries, s.UpdateEvery)
|
||||
}
|
||||
if !slices.Contains(UpdateChannels, s.UpdateChannel) {
|
||||
return fmt.Errorf("the update channel is %q (stable) or empty (every version), not %q", UpdateStable, s.UpdateChannel)
|
||||
return fmt.Errorf("the update channel is %q, %q or empty (every version), not %q", UpdateStable, UpdateDaily, s.UpdateChannel)
|
||||
}
|
||||
if m := s.UpdateMirror; m != "" {
|
||||
if u, err := url.Parse(m); err != nil || (u.Scheme != "https" && u.Scheme != "http") || u.Host == "" {
|
||||
|
||||
@@ -69,7 +69,7 @@ var Choices = map[string][]string{
|
||||
"claudeWarmup": {"off", "week", "all"},
|
||||
"trayUsageEvery": ints(settings.TrayEvery),
|
||||
"dayStart": {"0", "1", "2", "3", "4", "5", "6"},
|
||||
"updateChannel": {settings.UpdateStable},
|
||||
"updateChannel": {settings.UpdateStable, settings.UpdateDaily},
|
||||
"updateSource": {settings.UpdateSourceSite, settings.UpdateSourceGitHub},
|
||||
"updateEvery": ints(settings.UpdateEveries),
|
||||
"searchFirst": {settings.SearchFirstModel, settings.SearchFirstAPI},
|
||||
|
||||
@@ -25,8 +25,8 @@ func stableFor(t *testing.T, channel string) {
|
||||
t.Cleanup(func() { settings.Save(before) })
|
||||
}
|
||||
|
||||
// The Stable channel (ssharpcc on X): the feed is asked with
|
||||
// channel=stable, and only then; every version asks it as before. The
|
||||
// The Stable channel (ssharpcc on X) and Daily (fishmagic80 on X): the
|
||||
// feed is asked with channel=stable or channel=daily, and only then; every version asks it as before. The
|
||||
// language goes with it either way.
|
||||
func TestLatestAsksTheChannel(t *testing.T) {
|
||||
var (
|
||||
@@ -38,8 +38,11 @@ func TestLatestAsksTheChannel(t *testing.T) {
|
||||
asked = append(asked, r.URL.RawQuery)
|
||||
mu.Unlock()
|
||||
v := "0.1.1600"
|
||||
if r.URL.Query().Get("channel") == "stable" {
|
||||
switch r.URL.Query().Get("channel") {
|
||||
case "stable":
|
||||
v = "0.1.1550"
|
||||
case "daily":
|
||||
v = "0.1.1590"
|
||||
}
|
||||
json.NewEncoder(w).Encode(Release{Version: v})
|
||||
}))
|
||||
@@ -52,6 +55,8 @@ func TestLatestAsksTheChannel(t *testing.T) {
|
||||
{"", "", "", "0.1.1600"},
|
||||
{settings.UpdateStable, "zh", "channel=stable&lang=zh", "0.1.1550"},
|
||||
{settings.UpdateStable, "", "channel=stable", "0.1.1550"},
|
||||
{settings.UpdateDaily, "ja", "channel=daily&lang=ja", "0.1.1590"},
|
||||
{settings.UpdateDaily, "", "channel=daily", "0.1.1590"},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("%q %q", c.channel, c.lang), func(t *testing.T) {
|
||||
stableFor(t, c.channel)
|
||||
@@ -93,16 +98,55 @@ func TestStableNotesAreAll(t *testing.T) {
|
||||
if MostNotes() != StableMaxNotes {
|
||||
t.Fatalf("MostNotes on stable: %d", MostNotes())
|
||||
}
|
||||
// Daily's update is a day of releases, read as one list too
|
||||
stableFor(t, settings.UpdateDaily)
|
||||
if got := Between(notes, "0.1.1000", "0.1.1120"); len(got) != 120 || MostNotes() != StableMaxNotes {
|
||||
t.Fatalf("daily: %d notes, MostNotes %d", len(got), MostNotes())
|
||||
}
|
||||
}
|
||||
|
||||
// Settings take "stable" or nothing; anything else is refused, and the
|
||||
// Daily's release, like Stable's, is one only the site knows: a failed
|
||||
// feed doesn't go on to GitHub's newest, and GitHub only doesn't skip the
|
||||
// feed, either of which would hand the newest release to someone who chose
|
||||
// one a day.
|
||||
func TestDailyStaysOnTheFeed(t *testing.T) {
|
||||
t.Setenv("MAGPIE_UPDATE_FEED", "")
|
||||
for _, c := range []struct {
|
||||
channel string
|
||||
picked bool
|
||||
}{{"", false}, {settings.UpdateDaily, true}, {settings.UpdateStable, true}} {
|
||||
stableFor(t, c.channel)
|
||||
if Picked() != c.picked || Channel() != c.channel {
|
||||
t.Fatalf("%q: Picked %v, Channel %q", c.channel, Picked(), Channel())
|
||||
}
|
||||
if fallsBack(context.Background()) == c.picked {
|
||||
t.Errorf("%q: fallsBack %v", c.channel, !c.picked)
|
||||
}
|
||||
}
|
||||
stableFor(t, settings.UpdateDaily)
|
||||
s := settings.Load()
|
||||
s.UpdateSource = settings.UpdateSourceGitHub
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if githubOnly() {
|
||||
t.Error("GitHub only skipped Daily's feed")
|
||||
}
|
||||
}
|
||||
|
||||
// Settings take "stable", "daily" or nothing; anything else is refused, and the
|
||||
// value is kept as saved.
|
||||
func TestUpdateChannelSaved(t *testing.T) {
|
||||
stableFor(t, settings.UpdateStable)
|
||||
if got := settings.Load().UpdateChannel; got != "stable" || !Stable() {
|
||||
t.Fatalf("saved stable, read %q", got)
|
||||
}
|
||||
for _, bad := range []string{"Stable", "beta", "every", " stable"} {
|
||||
stableFor(t, settings.UpdateDaily)
|
||||
if got := settings.Load().UpdateChannel; got != "daily" || Stable() || Channel() != "daily" {
|
||||
t.Fatalf("saved daily, read %q", got)
|
||||
}
|
||||
stableFor(t, settings.UpdateStable)
|
||||
for _, bad := range []string{"Stable", "beta", "every", " stable", "Daily", "weekly"} {
|
||||
s := settings.Load()
|
||||
s.UpdateChannel = bad
|
||||
if err := settings.Save(s); err == nil {
|
||||
|
||||
@@ -44,17 +44,17 @@ var siteFeed = Site + "/api/latest"
|
||||
const maxSmall = 1 << 20
|
||||
|
||||
// fallsBack says whether a failed feed goes on to GitHub: the default
|
||||
// feed, not the Stable channel, and not an ask already cancelled.
|
||||
// feed, not the Stable or Daily channel, and not an ask already cancelled.
|
||||
func fallsBack(ctx context.Context) bool {
|
||||
return ctx.Err() == nil && Feed() == siteFeed && !Stable() && Source() == ""
|
||||
return ctx.Err() == nil && Feed() == siteFeed && !Picked() && Source() == ""
|
||||
}
|
||||
|
||||
// githubOnly says whether the release is read from GitHub alone, with no
|
||||
// try at the feed: Settings' GitHub only, on the default feed and not on
|
||||
// Stable (whose release only the site knows; its files still come from
|
||||
// GitHub).
|
||||
// Stable or Daily (whose release only the site knows; its files still come
|
||||
// from GitHub).
|
||||
func githubOnly() bool {
|
||||
return Feed() == siteFeed && !Stable() && Source() == settings.UpdateSourceGitHub
|
||||
return Feed() == siteFeed && !Picked() && Source() == settings.UpdateSourceGitHub
|
||||
}
|
||||
|
||||
// githubLatest is the newest release as GitHub gives it, verified.
|
||||
|
||||
+32
-14
@@ -149,32 +149,50 @@ func withLang(feed, lang string) string {
|
||||
// often, and a long-unopened one would have pages of them.
|
||||
const MaxNotes = 40
|
||||
|
||||
// StableMaxNotes is MaxNotes on the Stable channel, where an update is a
|
||||
// week of releases and its notes are read as one list (ssharpcc on X):
|
||||
// every one of them, as far as the site keeps them.
|
||||
// StableMaxNotes is MaxNotes on the Stable and Daily channels, where an
|
||||
// update is a week or a day of releases and its notes are read as one list
|
||||
// (ssharpcc on X): every one of them, as far as the site keeps them.
|
||||
const StableMaxNotes = 1500
|
||||
|
||||
// MostNotes is how many releases' notes are shown at most on the channel
|
||||
// Settings name.
|
||||
func MostNotes() int {
|
||||
if Stable() {
|
||||
if Picked() {
|
||||
return StableMaxNotes
|
||||
}
|
||||
return MaxNotes
|
||||
}
|
||||
|
||||
// Stable is whether Settings' Update channel is Stable: the update feed is
|
||||
// asked for a version a week, the newest that had been out three days as
|
||||
// the week began (Monday 00:00 UTC), or an urgent one (a security hole, a
|
||||
// ban risk, lost data) as soon as it is out. usemagpie.ai chooses it from
|
||||
// the release list (site/worker.js, "The Stable channel"); a release is
|
||||
// urgent when a line of its notes starts with "**Urgent release:**".
|
||||
func Stable() bool { return settings.Shared().UpdateChannel == settings.UpdateStable }
|
||||
// Channel is Settings' Update channel: settings.UpdateStable, the update
|
||||
// feed asked for a version a week, the newest that had been out three days
|
||||
// as the week began (Monday 00:00 UTC); settings.UpdateDaily, a version a
|
||||
// day, the newest out by 20:00 UTC that passed its tests (the Test run on
|
||||
// its commit) and has every file; either one with an urgent release (a
|
||||
// security hole, a ban risk, lost data) as soon as it is out. "" is every
|
||||
// version, and so is a value magpie doesn't know. usemagpie.ai chooses
|
||||
// both from the release list (site/worker.js, "The Stable channel" and
|
||||
// "The Daily channel"); a release is urgent when a line of its notes
|
||||
// starts with "**Urgent release:**".
|
||||
func Channel() string {
|
||||
switch c := settings.Shared().UpdateChannel; c {
|
||||
case settings.UpdateStable, settings.UpdateDaily:
|
||||
return c
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// withChannel is feed asking for Stable's release on the Stable channel,
|
||||
// Picked is whether the update feed picks the version (Stable or Daily)
|
||||
// rather than offering every one: only the site knows a picked release.
|
||||
func Picked() bool { return Channel() != "" }
|
||||
|
||||
// Stable is whether Settings' Update channel is Stable.
|
||||
func Stable() bool { return Channel() == settings.UpdateStable }
|
||||
|
||||
// withChannel is feed asking for the channel's release on Stable or Daily,
|
||||
// and feed as it is on every version.
|
||||
func withChannel(feed string) string {
|
||||
if !Stable() {
|
||||
ch := Channel()
|
||||
if ch == "" {
|
||||
return feed
|
||||
}
|
||||
u, err := url.Parse(feed)
|
||||
@@ -182,7 +200,7 @@ func withChannel(feed string) string {
|
||||
return feed
|
||||
}
|
||||
q := u.Query()
|
||||
q.Set("channel", settings.UpdateStable)
|
||||
q.Set("channel", ch)
|
||||
u.RawQuery = q.Encode()
|
||||
return u.String()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
// node --test site/: the Daily update channel (fishmagic80 on X) is picked
|
||||
// once a day from the release ledger: the newest release out by 20:00 UTC
|
||||
// with all its files and a green CI run of its own. GitHub, the edge cache
|
||||
// and KV are stood in for; every clock is held.
|
||||
import { test, beforeEach } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import worker, { dayCut, dailyOf, keepDaily, keepLedger, RELEASE_FILES, URGENT_MARK } from "./worker.js";
|
||||
|
||||
const DAY = 86400e3;
|
||||
const HOUR = 3600e3;
|
||||
const at = (iso) => Date.parse(iso);
|
||||
const iso = (ms) => new Date(ms).toISOString();
|
||||
|
||||
test("dayCut: the 20:00 UTC on or before", () => {
|
||||
assert.equal(iso(dayCut(at("2026-11-15T21:00:00Z"))), "2026-11-15T20:00:00.000Z");
|
||||
assert.equal(iso(dayCut(at("2026-11-15T20:00:00Z"))), "2026-11-15T20:00:00.000Z");
|
||||
assert.equal(iso(dayCut(at("2026-11-15T19:59:59Z"))), "2026-11-14T20:00:00.000Z");
|
||||
assert.equal(iso(dayCut(at("2027-01-01T03:00:00Z"))), "2026-12-31T20:00:00.000Z");
|
||||
});
|
||||
|
||||
test("dailyOf: the newest out by the cut with every file and a green run", () => {
|
||||
const cut = at("2026-11-15T20:00:00Z");
|
||||
const r = (version, published, files, green) => ({ version, published, files, green });
|
||||
const list = [
|
||||
r("0.1.9", "2026-11-15T20:00:01Z", 17, true), // after the cut
|
||||
r("0.1.8", "2026-11-15T19:00:00Z", 17, false), // red or no run
|
||||
r("0.1.7", "2026-11-15T18:00:00Z", 16, true), // a file short
|
||||
r("0.1.6", "2026-11-15T17:00:00Z", 17, true),
|
||||
r("0.1.5", "2026-11-15T16:00:00Z", 17, true),
|
||||
];
|
||||
assert.equal(RELEASE_FILES, 17);
|
||||
assert.equal(dailyOf(list, cut).version, "0.1.6");
|
||||
assert.equal(dailyOf([...list].reverse(), cut).version, "0.1.6");
|
||||
assert.equal(dailyOf(list.slice(0, 3), cut), null);
|
||||
assert.equal(dailyOf([r("0.1.10", null, 17, true)], cut), null);
|
||||
});
|
||||
|
||||
// --- the cron and the feed ---
|
||||
|
||||
function kv() {
|
||||
const m = new Map();
|
||||
const ns = {
|
||||
m,
|
||||
broken: false,
|
||||
async get(key, opts = {}) {
|
||||
if (ns.broken) throw new Error("kv down");
|
||||
const v = m.has(key) ? m.get(key) : null;
|
||||
return v !== null && (opts.type === "json" || opts === "json") ? JSON.parse(v) : v;
|
||||
},
|
||||
async put(key, v) {
|
||||
m.set(key, String(v));
|
||||
},
|
||||
};
|
||||
return ns;
|
||||
}
|
||||
|
||||
// GITHUB is magpie-releases' list, newest first: {version, published,
|
||||
// notes, files}. SHAS is each tag's commit in yetone/magpie, GREEN the
|
||||
// commits the Test workflow passed. srcDown makes yetone/magpie's API fail.
|
||||
let GITHUB = [], SHAS = {}, GREEN = [], srcDown = false, srcAsks = [];
|
||||
const store = new Map();
|
||||
globalThis.caches = {
|
||||
default: {
|
||||
match: async (req) => (store.has(req.url) ? new Response(store.get(req.url)) : undefined),
|
||||
put: async (req, res) => void store.set(req.url, await res.text()),
|
||||
},
|
||||
};
|
||||
const names = Array.from({ length: RELEASE_FILES }, (_, i) => (i ? `magpie-file-${i}` : "magpie-linux-amd64"));
|
||||
const gh = (r) => ({
|
||||
tag_name: "v" + r.version,
|
||||
body: r.notes || "",
|
||||
html_url: "https://github.com/r/v" + r.version,
|
||||
published_at: r.published,
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: names.slice(0, r.files ?? RELEASE_FILES).map((name) => ({ name, size: 7, browser_download_url: `https://dl/${r.version}/${name}` })),
|
||||
});
|
||||
globalThis.fetch = async (u) => {
|
||||
u = String(u);
|
||||
if (u.startsWith("https://api.github.com/repos/yetone/magpie-releases/")) {
|
||||
const path = u.split("/repos/yetone/magpie-releases/")[1];
|
||||
const tag = path.match(/^releases\/tags\/v(.+)$/);
|
||||
if (tag) {
|
||||
const r = GITHUB.find((r) => r.version === tag[1]);
|
||||
return r ? Response.json(gh(r)) : new Response("{}", { status: 404 });
|
||||
}
|
||||
if (path === "releases/latest") return Response.json(gh(GITHUB[0]));
|
||||
const page = path.match(/^releases\?per_page=100(?:&page=(\d+))?$/);
|
||||
if (page) {
|
||||
const n = +(page[1] || 1);
|
||||
return Response.json(GITHUB.slice((n - 1) * 100, n * 100).map(gh));
|
||||
}
|
||||
}
|
||||
if (u.startsWith("https://api.github.com/repos/yetone/magpie/")) {
|
||||
const path = u.split("/repos/yetone/magpie/")[1];
|
||||
srcAsks.push(path);
|
||||
if (srcDown) return new Response('{"message":"API rate limit exceeded"}', { status: 403 });
|
||||
if (path.startsWith("actions/workflows/test.yml/runs?")) {
|
||||
assert.match(path, /branch=main/);
|
||||
assert.match(path, /status=success/);
|
||||
return Response.json({ workflow_runs: GREEN.map((head_sha) => ({ head_sha, conclusion: "success" })) });
|
||||
}
|
||||
const refs = path.match(/^git\/matching-refs\/tags\/v(.+)$/);
|
||||
if (refs)
|
||||
return Response.json(
|
||||
Object.entries(SHAS)
|
||||
.filter(([v]) => v.startsWith(refs[1]))
|
||||
.map(([v, sha]) => ({ ref: "refs/tags/v" + v, object: { sha, type: "commit" } })),
|
||||
);
|
||||
}
|
||||
const sums = u.match(/\/releases\/download\/v([^/]+)\/SHA256SUMS$/);
|
||||
if (sums && GITHUB.some((r) => r.version === sums[1])) return new Response(`sum${sums[1]} magpie-linux-amd64\n`);
|
||||
return new Response("not found", { status: 404 });
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
store.clear();
|
||||
srcDown = false;
|
||||
srcAsks = [];
|
||||
});
|
||||
|
||||
// a day of releases, one an hour up to now: 0.1.(n) newest
|
||||
function day(n, newest) {
|
||||
GITHUB = Array.from({ length: n }, (_, i) => ({ version: `0.1.${n - i}`, published: iso(newest - i * HOUR), notes: `- change 0.1.${n - i}` }));
|
||||
SHAS = Object.fromEntries(GITHUB.map((r) => [r.version, "sha" + r.version]));
|
||||
}
|
||||
|
||||
test("keepDaily: once a cut, the newest out by it with all files and its own green run", async () => {
|
||||
const NOW = at("2026-11-15T20:05:00Z"); // just past the cut
|
||||
day(30, NOW); // 0.1.30 out at 20:05, 0.1.29 at 19:05, ...
|
||||
GITHUB.find((r) => r.version === "0.1.28").files = 16; // a file short
|
||||
GREEN = ["sha0.1.28", "sha0.1.26", "sha0.1.25", "sha0.1.30"]; // 0.1.30 is after the cut
|
||||
const env = { LEDGER: kv() };
|
||||
await keepLedger(env, NOW);
|
||||
await keepDaily(env, NOW);
|
||||
let d = JSON.parse(env.LEDGER.m.get("daily"));
|
||||
assert.equal(d.v, "0.1.26");
|
||||
assert.equal(d.cut, "2026-11-15T20:00:00.000Z");
|
||||
|
||||
// later the same day: nothing asked, nothing moves, however green
|
||||
srcAsks = [];
|
||||
GREEN = [...GREEN, "sha0.1.29"];
|
||||
await keepDaily(env, NOW + 3 * HOUR);
|
||||
assert.deepEqual(srcAsks, []);
|
||||
assert.equal(JSON.parse(env.LEDGER.m.get("daily")).v, "0.1.26");
|
||||
|
||||
// the next cut: the newest by then
|
||||
day(54, NOW + 24 * HOUR - 5 * 60e3); // 0.1.54 out at 19:00 the next day
|
||||
GREEN = ["sha0.1.29", "sha0.1.52"];
|
||||
await keepLedger(env, NOW + DAY);
|
||||
await keepDaily(env, NOW + DAY);
|
||||
d = JSON.parse(env.LEDGER.m.get("daily"));
|
||||
assert.equal(d.v, "0.1.52");
|
||||
assert.equal(d.cut, "2026-11-16T20:00:00.000Z");
|
||||
});
|
||||
|
||||
test("keepDaily: nothing green in reach keeps the last pick; GitHub failing writes nothing", async () => {
|
||||
const NOW = at("2026-11-15T20:05:00Z");
|
||||
day(30, NOW);
|
||||
GREEN = ["sha0.1.20"];
|
||||
const env = { LEDGER: kv() };
|
||||
await keepLedger(env, NOW);
|
||||
await keepDaily(env, NOW);
|
||||
assert.equal(JSON.parse(env.LEDGER.m.get("daily")).v, "0.1.20");
|
||||
|
||||
// a day with no green run: Daily stays, never goes back
|
||||
day(54, NOW + DAY);
|
||||
GREEN = ["sha0.1.10"];
|
||||
await keepLedger(env, NOW + DAY);
|
||||
await keepDaily(env, NOW + DAY);
|
||||
let d = JSON.parse(env.LEDGER.m.get("daily"));
|
||||
assert.equal(d.v, "0.1.20");
|
||||
assert.equal(d.cut, "2026-11-16T20:00:00.000Z");
|
||||
|
||||
// GitHub says no: nothing written, the next run tries again
|
||||
srcDown = true;
|
||||
await keepDaily(env, NOW + 2 * DAY);
|
||||
assert.equal(JSON.parse(env.LEDGER.m.get("daily")).cut, "2026-11-16T20:00:00.000Z");
|
||||
srcDown = false;
|
||||
GREEN = ["sha0.1.40"];
|
||||
await keepDaily(env, NOW + 2 * DAY);
|
||||
d = JSON.parse(env.LEDGER.m.get("daily"));
|
||||
assert.equal(d.v, "0.1.40");
|
||||
assert.equal(d.cut, "2026-11-17T20:00:00.000Z");
|
||||
|
||||
// a ledger that can't be read: nothing written
|
||||
env.LEDGER.broken = true;
|
||||
await keepDaily(env, NOW + 3 * DAY);
|
||||
env.LEDGER.broken = false;
|
||||
assert.equal(JSON.parse(env.LEDGER.m.get("daily")).v, "0.1.40");
|
||||
});
|
||||
|
||||
test("keepDaily: tags are asked ten at a time, a bounded number of asks", async () => {
|
||||
const NOW = at("2026-11-15T20:05:00Z");
|
||||
day(200, NOW);
|
||||
GREEN = []; // nothing green: it looks as far as it may
|
||||
const env = { LEDGER: kv() };
|
||||
await keepLedger(env, NOW);
|
||||
await keepDaily(env, NOW);
|
||||
const tagAsks = srcAsks.filter((p) => p.startsWith("git/"));
|
||||
assert.ok(tagAsks.length <= 6, tagAsks.join(" "));
|
||||
assert.equal(env.LEDGER.m.get("daily"), undefined); // never known: no pick
|
||||
});
|
||||
|
||||
const ctx = { waitUntil: (p) => p };
|
||||
const ask = async (path, env) => {
|
||||
const res = await worker.fetch(new Request("https://usemagpie.ai" + path), env, ctx);
|
||||
return { status: res.status, body: await res.json(), cache: res.headers.get("Cache-Control") };
|
||||
};
|
||||
|
||||
test("latest?channel=daily: the day's pick, an urgent release at once; 503 until a pick", async () => {
|
||||
const now = Date.now();
|
||||
GITHUB = [
|
||||
{ version: "0.1.4", published: iso(now), notes: "- newest" },
|
||||
{ version: "0.1.3", published: iso(now - 2 * DAY), notes: "- daily one\n\n<!-- lang:zh -->\n\n- 每日的" },
|
||||
{ version: "0.1.2", published: iso(now - 3 * DAY), notes: "- old" },
|
||||
];
|
||||
SHAS = { "0.1.4": "a4", "0.1.3": "a3", "0.1.2": "a2" };
|
||||
GREEN = ["a3", "a2"]; // 0.1.4's run hasn't finished
|
||||
const env = { LEDGER: kv() };
|
||||
await keepLedger(env, now);
|
||||
// before the cron has picked: unknown, never kept
|
||||
let got = await ask("/api/latest?channel=daily", env);
|
||||
assert.equal(got.status, 503);
|
||||
assert.equal(got.cache, "no-store");
|
||||
assert.equal((await ask("/api/latest?channel=daily", {})).status, 503);
|
||||
|
||||
await keepDaily(env, now);
|
||||
got = await ask("/api/latest?channel=daily", env);
|
||||
assert.equal(got.status, 200);
|
||||
assert.equal(got.body.version, "0.1.3");
|
||||
assert.equal(got.body.channel, "daily");
|
||||
assert.equal(got.body.urgent, false);
|
||||
assert.equal(got.body.notes, "- daily one");
|
||||
assert.equal((await ask("/api/latest?channel=daily&lang=zh", env)).body.notes, "- 每日的");
|
||||
// every version is as it was
|
||||
assert.equal((await ask("/api/latest", env)).body.version, "0.1.4");
|
||||
|
||||
// an urgent release is Daily at once
|
||||
GITHUB = [{ version: "0.1.5", published: iso(now), notes: `${URGENT_MARK} a ban risk\n\n- fix` }, ...GITHUB];
|
||||
await keepLedger(env, now);
|
||||
store.clear();
|
||||
got = await ask("/api/latest?channel=daily", env);
|
||||
assert.equal(got.body.version, "0.1.5");
|
||||
assert.equal(got.body.urgent, true);
|
||||
|
||||
// /download/daily follows it; /download stays the newest
|
||||
store.clear();
|
||||
const res = await worker.fetch(new Request("https://usemagpie.ai/download/daily/linux"), env, ctx);
|
||||
assert.equal(res.status, 302);
|
||||
assert.match(res.headers.get("Location"), /0\.1\.5/);
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
// node --test site/: the Docker image's tags the docs name are tags a
|
||||
// workflow writes. magpie releases many times a day, and a Renovate user
|
||||
// had a PR for each one (YaoFur on X): daily moves once a day, by
|
||||
// .github/workflows/docker-daily.yml, and is in the docs in every language.
|
||||
// had a PR for each one (YaoFur on X): daily is the Daily channel's
|
||||
// release, moved once a day by .github/workflows/docker-daily.yml, and is
|
||||
// in the docs in every language.
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
@@ -34,13 +35,13 @@ test("every tag the docs name is one a workflow writes", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("daily moves once a day, to latest's image, without a build", () => {
|
||||
test("daily follows the Daily channel's feed, without a build", () => {
|
||||
const y = read("../.github/workflows/docker-daily.yml");
|
||||
const crons = [...y.matchAll(/cron:\s*'([^']+)'/g)].map((m) => m[1]);
|
||||
assert.equal(crons.length, 1, "one schedule");
|
||||
const [min, hour, dom, mon, dow] = crons[0].split(/\s+/);
|
||||
assert.ok(/^\d+$/.test(min) && /^\d+$/.test(hour) && dom === "*" && mon === "*" && dow === "*", "once a day: " + crons[0]);
|
||||
assert.match(y, /imagetools create -t "\$IMAGE:daily" "\$IMAGE:latest"/);
|
||||
// the feed moves once a day (site/worker.js's keepDaily); the workflow
|
||||
// only copies the image it names, by version
|
||||
assert.match(y, /FEED: https:\/\/usemagpie\.ai\/api\/latest\?channel=daily/);
|
||||
assert.match(y, /imagetools create -t "\$IMAGE:daily" "\$IMAGE:\$V"/);
|
||||
assert.doesNotMatch(y, /\$IMAGE:latest/);
|
||||
assert.doesNotMatch(y, /build-push-action|docker (buildx )?build\s/);
|
||||
assert.doesNotMatch(y, /workflow_run|push:|tags:/, "only the clock (and a click) moves it");
|
||||
assert.doesNotMatch(y, /push:|tags:/, "never a push of its own");
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
<div class="table-wrap"><table>
|
||||
<tr><td><b>Image</b></td><td><code>ghcr.io/yetone/magpie</code>, for <code>linux/amd64</code> and <code>linux/arm64</code></td></tr>
|
||||
<tr><td><b>Tags</b></td><td><code>latest</code> (the newest release), <code>daily</code> (the newest release as of 20:00 UTC, moved once a day), <code>stable</code> (the desktop app's Stable channel: a release a week, out three days first, or an urgent one at once), <code>0.1.1150</code> (one release), <code>0.1</code>, <code>edge</code> (every change on <code>main</code>)</td></tr>
|
||||
<tr><td><b>Tags</b></td><td><code>latest</code> (the newest release), <code>daily</code> (the desktop app's Daily channel: once a day at 20:00 UTC, the newest release whose CI run passed, or an urgent one at once), <code>stable</code> (the desktop app's Stable channel: a release a week, out three days first, or an urgent one at once), <code>0.1.1150</code> (one release), <code>0.1</code>, <code>edge</code> (every change on <code>main</code>)</td></tr>
|
||||
<tr><td><b>Ports</b></td><td><code>3425</code> the gateway agents call; <code>3430</code> the browser UI, when the container runs <code>magpie web</code>; it answers the gateway’s <code>/v1</code> routes too, so a reverse proxy needs only this port</td></tr>
|
||||
<tr><td><b>Volume</b></td><td><code>/config</code>: providers, keys, sign-ins, plugins and usage</td></tr>
|
||||
<tr><td><b>User</b></td><td>nonroot (uid 65532)</td></tr>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
<div class="table-wrap"><table>
|
||||
<tr><td><b>イメージ</b></td><td><code>ghcr.io/yetone/magpie</code>(<code>linux/amd64</code> と <code>linux/arm64</code>)</td></tr>
|
||||
<tr><td><b>タグ</b></td><td><code>latest</code>(最新リリース)、<code>daily</code>(毎日 20:00 UTC にその時点の最新リリースへ移る。1 日 1 回だけ)、<code>stable</code>(デスクトップ版の Stable チャンネルと同じ:公開から 3 日たったリリースが週に 1 つ、緊急リリースはすぐ)、<code>0.1.1150</code>(特定のリリース)、<code>0.1</code>、<code>edge</code>(<code>main</code> の変更ごと)</td></tr>
|
||||
<tr><td><b>タグ</b></td><td><code>latest</code>(最新リリース)、<code>daily</code>(デスクトップ版の Daily チャンネルと同じ:毎日 20:00 UTC に、その時点で CI に通った最新リリースへ移る。1 日 1 回だけ、緊急リリースはすぐ)、<code>stable</code>(デスクトップ版の Stable チャンネルと同じ:公開から 3 日たったリリースが週に 1 つ、緊急リリースはすぐ)、<code>0.1.1150</code>(特定のリリース)、<code>0.1</code>、<code>edge</code>(<code>main</code> の変更ごと)</td></tr>
|
||||
<tr><td><b>ポート</b></td><td><code>3425</code> はエージェントが呼ぶゲートウェイ、<code>3430</code> はコンテナが <code>magpie web</code> を動かすときのブラウザ UI。ゲートウェイの <code>/v1</code> ルートにも応えるので、リバースプロキシはこのポートだけで足ります</td></tr>
|
||||
<tr><td><b>ボリューム</b></td><td><code>/config</code>:プロバイダ、キー、サインイン、プラグイン、使用量</td></tr>
|
||||
<tr><td><b>ユーザー</b></td><td>nonroot(uid 65532)</td></tr>
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
<h2 id="site"><a class="anchor" href="#site">usemagpie.ai に見えるもの</a></h2>
|
||||
<p>magpie はプライバシー設定にかかわらず、どのアプリも自分の更新サーバーに尋ねるのと同じように、自分のサイトにいくつか尋ねます。どのリクエストにもインストール ID やアカウントは付きません。</p>
|
||||
<ul>
|
||||
<li><code>/api/latest</code>:更新情報。<code>noAutoUpdate</code> がオンでなければ 6 時間ごと。<code>?lang=</code> であなたの言語のノートを取ります。<span class="ui">設定</span> → <span class="ui">情報</span> → <span class="ui">アップデートチャネル</span>が安定版なら <code>?channel=stable</code> も付けます。新しくインストールした magpie も一度 <code>?channel=stable</code> を尋ね、自分が安定版なら安定版にとどまります。どちらもあなたが誰かは含みません。<code>/api/notes</code> は更新後の「新機能」です。</li>
|
||||
<li><code>/api/latest</code>:更新情報。<code>noAutoUpdate</code> がオンでなければ 6 時間ごと。<code>?lang=</code> であなたの言語のノートを取ります。<span class="ui">設定</span> → <span class="ui">情報</span> → <span class="ui">アップデートチャネル</span>が安定版かデイリーなら <code>?channel=stable</code> か <code>?channel=daily</code> も付けます。新しくインストールした magpie も一度 <code>?channel=stable</code> を尋ね、自分が安定版なら安定版にとどまります。どちらもあなたが誰かは含みません。<code>/api/notes</code> は更新後の「新機能」です。</li>
|
||||
<li><code>/files/<バージョン>/<ファイル></code>:更新とインストーラがダウンロードするリリースファイルで、Cloudflare R2 から配信されます。サイトにないファイルは github.com へ転送されます。何も計測しません。</li>
|
||||
<li><code>/api/partners</code>:プロバイダー追加シートのパートナー一覧。6 時間ごと。パートナーが載っている間、10 回に 1 回の取得を Cloudflare が示す国とともに <code>magpie partners fetch</code> として数えます。</li>
|
||||
<li><code>/go/<パートナー>/site</code> と <code>/go/<パートナー>/keys</code>:パートナーの公式サイトとキーのページへのリンクをブラウザーで開くと、移動の前に <code>magpie partner go</code>(どのパートナーか、どのリンクか、地域、国)として数えます。</li>
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
<h2 id="site"><a class="anchor" href="#site">What usemagpie.ai sees</a></h2>
|
||||
<p>magpie asks its own site for a few things, whatever the privacy settings say, as any app asks its update server. None of these requests carries the install id or an account.</p>
|
||||
<ul>
|
||||
<li><code>/api/latest</code>: the update feed, every 6 hours unless <code>noAutoUpdate</code> is on, with <code>?lang=</code> for the notes in your language, and <code>?channel=stable</code> when <span class="ui">Settings</span> → <span class="ui">About</span> → <span class="ui">Update channel</span> is Stable; a fresh install asks <code>?channel=stable</code> once too, to stay on Stable when it is Stable’s version. Neither says who you are. <code>/api/notes</code> gives What’s new after an update.</li>
|
||||
<li><code>/api/latest</code>: the update feed, every 6 hours unless <code>noAutoUpdate</code> is on, with <code>?lang=</code> for the notes in your language, and <code>?channel=stable</code> or <code>?channel=daily</code> when <span class="ui">Settings</span> → <span class="ui">About</span> → <span class="ui">Update channel</span> is Stable or Daily; a fresh install asks <code>?channel=stable</code> once too, to stay on Stable when it is Stable’s version. Neither says who you are. <code>/api/notes</code> gives What’s new after an update.</li>
|
||||
<li><code>/files/<version>/<file></code>: the release files an update and the installer download, served from Cloudflare R2. A file the site doesn’t hold is sent on to github.com. Nothing is counted.</li>
|
||||
<li><code>/api/partners</code>: the add sheet’s partner list, every 6 hours. One fetch in ten is counted as a <code>magpie partners fetch</code> event, with the country Cloudflare gives, while a partner is listed.</li>
|
||||
<li><code>/go/<partner>/site</code> and <code>/go/<partner>/keys</code>: a partner’s website and key-page links, opened in your browser, are counted (the partner, which link, a region, a country) as <code>magpie partner go</code> before you are sent on.</li>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
<div class="table-wrap"><table>
|
||||
<tr><td><b>镜像</b></td><td><code>ghcr.io/yetone/magpie</code>,支持 <code>linux/amd64</code> 和 <code>linux/arm64</code></td></tr>
|
||||
<tr><td><b>标签</b></td><td><code>latest</code>(最新正式版)、<code>daily</code>(每天北京时间 04:00 指向当时的最新正式版,一天只变一次)、<code>stable</code>(与桌面版的稳定版通道一致:每周一个已发布满三天的版本,紧急修复版立即跟上)、<code>0.1.1150</code>(某个版本)、<code>0.1</code>、<code>edge</code>(<code>main</code> 上的每次改动)</td></tr>
|
||||
<tr><td><b>标签</b></td><td><code>latest</code>(最新正式版)、<code>daily</code>(与桌面版的每日版通道一致:每天北京时间 04:00 指向当时 CI 已通过的最新正式版,一天只变一次,紧急修复版立即跟上)、<code>stable</code>(与桌面版的稳定版通道一致:每周一个已发布满三天的版本,紧急修复版立即跟上)、<code>0.1.1150</code>(某个版本)、<code>0.1</code>、<code>edge</code>(<code>main</code> 上的每次改动)</td></tr>
|
||||
<tr><td><b>端口</b></td><td><code>3425</code> 是 Agent 调用的网关;<code>3430</code> 是容器运行 <code>magpie web</code> 时的 Web 界面;它也响应网关的 <code>/v1</code> 路由,所以反向代理只需转发这一个端口</td></tr>
|
||||
<tr><td><b>数据卷</b></td><td><code>/config</code>:供应商、密钥、登录、插件和用量</td></tr>
|
||||
<tr><td><b>用户</b></td><td>nonroot(uid 65532)</td></tr>
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
<h2 id="site"><a class="anchor" href="#site">usemagpie.ai 能看到什么</a></h2>
|
||||
<p>magpie 会向自己的网站请求几样东西,不受隐私设置影响,就像任何应用访问自己的更新服务器。这些请求都不带安装 ID 或账号。</p>
|
||||
<ul>
|
||||
<li><code>/api/latest</code>:更新信息,每 6 小时一次(开了 <code>noAutoUpdate</code> 则不请求),带 <code>?lang=</code> 取对应语言的说明;<span class="ui">设置</span> → <span class="ui">关于</span> → <span class="ui">更新渠道</span>选了稳定版时还带 <code>?channel=stable</code>;新安装的 magpie 也会请求一次 <code>?channel=stable</code>,若自己就是稳定版,便留在稳定版。两者都不含你是谁。<code>/api/notes</code> 在更新后给出“新功能”。</li>
|
||||
<li><code>/api/latest</code>:更新信息,每 6 小时一次(开了 <code>noAutoUpdate</code> 则不请求),带 <code>?lang=</code> 取对应语言的说明;<span class="ui">设置</span> → <span class="ui">关于</span> → <span class="ui">更新渠道</span>选了稳定版或每日版时还带 <code>?channel=stable</code> 或 <code>?channel=daily</code>;新安装的 magpie 也会请求一次 <code>?channel=stable</code>,若自己就是稳定版,便留在稳定版。两者都不含你是谁。<code>/api/notes</code> 在更新后给出“新功能”。</li>
|
||||
<li><code>/files/<版本>/<文件></code>:更新和安装脚本下载的发布文件,由 Cloudflare R2 提供;站点上没有的文件会转到 github.com。不做任何统计。</li>
|
||||
<li><code>/api/partners</code>:添加供应商页的合作伙伴列表,每 6 小时一次。在有合作伙伴上架时,每十次拉取记一次 <code>magpie partners fetch</code> 事件,附 Cloudflare 给出的国家。</li>
|
||||
<li><code>/go/<合作伙伴>/site</code> 和 <code>/go/<合作伙伴>/keys</code>:在浏览器里打开合作伙伴的官网和 Key 页面链接时,先记一次 <code>magpie partner go</code>(哪个合作伙伴、哪个链接、地区、国家),再跳转。</li>
|
||||
|
||||
@@ -724,12 +724,11 @@ magpie runs a gateway on your computer, at `127.0.0.1:3425`. It speaks the OpenA
|
||||
| ChatGPT (Plus, Pro, Business) | `codex/…` | `magpie accounts add codex` |
|
||||
| GitHub Copilot | `copilot/…` | `magpie accounts add copilot` |
|
||||
| Gemini (Code Assist) | `gemini/…` | `magpie accounts add gemini` |
|
||||
| Antigravity | `antigravity/…` | `magpie accounts add antigravity` |
|
||||
|
||||
- **Claude..** Requests on a Claude subscription run through the Claude Code installed on your computer, so keep it installed.
|
||||
- **Copilot..** Copilot gives you a code to enter on GitHub’s page. For GitHub Enterprise on its own domain: `magpie accounts add copilot --host <name>.ghe.com`.
|
||||
- **Gemini..** This is Gemini CLI’s Google sign-in. Google answers it only for a Code Assist Standard or Enterprise account with a Google Cloud project of its own; `magpie accounts project gemini <email> <project>` names the project.
|
||||
- **Antigravity..** Its sign-in gives Antigravity’s Claude and Gemini models.
|
||||
- **Antigravity..** Install Antigravity (local agy CLI) from Plugins (`magpie plugin add @magpie-community/opencode-agy-cli-auth`). It runs the agy CLI you installed and signed in to, so Google sees agy’s own requests. Signing in to Antigravity in magpie directly is retired: Google bans accounts used that way.
|
||||
|
||||
Other subscriptions are added as plugins, from magpie’s Plugins page; see [Plugins](https://usemagpie.ai/docs/plugins).
|
||||
|
||||
@@ -10730,7 +10729,7 @@ Run magpie on a server or a NAS that has no desktop: its gateway serves your mod
|
||||
|
||||
| **Image** | `ghcr.io/yetone/magpie`, for `linux/amd64` and `linux/arm64` |
|
||||
| --- | --- |
|
||||
| **Tags** | `latest` (the newest release), `daily` (the newest release as of 20:00 UTC, moved once a day), `stable` (the desktop app's Stable channel: a release a week, out three days first, or an urgent one at once), `0.1.1150` (one release), `0.1`, `edge` (every change on `main`) |
|
||||
| **Tags** | `latest` (the newest release), `daily` (the desktop app's Daily channel: once a day at 20:00 UTC, the newest release whose CI run passed, or an urgent one at once), `stable` (the desktop app's Stable channel: a release a week, out three days first, or an urgent one at once), `0.1.1150` (one release), `0.1`, `edge` (every change on `main`) |
|
||||
| **Ports** | `3425` the gateway agents call; `3430` the browser UI, when the container runs `magpie web`; it answers the gateway’s `/v1` routes too, so a reverse proxy needs only this port |
|
||||
| **Volume** | `/config`: providers, keys, sign-ins, plugins and usage |
|
||||
| **User** | nonroot (uid 65532) |
|
||||
@@ -12170,7 +12169,7 @@ The app writes a log of what it did, `app.log`, in `~/Library/Logs/magpie` on ma
|
||||
|
||||
magpie asks its own site for a few things, whatever the privacy settings say, as any app asks its update server. None of these requests carries the install id or an account.
|
||||
|
||||
- `/api/latest`: the update feed, every 6 hours unless `noAutoUpdate` is on, with `?lang=` for the notes in your language, and `?channel=stable` when Settings → About → Update channel is Stable; a fresh install asks `?channel=stable` once too, to stay on Stable when it is Stable’s version. Neither says who you are. `/api/notes` gives What’s new after an update.
|
||||
- `/api/latest`: the update feed, every 6 hours unless `noAutoUpdate` is on, with `?lang=` for the notes in your language, and `?channel=stable` or `?channel=daily` when Settings → About → Update channel is Stable or Daily; a fresh install asks `?channel=stable` once too, to stay on Stable when it is Stable’s version. Neither says who you are. `/api/notes` gives What’s new after an update.
|
||||
- `/files/<version>/<file>`: the release files an update and the installer download, served from Cloudflare R2. A file the site doesn’t hold is sent on to github.com. Nothing is counted.
|
||||
- `/api/partners`: the add sheet’s partner list, every 6 hours. One fetch in ten is counted as a `magpie partners fetch` event, with the country Cloudflare gives, while a partner is listed.
|
||||
- `/go/<partner>/site` and `/go/<partner>/keys`: a partner’s website and key-page links, opened in your browser, are counted (the partner, which link, a region, a country) as `magpie partner go` before you are sent on.
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+202
-22
@@ -8,6 +8,10 @@
|
||||
// the same for Settings' Stable channel: a release a
|
||||
// week, an urgent one at once ("The Stable channel"
|
||||
// below), with channel and urgent; 503 while unknown
|
||||
// /api/latest?channel=daily
|
||||
// the same for the Daily channel: the newest release
|
||||
// with a green CI run and all its files, picked once
|
||||
// a day at 20:00 UTC ("The Daily channel" below)
|
||||
// /api/notes?after=&upto=&limit= {releases: [{version, notes, url, published}]}, newest
|
||||
// first: what changed since the version an app last ran
|
||||
// Both take ?lang=zh for the notes in Chinese, where a
|
||||
@@ -35,6 +39,8 @@
|
||||
// /download/<file> any file of the newest release, by name
|
||||
// /download/stable, /download/stable/<platform or file>
|
||||
// the same from the Stable channel's release
|
||||
// /download/daily, /download/daily/<platform or file>
|
||||
// the same from the Daily channel's release
|
||||
// /files/<tag>/<file> a release's file from R2 (files.js), the feed's
|
||||
// url and /download's for the files R2 holds;
|
||||
// GitHub's own address for any it doesn't
|
||||
@@ -96,11 +102,12 @@ export default {
|
||||
}
|
||||
if (url.pathname === "/api/latest") {
|
||||
const lang = url.searchParams.get("lang");
|
||||
// Settings' Stable channel; any other channel, or none, is every
|
||||
// version as it comes out
|
||||
if (url.searchParams.get("channel") === "stable") {
|
||||
const got = await stable(ctx, env, Date.now());
|
||||
if (!got) return json({ error: "the stable version isn't known yet" }, 503, NO_STORE);
|
||||
// Settings' Stable and Daily channels; any other channel, or none,
|
||||
// is every version as it comes out
|
||||
const ch = url.searchParams.get("channel");
|
||||
if (CHANNELS[ch]) {
|
||||
const got = await CHANNELS[ch](ctx, env, Date.now());
|
||||
if (!got) return json({ error: `the ${ch} version isn't known yet` }, 503, NO_STORE);
|
||||
return json({ ...(await fromR2(ctx, env, got.rel)), notes: inLang(got.rel.notes, lang) }, 200, cacheFor(got));
|
||||
}
|
||||
const got = await latest(ctx, env);
|
||||
@@ -150,16 +157,16 @@ export default {
|
||||
if (dl) return detour(ctx, env, dl[1], dl[2]);
|
||||
if (url.pathname.startsWith(RELAY)) return relay(req, url);
|
||||
if (url.pathname === "/download" || url.pathname.startsWith("/download/")) {
|
||||
// /download/stable/...: the same from the Stable channel's release
|
||||
// (the home page's Stable choice, fishmagic80 on X)
|
||||
// /download/stable/... and /download/daily/...: the same from that
|
||||
// channel's release (the home page's Stable choice, fishmagic80 on X)
|
||||
const parts = url.pathname.split("/");
|
||||
const onStable = parts[2] === "stable";
|
||||
const want = parts[onStable ? 3 : 2] || "mac-arm64";
|
||||
const got = onStable ? await stable(ctx, env, Date.now()).catch(() => null) : await latest(ctx, env);
|
||||
const ch = CHANNELS[parts[2]] ? parts[2] : "";
|
||||
const want = parts[ch ? 3 : 2] || "mac-arm64";
|
||||
const got = ch ? await CHANNELS[ch](ctx, env, Date.now()).catch(() => null) : await latest(ctx, env);
|
||||
const rel = got && (await fromR2(ctx, env, got.rel));
|
||||
const asset = rel && rel.assets && rel.assets[SHORT[want] || want];
|
||||
if (!asset) return new Response(onStable && !got ? "the stable version isn't known yet\n" : "not found\n", { status: onStable && !got ? 503 : 404, headers: NO_STORE });
|
||||
if (req.method === "GET") ctx.waitUntil(capture("magpie site download", { link: onStable ? "stable/" + want : want, file: SHORT[want] || want, client: client(req), country: country(req) }));
|
||||
if (!asset) return new Response(ch && !got ? `the ${ch} version isn't known yet\n` : "not found\n", { status: ch && !got ? 503 : 404, headers: NO_STORE });
|
||||
if (req.method === "GET") ctx.waitUntil(capture("magpie site download", { link: ch ? ch + "/" + want : want, file: SHORT[want] || want, client: client(req), country: country(req) }));
|
||||
return Response.redirect(asset.url, 302);
|
||||
}
|
||||
// crawlers and old browsers ask for /favicon.ico whatever the page links
|
||||
@@ -206,12 +213,13 @@ export default {
|
||||
return beacon(await withWall(await env.ASSETS.fetch(req), env, url));
|
||||
},
|
||||
// the crons (wrangler.jsonc's triggers): every quarter hour the ledger
|
||||
// the Stable channel is chosen from and Discover's old counts pruned, every five minutes the newest and
|
||||
// the Stable release's files into R2
|
||||
// the Stable channel is chosen from, then the day's Daily pick, and
|
||||
// Discover's old counts pruned; every five minutes the newest, the
|
||||
// Stable and the Daily release's files into R2
|
||||
async scheduled(event, env, ctx) {
|
||||
if (event.cron === MIRROR_CRON) ctx.waitUntil(keepFiles(ctx, env));
|
||||
else {
|
||||
ctx.waitUntil(keepLedger(env, Date.now()));
|
||||
ctx.waitUntil(keepLedger(env, Date.now()).catch((e) => console.log("ledger", String(e))).then(() => keepDaily(env, Date.now())));
|
||||
ctx.waitUntil(prunePlugins(env));
|
||||
}
|
||||
},
|
||||
@@ -514,6 +522,8 @@ async function keepFiles(ctx, env) {
|
||||
if (got) rels.push(got.rel);
|
||||
const st = await stable(ctx, env, Date.now()).catch((e) => console.log("r2: stable", String(e)));
|
||||
if (st) rels.push(st.rel);
|
||||
const dy = await daily(ctx, env, Date.now()).catch((e) => console.log("r2: daily", String(e)));
|
||||
if (dy && !rels.some((r) => r.version === dy.rel.version)) rels.push(dy.rel);
|
||||
const open = async (name, a, tag) => {
|
||||
let res = null;
|
||||
try {
|
||||
@@ -731,9 +741,10 @@ async function releases(ctx, env) {
|
||||
// A hundred releases are a day or so of magpie, so the list GitHub's API
|
||||
// gives in one ask doesn't reach a week back. The ledger does: a KV
|
||||
// namespace (LEDGER) the cron fills every quarter hour, its "index" every
|
||||
// release of the last LEDGER_DAYS ({v, p: published, u: urgent}, newest
|
||||
// first) and "notes:<UTC day>" each day's notes by version, which
|
||||
// /api/notes reads for a range older than the hundred newest. Without the
|
||||
// release of the last LEDGER_DAYS ({v, p: published, u: urgent, a: how
|
||||
// many files}, newest first) and "notes:<UTC day>" each day's notes by
|
||||
// version, which /api/notes reads for a range older than the hundred
|
||||
// newest. Without the
|
||||
// ledger, or one that doesn't reach back to the week's cut, Stable isn't
|
||||
// known and the feed says so (503) rather than guess. The Docker image's
|
||||
// stable tag follows this feed (.github/workflows/docker-stable.yml).
|
||||
@@ -801,6 +812,14 @@ async function stable(ctx, env, now) {
|
||||
if (!ix) return null;
|
||||
const pick = stableOf(ix.list.map((r) => ({ version: r.v, published: r.p, urgent: !!r.u })), now);
|
||||
if (!pick) return null;
|
||||
return channelRelease(ctx, env, "stable", pick);
|
||||
}
|
||||
|
||||
// channelRelease is a channel's pick ({version, published, urgent}) as a
|
||||
// release, condensed as latest's is and kept under the channel's name:
|
||||
// from GitHub's API, or, when it says no, the files from SHA256SUMS and
|
||||
// the notes from the ledger.
|
||||
async function channelRelease(ctx, env, channel, pick) {
|
||||
const tag = "v" + pick.version;
|
||||
let rel = await fromAPI(env, "releases/tags/" + tag);
|
||||
let degraded = !!rel && detoured(rel);
|
||||
@@ -811,11 +830,170 @@ async function stable(ctx, env, now) {
|
||||
degraded = true;
|
||||
}
|
||||
if (!rel) return null;
|
||||
const got = { rel: { ...rel, channel: "stable", urgent: !!pick.urgent }, degraded };
|
||||
remember(ctx, "stable", got, degraded ? BRIEF : TTL);
|
||||
const got = { rel: { ...rel, channel, urgent: !!pick.urgent }, degraded };
|
||||
remember(ctx, channel, got, degraded ? BRIEF : TTL);
|
||||
return got;
|
||||
}
|
||||
|
||||
// The Daily channel (fishmagic80 on X, a Docker user): Stable is a week
|
||||
// behind, so a plugin that needs a newer magpie doesn't work there, and
|
||||
// the newest is many releases a day. /api/latest?channel=daily is the
|
||||
// update feed between them, chosen here and never by hand:
|
||||
//
|
||||
// - once a day, at DAILY_HOUR UTC (04:00 in China), Daily becomes the
|
||||
// newest release out by then that has all RELEASE_FILES files and
|
||||
// whose own CI run (yetone/magpie's Test workflow, on the push of its
|
||||
// tagged commit) has passed by the time the pick is made;
|
||||
// - an urgent release is Daily as soon as it is out, as on Stable,
|
||||
// until a daily pick passes it.
|
||||
//
|
||||
// The quarter-hour cron makes the pick (keepDaily) once the day's cut has
|
||||
// passed and keeps it in the ledger as "daily": {cut, v}. A release with
|
||||
// no run of its own (a push of several commits runs the newest alone; a
|
||||
// newer push replaces a run that hasn't started) or a red one is passed
|
||||
// over. When nothing in reach qualifies the last pick stays, so Daily
|
||||
// never goes back. Until the first pick it isn't known (503). The Docker
|
||||
// image's daily tag follows this feed (.github/workflows/docker-daily.yml).
|
||||
const DAILY_HOUR = 20;
|
||||
export const RELEASE_FILES = 17; // the dmgs, zips, apps, CLIs, SHA256SUMS and its signature
|
||||
const SOURCE = "yetone/magpie"; // where the tags and their CI runs are
|
||||
const DAILY_ASKS = 6; // tag lookups (ten versions each) one pick makes at most
|
||||
|
||||
// dayCut is the DAILY_HOUR:00 UTC on or before now, in ms.
|
||||
export function dayCut(now) {
|
||||
const d = new Date(now);
|
||||
const c = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), DAILY_HOUR);
|
||||
return c > now ? c - DAY : c;
|
||||
}
|
||||
|
||||
// dailyOf is the Daily pick at cut among list ([{version, published,
|
||||
// files, green}], any order): the newest out by cut with every file and a
|
||||
// green run. null when none is.
|
||||
export function dailyOf(list, cut) {
|
||||
let pick = null;
|
||||
for (const r of list) {
|
||||
if (!(Date.parse(r.published) <= cut) || !(r.files >= RELEASE_FILES) || !r.green) continue;
|
||||
if (!pick || newer(r.version, pick.version)) pick = r;
|
||||
}
|
||||
return pick;
|
||||
}
|
||||
|
||||
// srcApi asks GitHub's API about yetone/magpie, with the GITHUB_TOKEN
|
||||
// secret where one is set, and without it when the token isn't let in
|
||||
// there (a token made for magpie-releases alone).
|
||||
async function srcApi(path, env) {
|
||||
const url = `https://api.github.com/repos/${SOURCE}/${path}`;
|
||||
const headers = { ...UA, Accept: "application/vnd.github+json" };
|
||||
if (env && env.GITHUB_TOKEN) {
|
||||
const res = await fetch(url, { headers: { ...headers, Authorization: `Bearer ${env.GITHUB_TOKEN}` } });
|
||||
if (res.ok || ![401, 403, 404].includes(res.status)) return res;
|
||||
}
|
||||
return fetch(url, { headers });
|
||||
}
|
||||
|
||||
// greenRuns is the commits the Test workflow passed on main, as a Set,
|
||||
// or null when GitHub can't say.
|
||||
async function greenRuns(env) {
|
||||
try {
|
||||
const res = await srcApi("actions/workflows/test.yml/runs?branch=main&event=push&status=success&per_page=100", env);
|
||||
if (!res.ok) {
|
||||
console.log("daily: runs", res.status);
|
||||
return null;
|
||||
}
|
||||
const j = await res.json();
|
||||
return new Set((j.workflow_runs || []).filter((r) => r.conclusion === "success").map((r) => r.head_sha));
|
||||
} catch (e) {
|
||||
console.log("daily: runs", String(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// keepDaily is the quarter-hour cron's Daily pick, made once a cut: the
|
||||
// ledger's releases out by the cut, newest first, each looked up as its
|
||||
// tag's commit (ten tags an ask, at most DAILY_ASKS asks) until one has
|
||||
// all its files and a green run. Nothing written while GitHub or the
|
||||
// ledger can't say: the next run tries again.
|
||||
export async function keepDaily(env, now) {
|
||||
const kv = env && env.LEDGER;
|
||||
if (!kv) return;
|
||||
const cut = dayCut(now);
|
||||
let had;
|
||||
try {
|
||||
had = await kv.get("daily", { type: "json" });
|
||||
} catch (e) {
|
||||
console.log("daily: read", String(e));
|
||||
return;
|
||||
}
|
||||
if (had && Date.parse(had.cut) >= cut) return;
|
||||
const ix = await readIndex(env);
|
||||
if (!ix) return;
|
||||
const out = ix.list
|
||||
.filter((r) => Date.parse(r.p) <= cut && r.a >= RELEASE_FILES && (!had || !had.v || newer(r.v, had.v)))
|
||||
.sort((a, b) => (newer(a.v, b.v) ? -1 : newer(b.v, a.v) ? 1 : 0));
|
||||
let pick = null;
|
||||
if (out.length) {
|
||||
const green = await greenRuns(env);
|
||||
if (!green) return;
|
||||
const shas = new Map(); // version: commit
|
||||
const groups = new Set();
|
||||
for (const r of out) {
|
||||
const group = r.v.slice(0, -1); // 0.1.422 holds 0.1.4220 to 0.1.4229
|
||||
if (!groups.has(group)) {
|
||||
if (groups.size >= DAILY_ASKS) break;
|
||||
groups.add(group);
|
||||
let refs;
|
||||
try {
|
||||
const res = await srcApi(`git/matching-refs/tags/v${group}`, env);
|
||||
if (!res.ok) {
|
||||
console.log("daily: tags", group, res.status);
|
||||
return;
|
||||
}
|
||||
refs = await res.json();
|
||||
} catch (e) {
|
||||
console.log("daily: tags", group, String(e));
|
||||
return;
|
||||
}
|
||||
// a lightweight tag names its commit; an annotated one isn't read
|
||||
for (const t of refs) if (t.object && t.object.type === "commit") shas.set(t.ref.replace(/^refs\/tags\/v/, ""), t.object.sha);
|
||||
}
|
||||
const sha = shas.get(r.v);
|
||||
pick = dailyOf([{ version: r.v, published: r.p, files: r.a, green: !!sha && green.has(sha) }], cut);
|
||||
if (pick) break;
|
||||
}
|
||||
}
|
||||
const v = pick ? pick.version : had && had.v;
|
||||
if (!v) {
|
||||
console.log("daily: nothing in reach passed", new Date(cut).toISOString());
|
||||
return;
|
||||
}
|
||||
await kv.put("daily", JSON.stringify({ cut: new Date(cut).toISOString(), v, at: new Date(now).toISOString() }));
|
||||
}
|
||||
|
||||
// daily is the Daily release, condensed as latest's is: {rel, degraded},
|
||||
// or null when it isn't known. An urgent release newer than the day's
|
||||
// pick is Daily at once.
|
||||
async function daily(ctx, env, now) {
|
||||
const hit = await cached("daily");
|
||||
if (hit && hit.rel && hit.rel.version) return hit;
|
||||
if (!env || !env.LEDGER) return null;
|
||||
let had;
|
||||
try {
|
||||
had = await env.LEDGER.get("daily", { type: "json", cacheTtl: 60 });
|
||||
} catch (e) {
|
||||
console.log("daily", String(e));
|
||||
return null;
|
||||
}
|
||||
if (!had || !had.v) return null;
|
||||
const ix = await readIndex(env, 60);
|
||||
if (!ix) return null;
|
||||
let pick = { version: had.v, published: (ix.list.find((r) => r.v === had.v) || {}).p, urgent: false };
|
||||
for (const r of ix.list) if (r.u && Date.parse(r.p) <= now && newer(r.v, pick.version)) pick = { version: r.v, published: r.p, urgent: true };
|
||||
return channelRelease(ctx, env, "daily", pick);
|
||||
}
|
||||
|
||||
// CHANNELS are the update feed's channels other than every version.
|
||||
const CHANNELS = { stable, daily };
|
||||
|
||||
// fromLedger is the notes of the releases the ledger has older than below
|
||||
// (every one when null), after after (exclusive, "" for any) up to upto,
|
||||
// newest first, at most most: [{version, notes, url, published}].
|
||||
@@ -863,7 +1041,7 @@ export async function keepLedger(env, now) {
|
||||
}
|
||||
const rels = (await res.json())
|
||||
.filter((r) => !r.draft && !r.prerelease)
|
||||
.map((r) => ({ version: r.tag_name.replace(/^v/, ""), notes: r.body || "", published: r.published_at }));
|
||||
.map((r) => ({ version: r.tag_name.replace(/^v/, ""), notes: r.body || "", published: r.published_at, files: (r.assets || []).length }));
|
||||
if (rels.length < 100) bottom = true;
|
||||
for (const r of rels) got.set(r.version, r);
|
||||
return rels;
|
||||
@@ -893,7 +1071,9 @@ export async function keepLedger(env, now) {
|
||||
// the feed's date is when the release was last edited: the API's, or
|
||||
// the one the ledger has, is when it came out
|
||||
const was = merged.get(r.version);
|
||||
merged.set(r.version, { v: r.version, p: !first && was ? was.p : r.published, u: urgentIn(r.notes) });
|
||||
// a: how many files it has, from the API (the feed doesn't say)
|
||||
const a = r.files !== undefined ? r.files : was && was.a;
|
||||
merged.set(r.version, { v: r.version, p: !first && was ? was.p : r.published, u: urgentIn(r.notes), ...(a !== undefined ? { a } : {}) });
|
||||
}
|
||||
const list = [...merged.values()]
|
||||
.filter((r) => r.v && Date.parse(r.p) >= keep)
|
||||
|
||||
Reference in New Issue
Block a user