A new gateway middleware, @magpie-community/middleware-fovea 0.2.2 (webkubor, #640): old tool output and text in a long history are cut to head and tail, with the boundary only on multiples of `cut_step` (24) so the cut prefix stays byte-identical between turns and the prompt cache holds. The leading user items before the first answer (Codex's AGENTS.md, environment_context and the task; Claude Code's first message) stay whole. `saccade` ("off" by default) drops the old context on a new topic, judged against that same task. Old images become a text note that keeps their `cache_control`. Ships an evidence page (Plugins > Fovea evidence) that computes a paste-in A/B in the frame, with no network.
What was run, at the reviewed head b9883cf206814fdc01950a00d413a36856de4e11, on mote (macOS, Bun 1.4.2, sandbox HOME):
- `bun test packages/fovea`: 33 pass, 0 fail. The two new Codex saccade cases fail with 0357f1c's middleware (and pass at the head).
- `bun scripts/check.mjs fovea` and `bun scripts/check.mjs`: pass. `page/measure.js` is byte-identical to a fresh `bun build.mjs`.
- `npm pack --dry-run`: 18 files, 131.8 kB unpacked; no brand/, no live-benchmark.mjs.
- The head merged onto origin/main 82b254f2 (registry.json auto-merged): `bun scripts/check.mjs` passes and `HOME=$(mktemp -d) bun test` (the whole repo, as pr.yml runs it): 5477 pass, 0 fail.
- A probe calling onRequest turn after turn. Codex-shaped Responses (instructions, developer permissions item, AGENTS.md, environment_context, the task as input_text, then reasoning with encrypted_content, function_call and function_call_output, 60 turns) and Claude Code-shaped Messages (system with cache_control, a first message with system-reminder, task and an image with cache_control, then thinking + signature, text, tool_use and a 6400-char tool_result with emoji, 70 turns). `instructions`, `system`, `tools`, every reasoning, function_call and assistant item, ids, counts and the cache_control count are unchanged; the four leading Codex items reach upstream byte-identical; no lone surrogate. The shared prefix breaks once per cut_step (Codex 6 of 60 turns, Messages 5 of 70; 0 without fovea), with `saccade: "auto"` too. With auto, a same-task follow-up on Codex ("scheduler retry timing assertion still fails in internal/sched, fix it") and on Messages collapses nothing; a new topic collapses from that turn on (one extra prefix break). Bodies went 16.1 MB to 9.4 MB (Codex) and 26.1 MB to 13.9 MB (Messages) over the run.
- Text the middleware adds upstream is only `[fovea: N chars of old tool output omitted]` and `[fovea: prior topic not carried]`: neither names magpie, a vendor or a limit. Codex's instructions are never touched.
Not tried: a live vendor request with real cache-hit numbers (the evidence is the byte-level prefix). pr.yml's runs were waiting on approval for a first-time contributor, so the CI record is the merged-tree run above. A new topic that shares a common word such as "the" with the task stays below the 0.08 overlap bar only when it has enough words; with saccade off by default that is a tuning note, not a blocker. @magpie-community/middleware-fovea is new to npm, so its first version needs an owner (trusted publishing can't create a package); magpie serves it from the dist branch meanwhile.
105 lines
5.7 KiB
CSS
105 lines
5.7 KiB
CSS
:root{
|
|
color-scheme: light dark;
|
|
--bg:#f4f6f9; --surface:#ffffff; --text:#13202e; --sub:#64748b;
|
|
--line:#e3e9f0; --ink:#2f63a2; --soft:#ecf3fb; --raw:#b6c2ce;
|
|
--shadow:0 10px 34px rgba(19,32,46,.06);
|
|
}
|
|
@media (prefers-color-scheme: dark){
|
|
:root{ --bg:#0f151d; --surface:#18212c; --text:#eef3f8; --sub:#9db0c2;
|
|
--line:#2b3a4a; --ink:#8dbbf5; --soft:#21334a;
|
|
--raw:#5d738a; --shadow:0 10px 34px rgba(0,0,0,.22); }
|
|
}
|
|
*{box-sizing:border-box}
|
|
body{margin:0;background:var(--bg);color:var(--text);
|
|
font:14px/1.6 -apple-system,BlinkMacSystemFont,"PingFang SC","Segoe UI",sans-serif;
|
|
-webkit-font-smoothing:antialiased}
|
|
main{width:min(840px,calc(100% - 32px));margin:0 auto;padding:26px 0 56px}
|
|
|
|
/* ── hero ─────────────────────────────────────────── */
|
|
.hero{display:flex;align-items:center;gap:16px;margin:6px 0 22px}
|
|
.eye{width:46px;height:46px;color:var(--ink);flex:none}
|
|
.eye .dot{fill:var(--ink)}
|
|
.hero-text h1{margin:0;font-size:21px;letter-spacing:-.02em}
|
|
.hero-text h1 span{color:var(--sub);font-weight:500}
|
|
.hero-text p{margin:0;color:var(--sub);font-size:13px}
|
|
.pill{margin-left:auto;background:var(--soft);color:var(--ink);padding:5px 11px;
|
|
border-radius:999px;font-size:12px;white-space:nowrap;flex:none}
|
|
.pill.bad{background:#f6e3e3;color:#a04040}
|
|
@media (prefers-color-scheme: dark){.pill.bad{background:#3d2426;color:#e2a2a2}}
|
|
|
|
/* ── stat cards ───────────────────────────────────── */
|
|
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:10px}
|
|
.stat{background:var(--surface);border:1px solid var(--line);border-radius:14px;
|
|
padding:16px 18px;box-shadow:var(--shadow);display:flex;flex-direction:column}
|
|
.stat .label{color:var(--sub);font-size:12px}
|
|
.stat strong{font-size:30px;line-height:1.25;font-variant-numeric:tabular-nums;
|
|
letter-spacing:-.03em}
|
|
.stat small{font-size:12px;color:var(--sub)}
|
|
.stat.accent{background:var(--soft);border-color:transparent}
|
|
.stat.accent strong{color:var(--ink)}
|
|
|
|
/* ── panels ───────────────────────────────────────── */
|
|
.panel{background:var(--surface);border:1px solid var(--line);border-radius:14px;
|
|
padding:18px 20px;margin:10px 0;box-shadow:var(--shadow)}
|
|
.head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}
|
|
.head h2,.note h2{font-size:15px;margin:0;font-weight:650}
|
|
.hint{color:var(--sub);font-size:12px}
|
|
.cap{color:var(--sub);font-size:12px;margin:12px 0 0}
|
|
.note{border-left:3px solid var(--ink)}
|
|
.note p{margin:10px 0 0;color:var(--sub)}
|
|
.note p:last-child{margin-bottom:0}
|
|
code{font:12px ui-monospace,SFMono-Regular,Consolas,monospace;background:var(--soft);
|
|
padding:2px 5px;border-radius:4px;color:var(--text)}
|
|
|
|
/* ── message strip ────────────────────────────────── */
|
|
.strip{display:flex;align-items:center;gap:6px;padding:6px 2px}
|
|
.m{height:26px;border-radius:6px}
|
|
.m.old{flex:1;background:var(--soft);border:1px dashed var(--line)}
|
|
.m.win{flex:1;background:var(--ink);opacity:.92}
|
|
.dots{display:flex;gap:5px;padding:0 6px}
|
|
.dots b{width:5px;height:5px;border-radius:50%;background:var(--sub);opacity:.6}
|
|
|
|
/* ── bars ─────────────────────────────────────────── */
|
|
.bar{display:flex;align-items:center;gap:12px;margin:12px 0;font-size:12px}
|
|
.bar>span{width:64px;flex:none;color:var(--sub)}
|
|
.track{height:12px;background:var(--bg);border-radius:8px;flex:1;overflow:hidden}
|
|
.fill{display:block;height:100%;width:100%;border-radius:8px;transition:width .3s ease}
|
|
.fill.raw{background:var(--raw)}
|
|
.fill.slim{background:var(--ink)}
|
|
.bar output{width:86px;text-align:right;font-variant-numeric:tabular-nums}
|
|
|
|
/* ── try-it form ──────────────────────────────────── */
|
|
.controls{display:flex;gap:14px;flex-wrap:wrap;margin:14px 0 10px}
|
|
.controls label{display:flex;flex-direction:column;gap:5px;color:var(--sub);font-size:12px}
|
|
select,input,textarea{background:var(--bg);color:var(--text);border:1px solid var(--line);
|
|
border-radius:9px;padding:8px 10px;font:inherit}
|
|
input{width:104px}
|
|
textarea{width:100%;min-height:120px;resize:vertical;
|
|
font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace}
|
|
textarea:focus,select:focus,input:focus{outline:2px solid var(--soft);border-color:var(--ink)}
|
|
.actions{display:flex;align-items:center;gap:10px;margin-top:12px;flex-wrap:wrap}
|
|
button{border:0;border-radius:9px;background:var(--ink);color:var(--bg);padding:9px 16px;
|
|
font:inherit;font-weight:600;cursor:pointer}
|
|
button.quiet{background:var(--soft);color:var(--ink)}
|
|
#error{color:#a04040;font-size:12px}
|
|
|
|
/* ── live cards ───────────────────────────────────── */
|
|
.live-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
|
|
.live-card{background:var(--bg);border:1px solid var(--line);border-radius:11px;padding:12px 14px}
|
|
.live-card h3{font-size:13px;margin:0 0 10px;font-weight:650}
|
|
.live-card>div{display:flex;justify-content:space-between;gap:12px;margin:4px 0;font-size:12px}
|
|
.live-card span{color:var(--sub)}
|
|
.live-card strong{font-variant-numeric:tabular-nums}
|
|
|
|
@media (max-width:640px){
|
|
main{width:min(100% - 24px,840px);padding-top:16px}
|
|
.stats{grid-template-columns:1fr 1fr}
|
|
.stat.accent{grid-column:span 2}
|
|
.stat strong{font-size:24px}
|
|
.panel{padding:15px 16px}
|
|
.bar>span{width:54px}
|
|
.bar output{width:64px}
|
|
.live-grid{grid-template-columns:1fr}
|
|
.pill{display:none}
|
|
}
|