Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

fix(ci): restore star history updates and round Y axis bounds

沨沄极客9b13d1d75101
diff --git a/.github/star-history/FONT-LICENSE.txt b/.github/star-history/FONT-LICENSE.txt
new file mode 100644
index 0000000..116af2d
--- /dev/null
+++ b/.github/star-history/FONT-LICENSE.txt
@@ -0,0 +1,13 @@
+Patrick Hand
+Copyright (c) 2012 Patrick Wagesreiter ([email protected])
+
+Licensed under the SIL Open Font License, Version 1.1.
+http://scripts.sil.org/OFL
+https://fonts.google.com/specimen/Patrick+Hand
+
+patrick-hand.woff2 in this directory is that font, as served by Google Fonts
+for the latin range, inlined into the star history SVGs by postprocess-svg.py.
+
+The OFL permits commercial use, embedding and redistribution, and requires
+that this notice travel with the font. The font is not sold on its own and
+its name is not used to promote anything derived from it.
diff --git a/.github/star-history/branch-readme.md b/.github/star-history/branch-readme.md
new file mode 100644
index 0000000..780551c
--- /dev/null
+++ b/.github/star-history/branch-readme.md
@@ -0,0 +1,17 @@
+# star-history (generated branch)
+
+Machine-generated. Do not edit, do not open pull requests against this branch,
+and do not expect its history to be stable — every run of
+[`.github/workflows/star-history.yml`](https://github.com/citrolabs/ego-lite/blob/main/.github/workflows/star-history.yml)
+on `main` force-pushes a fresh single commit over it.
+
+The chart lives here rather than on `main` because `main`'s ruleset requires a
+reviewed pull request for every change, which a scheduled bot cannot produce
+unattended. `main`'s README links these files by raw URL:
+
+| File | Purpose |
+| --- | --- |
+| `star-history-light.svg` | README chart, light theme |
+| `star-history-dark.svg` | README chart, dark theme |
+| `star-history.png` | Raster fallback for registries that cannot render SVG |
+| `.star-history.sig` | Signature over the star data; how the workflow detects a change |
diff --git a/.github/star-history/patrick-hand.woff2 b/.github/star-history/patrick-hand.woff2
new file mode 100644
index 0000000..eecd8e5
Binary files /dev/null and b/.github/star-history/patrick-hand.woff2 differ
diff --git a/.github/star-history/postprocess-svg.py b/.github/star-history/postprocess-svg.py
new file mode 100755
index 0000000..143df1d
--- /dev/null
+++ b/.github/star-history/postprocess-svg.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+"""Post-process the rendered star-history SVGs for GitHub's raw host.
+
+Two fixes, both forced by the CSP raw.githubusercontent.com serves the chart
+with:
+
+ default-src 'none'; style-src 'unsafe-inline'; sandbox
+
+strip_blocked_images() drops the repo-avatar <image> the renderer puts next to
+the chart title. No img-src means no image source is permitted at all, data:
+URIs included, so the avatar cannot load and the browser draws a broken-image
+icon in its place. The title text is centred with text-anchor="middle"
+independently of the avatar, so removing it leaves the heading correct.
+
+embed_font() re-embeds the @font-face the renderer strips out, on the
+assumption GitHub drops it. camo does allow it (its CSP names img-src data:
+and style-src 'unsafe-inline'), which is the case the renderer had in mind.
+
+The font is Patrick Hand (SIL OFL), which reads as hand-drawn without the
+non-commercial clause that star-history.com's own xkcd Script carries. To
+switch faces, drop a new woff2 next to this script and point FONT at it.
+"""
+import base64
+import pathlib
+import re
+import sys
+
+HERE = pathlib.Path(__file__).parent
+FONT = HERE / "patrick-hand.woff2"
+# The vendored star-history renderer asks for this family by name, so whatever
+# face FONT points at has to be declared under it.
+FAMILY = "xkcd"
+
+
+def strip_blocked_images(text: str) -> tuple[str, int]:
+ """Remove every <image> element, plus any clip path left with no referent."""
+ text, dropped = re.subn(r"<image\b[^>]*/>", "", text)
+ if not dropped:
+ return text, 0
+ # The renderer wraps the avatar's clip path in its own <svg><defs>. Drop any
+ # clip path nothing points at any more, then the container if it went empty.
+ for clip in re.findall(r'<clipPath id="([^"]+)">.*?</clipPath>', text):
+ if f"url(#{clip})" not in text:
+ text = re.sub(
+ r'<clipPath id="%s">.*?</clipPath>' % re.escape(clip), "", text
+ )
+ text = text.replace("<svg><defs></defs></svg>", "")
+ return text, dropped
+
+
+def main(out_dir: str) -> int:
+ b64 = base64.b64encode(FONT.read_bytes()).decode("ascii")
+ face = (
+ '<defs><style type="text/css">'
+ f'@font-face{{font-family:"{FAMILY}";'
+ f"src:url(data:font/woff2;base64,{b64}) format('woff2');"
+ "font-weight:normal;font-style:normal;}</style></defs>"
+ )
+
+ svgs = sorted(pathlib.Path(out_dir).glob("*.svg"))
+ if not svgs:
+ print(f"No SVGs in {out_dir}; nothing to do.")
+ return 0
+
+ for svg in svgs:
+ text = svg.read_text(encoding="utf-8")
+
+ text, dropped = strip_blocked_images(text)
+ if dropped:
+ print(f"{svg.name}: dropped {dropped} CSP-blocked <image> element(s)")
+
+ if "@font-face" in text:
+ print(f"{svg.name}: already has @font-face, skipping font")
+ else:
+ # Insert immediately after the opening <svg ...> tag.
+ cut = text.index(">") + 1
+ text = text[:cut] + face + text[cut:]
+ print(f"{svg.name}: embedded {FONT.name}")
+
+ svg.write_text(text, encoding="utf-8")
+ print(f"{svg.name}: {len(text.encode()) // 1024} KB")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else "assets/star-history"))
diff --git a/.github/star-history/y-axis.patch b/.github/star-history/y-axis.patch
new file mode 100644
index 0000000..3974026
--- /dev/null
+++ b/.github/star-history/y-axis.patch
@@ -0,0 +1,11 @@
+diff --git a/renderer/vendor/shared/packages/xy-chart.tsx b/renderer/vendor/shared/packages/xy-chart.tsx
+--- a/renderer/vendor/shared/packages/xy-chart.tsx
++++ b/renderer/vendor/shared/packages/xy-chart.tsx
+@@ -212,6 +212,7 @@
+ } else {
+ yScale = scaleLinear()
+ .domain([0, Math.max(...allYData)]) // Always start from 0 for linear scale
++ .nice(options.yTickCount)
+ .range([chartHeight, 0])
+ }
+
diff --git a/.github/star-history/y-axis.test.ts b/.github/star-history/y-axis.test.ts
new file mode 100644
index 0000000..561a6b7
--- /dev/null
+++ b/.github/star-history/y-axis.test.ts
@@ -0,0 +1,30 @@
+// Run from the pinned action's renderer directory after applying y-axis.patch.
+import assert from "node:assert/strict";
+import { test } from "node:test";
+import { JSDOM } from "jsdom";
+import XYChart from "./vendor/shared/packages/xy-chart";
+
+for (const theme of ["light", "dark"] as const) {
+ for (const stars of [1, 14001, 19546, 20000, 20001, 99999]) {
+ test(`${theme}: Y axis covers ${stars} stars with a labelled upper bound`, () => {
+ const dom = new JSDOM("<!DOCTYPE html><body></body>");
+ const svg = dom.window.document.createElement("svg");
+ dom.window.document.body.append(svg);
+ XYChart(svg as unknown as SVGSVGElement, {
+ title: "Star History", xLabel: "Date", yLabel: "GitHub Stars",
+ data: { datasets: [{ label: "test/repo", logo: "", data: [
+ { x: new Date("2026-05-01"), y: 0 },
+ { x: new Date("2026-10-26"), y: stars },
+ ] }] },
+ showDots: false, transparent: false, theme,
+ }, { xTickLabelType: "Date", chartWidth: 800 });
+ const ticks = [...svg.querySelectorAll(".yaxis .tick")];
+ const upper = ticks[ticks.length - 1];
+ assert(upper);
+ assert((upper as unknown as { __data__: number }).__data__ >= stars);
+ assert.match(upper.getAttribute("transform") ?? "", /^translate\(0,0(?:\.5)?\)$/);
+ if (stars === 19546) assert.equal(upper.textContent, "20K");
+ dom.window.close();
+ });
+ }
+}
diff --git a/.github/workflows/star-history.yml b/.github/workflows/star-history.yml
new file mode 100644
index 0000000..b1e6c7e
--- /dev/null
+++ b/.github/workflows/star-history.yml
@@ -0,0 +1,133 @@
+name: Star History
+
+on:
+ schedule:
+ # Daily at 04:17 UTC. Off the hour to avoid the top-of-hour Actions rush.
+ - cron: '17 4 * * *'
+ workflow_dispatch:
+ inputs:
+ force:
+ # The publish is normally gated on the star data moving, so a change to
+ # the SVG post-processing alone would not reach the branch until the
+ # next new star. This republishes from the restored chart on demand.
+ description: 'Republish even if the star data has not changed'
+ type: boolean
+ default: false
+
+# The stargazers API needs metadata:read + contents:write since GitHub's
+# 2026-06-30 restriction. The built-in token with contents:write covers both,
+# so no PAT is involved. contents:write is also what pushes CHART_BRANCH.
+permissions:
+ contents: write
+
+concurrency:
+ group: star-history
+ cancel-in-progress: false
+
+env:
+ # main's ruleset requires every change to arrive as a reviewed pull request,
+ # so a bot cannot commit the regenerated chart there. The chart lives on this
+ # orphan data branch instead and the README links it by raw URL; main is
+ # never written to. Renaming this branch means editing the README URLs too.
+ CHART_BRANCH: star-history
+ # Scratch directory in the runner's checkout. Deliberately not tracked on
+ # main: the only copy of the chart that matters is the one on CHART_BRANCH.
+ CHART_DIR: assets/star-history
+
+jobs:
+ star-history:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ # render-charts.sh decides "changed" by comparing .star-history.sig, and
+ # falls back to the existing chart when the stargazers API rate-limits it.
+ # Both need the previously published files on disk, and they no longer
+ # come with the checkout, so fetch them off CHART_BRANCH first.
+ - name: Restore last published chart
+ run: |
+ set -euo pipefail
+ mkdir -p "$CHART_DIR"
+ if git fetch --depth=1 origin "$CHART_BRANCH"; then
+ git archive FETCH_HEAD | tar -x -C "$CHART_DIR"
+ # Branch-local docs, not chart data; keep it out of the render dir.
+ rm -f "$CHART_DIR/README.md"
+ ls -la "$CHART_DIR" # -a: .star-history.sig matters here
+ else
+ echo "No $CHART_BRANCH yet; this run creates it."
+ fi
+
+ # Pinned to the v1.0.5 commit; the renderer's package-lock.json makes the
+ # npm install deterministic from there. commit is left to us because the
+ # SVGs still need their font embedded, and because the files go to
+ # CHART_BRANCH rather than to the checked-out branch. update-readme is off
+ # for the same reason: the README already carries absolute CHART_BRANCH
+ # URLs, which the action's relative-path rewrite would undo.
+ - name: Check out pinned chart renderer
+ uses: actions/checkout@v4
+ with:
+ repository: narayann7/star-history-action
+ ref: a68d8f9d67ca20d55b682a264e69152dcf326e9c
+ path: .star-history-action
+ persist-credentials: false
+
+ - name: Round the Y axis up to a labelled tick
+ run: git -C .star-history-action apply "$GITHUB_WORKSPACE/.github/star-history/y-axis.patch"
+
+ - id: chart
+ uses: ./.star-history-action
+ with:
+ repos: ${{ github.repository }}
+ output-dir: ${{ env.CHART_DIR }}
+ type: Date
+ themes: light,dark
+ # Only reaches the PNG; the SVGs get their font from postprocess-svg.py
+ # below. Set so the two do not drift apart.
+ font-family: Patrick Hand
+ update-readme: false
+ commit: false
+
+ - name: Test Y axis bounds
+ run: |
+ cp .github/star-history/y-axis.test.ts .star-history-action/renderer/
+ cd .star-history-action/renderer
+ node_modules/.bin/tsx --test y-axis.test.ts
+
+ # Drops the repo-avatar <image> the renderer adds beside the title, which
+ # raw.githubusercontent.com's 'default-src none' CSP refuses to load at
+ # all — it rendered as a broken-image icon — and re-embeds the @font-face
+ # the renderer strips. See postprocess-svg.py for both.
+ - name: Post-process chart SVGs
+ if: steps.chart.outputs.changed == 'true' || inputs.force
+ run: python3 .github/star-history/postprocess-svg.py "$CHART_DIR"
+
+ # A fresh orphan commit force-pushed over CHART_BRANCH: the branch stays
+ # one commit deep, so a daily 130 KB of regenerated binaries never turns
+ # into a growing history. No rule guards a non-default branch, so this
+ # needs no review and cannot be declined the way the old push to main was.
+ - name: Publish chart to CHART_BRANCH
+ if: steps.chart.outputs.changed == 'true' || inputs.force
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ work="$(mktemp -d)"
+ cp "$CHART_DIR"/star-history-*.svg \
+ "$CHART_DIR"/star-history.png \
+ "$CHART_DIR"/.star-history.sig \
+ "$work/"
+ cp .github/star-history/branch-readme.md "$work/README.md"
+ git init -q -b "$CHART_BRANCH" "$work"
+ git -C "$work" add -A
+ git -C "$work" \
+ -c user.name='github-actions[bot]' \
+ -c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
+ commit -q -m "chore: update star history (run ${GITHUB_RUN_ID})"
+ git -C "$work" push --force --quiet \
+ "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
+ "$CHART_BRANCH"
+ echo "Pushed $(git -C "$work" rev-parse --short HEAD) to $CHART_BRANCH."
+ # No cache purge needed: GitHub does not camo-proxy
+ # raw.githubusercontent.com, it serves these URLs verbatim with
+ # cache-control max-age=300, so the README picks the new chart up
+ # within five minutes. Verified against the rendered README.