Changelog, dev startup, README, AgentHub 0.4.0, model catalog, and landing site (#7)

Branch-length batch covering tooling, the model layer, the Web App and the public
surfaces. Highlights:

- Changelog: a per-release `changelog/<version>/` tree, grouped by the surface each
  change touches, with a root CHANGELOG.md holding one line per release.
- Dev startup: `scripts/dev-prebuild.mjs` serializes the skills+core prebuild behind a
  lock and keeps `pnpm install` current; `pnpm dev` runs server+web together.
- AgentHub 0.3.3 -> 0.4.0: OmniMessage complete payloads carry one opaque `fidelity`
  object in place of item-level `signature`/`phase`, threaded verbatim through Trace,
  replay and resume; malformed classification adapted to the new error types.
- Model layer: a model is always referenced by an explicit `(provider, model_id)` pair.
  The provider is never inferred, guessed or defaulted -- both the catalog inference and
  the unique-match config resolution are gone, and CLI, SDK, server routes and
  run_subagent all require the complete pair. Catalog gains the Qwen Token Plan, Qwen
  Pay-As-You-Go and Fireworks AI gateways, plus an expanded OpenRouter group.
- Web App: catalog preset sync and per-group speed test on the Models page, positional
  slash commands, a markdown renderer, skill-library update reminders, and a vertically
  centred draft page whose upward menus size themselves to the room available.
- Public surfaces: restructured READMEs, the penguin.ooo landing site and blog, refreshed
  benchmark results for both suites, and the demo videos playing on the landing page.

Includes the fixes from a full review of the branch: 23 confirmed findings, among them a
provider-inference bug that could send one vendor's API key to another vendor's endpoint,
and an Escape handler that destroyed the composer's contents unrecoverably.

Verified on the branch head: pnpm test (1127 passing, 7 packages), pnpm typecheck and
pnpm format:check clean, Playwright e2e 14/14.
This commit is contained in:
Yaowei Zheng
2026-07-21 17:43:31 +08:00
committed by GitHub
parent abf0a2f248
commit d4faee3a1e
214 changed files with 9406 additions and 1688 deletions
+1
View File
@@ -25,6 +25,7 @@ const agent = (agentId: string, name?: string): AgentSummary => ({
version: 1,
vaultKeyCount: 0,
scheduleCount: 0,
skillCount: 0,
});
const AGENTS: AgentSummary[] = [
+153
View File
@@ -0,0 +1,153 @@
/**
* catalog-sync.ts unit tests: the "sync presets" merge — union of the local model table and
* the built-in catalog, catalog winning on differing preset entries, local additions and
* credentials untouched.
*/
import { describe, expect, it } from "vitest";
import { syncRowsWithCatalog } from "../src/features/models/catalog-sync";
import type { RowState } from "../src/features/models/models-page";
type PresetEntry = Parameters<typeof syncRowsWithCatalog>[1] extends (infer E)[] | undefined
? E
: never;
function makeRow(partial: Partial<RowState> & Pick<RowState, "provider" | "modelId">): RowState {
return {
original: { provider: partial.provider, modelId: partial.modelId },
vision: true,
contextWindow: "",
clientType: "",
cacheRead: "",
cacheWrite: "",
output: "",
baseUrl: "",
originalBaseUrl: "",
apiKeyInput: "",
clearApiKey: false,
...partial,
};
}
const PRESET: PresetEntry[] = [
{
provider: "deepseek",
model_id: "deepseek-v4-pro",
context_window: 1000000,
pricing: {
unit: "usd_per_mtok",
cache_read: 0.003571,
cache_write: 0.428571,
output: 0.857143,
},
vision: false,
},
{
provider: "qwen-token-plan",
model_id: "glm-5.2",
context_window: 1048576,
client_type: "openai",
pricing: { unit: "usd_per_mtok", cache_read: 0.285714, cache_write: 1.142857, output: 4 },
vision: false,
base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
},
// Preview model without a list price: the catalog carries no pricing.
{
provider: "qwen-token-plan",
model_id: "qwen3.8-max-preview",
context_window: 1000000,
client_type: "openai",
base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
},
];
describe("syncRowsWithCatalog", () => {
it("adds catalog entries missing locally (gateway base URL preset, original null -> new on PUT)", () => {
const { rows, added, updated } = syncRowsWithCatalog([], PRESET);
expect(added).toBe(3);
expect(updated).toBe(0);
const glm = rows.find((r) => r.provider === "qwen-token-plan" && r.modelId === "glm-5.2")!;
expect(glm.original).toBeNull();
expect(glm.clientType).toBe("openai");
expect(glm.baseUrl).toBe("https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1");
expect(glm.originalBaseUrl).toBe(""); // differs from baseUrl -> the PUT submits the preset URL
expect(glm.cacheRead).toBe("0.285714");
expect(glm.vision).toBe(false);
});
it("resets differing preset rows to the catalog's fields, keeping identity and credentials", () => {
const local = makeRow({
provider: "deepseek",
modelId: "deepseek-v4-pro",
vision: true, // user flipped it
contextWindow: "500000", // stale
cacheRead: "1",
cacheWrite: "2",
output: "3",
baseUrl: "http://my-proxy", // user override -> catalog wins (cleared)
originalBaseUrl: "http://my-proxy",
credential: { hasApiKey: true } as RowState["credential"],
});
const { rows, added, updated } = syncRowsWithCatalog([local], PRESET);
expect(added).toBe(2);
expect(updated).toBe(1);
const row = rows[0]!;
expect(row.contextWindow).toBe("1000000");
expect(row.vision).toBe(false);
expect(row.cacheRead).toBe("0.003571");
expect(row.baseUrl).toBe(""); // catalog has no base_url; differs from originalBaseUrl -> cleared on PUT
expect(row.originalBaseUrl).toBe("http://my-proxy");
// Identity and credential state untouched: no rename, no key input, credential kept.
expect(row.original).toEqual({ provider: "deepseek", modelId: "deepseek-v4-pro" });
expect(row.apiKeyInput).toBe("");
expect(row.clearApiKey).toBe(false);
expect(row.credential).toEqual({ hasApiKey: true });
});
it("leaves up-to-date rows untouched (same object, updated not counted)", () => {
const upToDate = makeRow({
provider: "deepseek",
modelId: "deepseek-v4-pro",
vision: false,
contextWindow: "1000000",
cacheRead: "0.003571",
cacheWrite: "0.428571",
output: "0.857143",
});
const { rows, updated } = syncRowsWithCatalog([upToDate], PRESET);
expect(updated).toBe(0);
expect(rows[0]).toBe(upToDate);
});
it("keeps locally added models (including user-defined groups) verbatim and in place", () => {
const mine = makeRow({ provider: "my-gateway", modelId: "my-model", baseUrl: "http://x" });
const { rows, added } = syncRowsWithCatalog([mine], PRESET);
expect(added).toBe(3);
expect(rows[0]).toBe(mine); // existing rows keep their list position; catalog entries append
expect(rows).toHaveLength(4);
});
it("removes pricing when the catalog entry carries none (preview model, catalog wins)", () => {
const local = makeRow({
provider: "qwen-token-plan",
modelId: "qwen3.8-max-preview",
contextWindow: "1000000",
clientType: "openai",
baseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
cacheRead: "1",
cacheWrite: "2",
output: "3",
});
const { rows, updated } = syncRowsWithCatalog([local], PRESET);
expect(updated).toBe(1);
const row = rows.find((r) => r.modelId === "qwen3.8-max-preview")!;
expect([row.cacheRead, row.cacheWrite, row.output]).toEqual(["", "", ""]);
});
it("syncs against the real built-in catalog by default", () => {
const { rows, added, updated } = syncRowsWithCatalog([]);
expect(added).toBeGreaterThan(30);
expect(updated).toBe(0);
// No merged row ever carries a key input: credentials are structurally untouched.
expect(rows.every((r) => r.apiKeyInput === "" && !r.clearApiKey)).toBe(true);
});
});
+31 -1
View File
@@ -10,7 +10,11 @@
*/
import { describe, expect, it } from "vitest";
import { MODEL_PROVIDERS } from "@prismshadow/penguin-core/model-catalog";
import { groupModelRows, matchesQuery } from "../src/features/models/model-grouping";
import {
groupModelRows,
orderModelsLikeLibrary,
matchesQuery,
} from "../src/features/models/model-grouping";
import type { ModelRowLike } from "../src/features/models/model-grouping";
const rows: ModelRowLike[] = [
@@ -64,7 +68,10 @@ describe("groupModelRows", () => {
expect(MODEL_PROVIDERS.map((p) => p.id)).toEqual([
"deepseek",
"openrouter",
"fireworks",
"siliconflow",
"qwen-token-plan",
"qwen-pay-as-you-go",
"google",
"anthropic",
"openai",
@@ -123,3 +130,26 @@ describe("groupModelRows", () => {
expect(groupModelRows(mixed, "zeta").map((g) => g.provider.id)).toEqual(["zeta-lab"]);
});
});
describe("orderModelsLikeLibrary", () => {
it("flattens to the library page's order: built-in provider order, user groups after, custom last", () => {
const rows: ModelRowLike[] = [
{ provider: "custom", modelId: "my-proxy" },
{ provider: "my-gateway", modelId: "own-1" },
{ provider: "moonshot", modelId: "kimi-k3" },
{ provider: "deepseek", modelId: "deepseek-v4-flash" },
{ provider: "openrouter", modelId: "anthropic/claude-fable-5" },
{ provider: "deepseek", modelId: "deepseek-v4-pro" },
];
expect(orderModelsLikeLibrary(rows).map((r) => `${r.provider} ${r.modelId}`)).toEqual([
// deepseek first (in-group order preserved), then the openrouter gateway, then moonshot,
// then custom, then the user-defined group appended after the built-ins.
"deepseek deepseek-v4-flash",
"deepseek deepseek-v4-pro",
"openrouter anthropic/claude-fable-5",
"moonshot kimi-k3",
"custom my-proxy",
"my-gateway own-1",
]);
});
});
+41
View File
@@ -0,0 +1,41 @@
/**
* outdatedAgentIds unit tests: the skill-library update reminder's data source — Agents
* whose installed copy is strictly older than the library's version.
*/
import { describe, expect, it } from "vitest";
import { outdatedAgentIds } from "../src/features/skills/skills-page";
import type { InstalledMap } from "../src/features/skills/skills-page";
const installed: InstalledMap = new Map([
["stale_agent", new Map([["agenthub-dev", 1]])],
["current_agent", new Map([["agenthub-dev", 2]])],
["ahead_agent", new Map([["agenthub-dev", 3]])],
["other_agent", new Map([["penguin-cli", 1]])],
]);
const AGENTS = ["stale_agent", "current_agent", "ahead_agent", "other_agent", "empty_agent"];
describe("outdatedAgentIds", () => {
it("flags only strictly lower installed versions", () => {
expect(outdatedAgentIds(AGENTS, installed, "agenthub-dev", 2)).toEqual(["stale_agent"]);
});
it("ignores not-installed Agents (including ones with no snapshot at all)", () => {
// other_agent has a different skill installed; empty_agent never appears in the map.
expect(outdatedAgentIds(AGENTS, installed, "agenthub-dev", 99)).toEqual([
"stale_agent",
"current_agent",
"ahead_agent",
]);
expect(outdatedAgentIds(["other_agent", "empty_agent"], installed, "agenthub-dev", 99)).toEqual(
[],
);
});
it("a locally newer copy does not trigger the reminder", () => {
expect(outdatedAgentIds(["ahead_agent"], installed, "agenthub-dev", 2)).toEqual([]);
});
it("everything current -> no reminder", () => {
expect(outdatedAgentIds(AGENTS, installed, "agenthub-dev", 1)).toEqual([]);
});
});
+53
View File
@@ -0,0 +1,53 @@
/**
* slash-token.ts unit tests: positional slash matching (any caret position, whitespace
* boundary, no URL/path false positives) and token removal on command run.
*/
import { describe, expect, it } from "vitest";
import { matchSlash, removeSlashToken } from "../src/features/chat/slash-token";
describe("matchSlash", () => {
it("matches at the start of the text", () => {
expect(matchSlash("/comp", 5)).toEqual({ start: 0, end: 5, query: "comp" });
});
it("matches mid-text after whitespace, with the token extending past the caret", () => {
// caret in the middle of "/compact" (after "/com")
expect(matchSlash("please /compact now", 11)).toEqual({ start: 7, end: 15, query: "com" });
});
it("does not treat paths or URLs as commands (no whitespace before the slash)", () => {
expect(matchSlash("see a/b", 7)).toBeNull();
expect(matchSlash("https://x", 9)).toBeNull();
});
it("stops matching once non-command characters follow the slash", () => {
expect(matchSlash("/comp act", 9)).toBeNull(); // caret after the space: query has a space
expect(matchSlash("/comp act", 5)).toEqual({ start: 0, end: 5, query: "comp" });
});
});
describe("removeSlashToken", () => {
it("removes just the token and keeps the rest of the text", () => {
const m = matchSlash("please /compact now", 11)!;
expect(removeSlashToken("please /compact now", m)).toBe("please now");
});
it("clears a token-only input to empty", () => {
const m = matchSlash("/compact", 8)!;
expect(removeSlashToken("/compact", m)).toBe("");
// Whitespace-only leftovers count as empty too.
expect(removeSlashToken(" /compact", matchSlash(" /compact", 10)!)).toBe("");
});
it("keeps multi-space runs elsewhere in the body verbatim", () => {
const text = "a b /compact";
expect(removeSlashToken(text, matchSlash(text, text.length)!)).toBe("a b ");
});
it("keeps indentation of a multi-line body verbatim", () => {
const text = "steps:\n - one\n - nested\n/compact";
expect(removeSlashToken(text, matchSlash(text, text.length)!)).toBe(
"steps:\n - one\n - nested\n",
);
});
});
+24
View File
@@ -0,0 +1,24 @@
/**
* Speed-test tone thresholds: TTFT (< 1s green, <= 3s yellow, beyond red) and TPS
* (>= 40 tok/s green, >= 15 yellow, below red) — the card badge colors.
*/
import { describe, expect, it } from "vitest";
import { tpsTone, ttftTone } from "../src/features/models/speed-test";
describe("speed-test tones", () => {
it("grades TTFT boundaries", () => {
expect(ttftTone(120)).toBe("green");
expect(ttftTone(999)).toBe("green");
expect(ttftTone(1000)).toBe("yellow");
expect(ttftTone(3000)).toBe("yellow");
expect(ttftTone(3001)).toBe("red");
});
it("grades TPS boundaries", () => {
expect(tpsTone(80)).toBe("green");
expect(tpsTone(40)).toBe("green");
expect(tpsTone(39.9)).toBe("yellow");
expect(tpsTone(15)).toBe("yellow");
expect(tpsTone(14.9)).toBe("red");
});
});
+39 -3
View File
@@ -231,11 +231,14 @@ describe("resync rebuild", () => {
h.resolveLoad([at(userText("question"), "2026-07-05T00:00:00.000Z")]);
await p;
expect(h.loadCalls()).toBe(2);
// The old replay must not reset phase back to live: events arriving during rebuild
// should still be buffered, not fed to the new model.
// The old replay must not reset phase back to live: events arriving during rebuild are still
// buffered, not fed to a model. And with the atomic swap the OLD transcript stays visible until
// the rebuild's history load returns — mid-rebuild the model still shows the pre-resync content
// (the question + "old event A"), never a blank, and the live event is not yet in it (feeding it
// here as a third item would fail this assertion).
const live = at(assistantText("output during rebuild"), "2026-07-05T00:00:02.000Z");
h.controller.handleOmni(live);
expect(h.controller.model.items).toHaveLength(0);
expect(h.controller.model.items.map((i) => i.kind)).toEqual(["user_text", "assistant_text"]);
// Second round of history (authoritative) returns: the transferred task_state and
// buffered events replay in order.
h.resolveLoad([
@@ -278,4 +281,37 @@ describe("history load failure and retry (#6)", () => {
await h.controller.retry();
expect(h.loadCalls()).toBe(1);
});
it("retry after a FAILED resync rebuild rebuilds into a fresh model (no transcript duplication)", async () => {
// A successful initial load leaves the transcript populated; a mid-stream resync whose refetch
// then fails deliberately keeps that old transcript on screen (the atomic swap only replaces it
// on success). Retry must therefore push the refetched history into a FRESH model — pushing it
// onto the retained one would duplicate the whole conversation (regression guard).
const h = createHarness();
const p = h.controller.load();
h.resolveLoad([
at(userText("q1"), "2026-07-05T00:00:00.000Z"),
at(assistantText("a1"), "2026-07-05T00:00:01.000Z"),
]);
await p;
expect(h.controller.model.items.map((i) => i.kind)).toEqual(["user_text", "assistant_text"]);
// Resync mid-session, but the rebuild's history refetch fails.
h.controller.handleServer({ type: "resync_required" });
h.rejectLoad(new Error("network error"));
await flush();
expect(h.errors[h.errors.length - 1]).toBe("network error");
// The old transcript is retained (not blanked) while the error/Retry state is shown.
expect(h.controller.model.items.map((i) => i.kind)).toEqual(["user_text", "assistant_text"]);
// Retry succeeds: the identical history must land in a fresh model, not be appended onto the retained one.
const retryP = h.controller.retry();
h.resolveLoad([
at(userText("q1"), "2026-07-05T00:00:00.000Z"),
at(assistantText("a1"), "2026-07-05T00:00:01.000Z"),
]);
await retryP;
expect(h.controller.model.items.map((i) => i.kind)).toEqual(["user_text", "assistant_text"]);
expect(h.controller.model.items.filter((i) => i.kind === "user_text")).toHaveLength(1);
});
});
+16
View File
@@ -75,4 +75,20 @@ describe("createStreamFollow", () => {
f.scrolled({ scrollHeight: 2000, clientHeight: 460, scrollTop: 1000 });
expect(f.stick).toBe(false);
});
it("resume (back-to-bottom button) re-enters follow, and the programmatic jump to the bottom keeps it stuck", () => {
const f = createStreamFollow();
f.scrolled({ scrollHeight: 2000, clientHeight: 460, scrollTop: 1540 });
f.scrolled({ scrollHeight: 2000, clientHeight: 460, scrollTop: 200 }); // dragged far up, exits.
expect(f.stick).toBe(false);
f.resume();
expect(f.stick).toBe(true);
// The caller sets scrollTop = scrollHeight right after; the resulting scroll event lands
// at the bottom and must not be judged against the stale scrollTop=200 as "moved down then
// wherever" — following continues, and streaming growth keeps sticking.
f.scrolled({ scrollHeight: 2000, clientHeight: 460, scrollTop: 1540 });
expect(f.stick).toBe(true);
f.scrolled({ scrollHeight: 2400, clientHeight: 460, scrollTop: 1940 }); // next streamed stick.
expect(f.stick).toBe(true);
});
});
+33 -23
View File
@@ -1,10 +1,11 @@
/**
* work-summary.ts unit tests (issue #76): group header duration is computed as the union
* of time intervals — overlapping time from parallel tools counts once; sequential calls
* accumulate as usual (gaps don't count); approval waits are excluded per the durationMs
* convention; the argument-generation segment and execution segment are separate intervals
* (generation is not shifted into the execution period); items missing a start point fall
* back to direct accumulation.
* work-summary.ts unit tests: the group header duration is the group's real wall-clock
* span — earliest segment start → latest segment end — including approval waits and the
* gaps between steps (the header answers "how long did this group take"; per-item cards
* keep the fine-grained settled durations). Parallel work counts once by construction.
* Items missing a start point fall back to direct accumulation on top of the span; the
* returned startMs is the earliest start stamp of ANY item (settled or not) — the anchor
* the header ticks from while the group is still running.
*/
import { describe, expect, it } from "vitest";
import type { ChatItem } from "../src/lib/omni/stream-model";
@@ -41,56 +42,65 @@ const tool = (
});
describe("summarizeWork", () => {
it("overlapping time of parallel tools counts once (15-way parallel for 9 minutes no longer reports 99 minutes)", () => {
it("parallel work counts once: 15-way parallel over 9 minutes reports 9 minutes", () => {
const nine = 9 * 60_000;
const items = Array.from({ length: 15 }, () => tool({ start: 0, durationMs: nine }));
expect(summarizeWork(items)).toEqual({ steps: 15, durationMs: nine });
expect(summarizeWork(items)).toEqual({ steps: 15, durationMs: nine, startMs: 0 });
});
it("partial overlaps merge as a union", () => {
it("staggered parallel tools span first start → last end", () => {
const items = [
tool({ start: 0, durationMs: 60_000 }),
tool({ start: 10_000, durationMs: 60_000 }),
tool({ start: 20_000, durationMs: 70_000 }),
];
expect(summarizeWork(items)).toEqual({ steps: 3, durationMs: 90_000 });
expect(summarizeWork(items)).toEqual({ steps: 3, durationMs: 90_000, startMs: 0 });
});
it("sequential calls accumulate as usual; gaps do not count", () => {
it("gaps between sequential steps count toward the span", () => {
const items = [
tool({ start: 0, durationMs: 10_000 }),
tool({ start: 15_000, durationMs: 10_000 }),
];
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 20_000 });
// [0,10s] then a 5s gap then [15s,25s]: the group took 25s of wall time.
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 25_000, startMs: 0 });
});
it("thinking and tools merge on the same axis; thinking does not count as a step", () => {
it("thinking and tools share the same axis; thinking does not count as a step", () => {
const items = [thinking(0, 5_000), tool({ start: 5_000, durationMs: 10_000 })];
expect(summarizeWork(items)).toEqual({ steps: 1, durationMs: 15_000 });
expect(summarizeWork(items)).toEqual({ steps: 1, durationMs: 15_000, startMs: 0 });
});
it("approval waits excluded: intervals start at approvalAtMs", () => {
it("approval waits are included: the span runs from the call start, not the approval", () => {
const items = [
// Call ready at 0, human approves at 100s, execution 100-105s.
tool({ start: 0, approvalAt: 100_000, durationMs: 5_000 }),
tool({ start: 102_000, durationMs: 8_000 }),
];
// [100s,105s] ∪ [102s,110s] = 10s; starting from callStartedAtMs by mistake would include the 100s approval wait.
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 10_000 });
// Span 0 → 110s: the 100s spent waiting for the human is part of how long the group took.
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 110_000, startMs: 0 });
});
it("argument-generation and execution are separate intervals: generation is not shifted into the execution period", () => {
it("argument generation anchors the start; execution end anchors the end", () => {
const items = [
// A: arg generation 0-10s, approval wait 10-100s, execution 100-110s (durationMs = 10s generation + 10s execution).
// A: arg generation 0-10s, approval wait 10-100s, execution 100-110s (durationMs = 10s + 10s).
tool({ argStart: 0, start: 10_000, approvalAt: 100_000, durationMs: 20_000 }),
// B: execution 110-120s. If A were computed entirely from its execution start ([100s,120s]), it would fully overlap with B, leaving only 20s.
// B: execution 110-120s.
tool({ start: 110_000, durationMs: 10_000 }),
];
// Correct union: [0,10s] ∪ [100s,120s] = 30s.
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 30_000 });
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 120_000, startMs: 0 });
});
it("items missing a start point fall back to direct accumulation; items without a duration only count as steps", () => {
const items = [tool({ start: 0, durationMs: 10_000 }), tool({ durationMs: 7_000 }), tool()];
expect(summarizeWork(items)).toEqual({ steps: 3, durationMs: 17_000 });
expect(summarizeWork(items)).toEqual({ steps: 3, durationMs: 17_000, startMs: 0 });
});
it("a still-streaming first item already anchors startMs (live tick before anything settles)", () => {
expect(summarizeWork([thinking(1_000)])).toEqual({ steps: 0, durationMs: 0, startMs: 1_000 });
});
it("no timestamps at all: no startMs key", () => {
expect(summarizeWork([tool({ durationMs: 7_000 })])).toEqual({ steps: 1, durationMs: 7_000 });
});
});