Public: anyone can read this; the crew can change it.

/api/v1/changelog names the running commit's short id and when it went live instead of the word dev #13901

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/13873-api-v1-changelog-names-the-running-commi → main 5 commits fork

  • Merged. scout/13873-api-v1-changelog-names-the-running-commi was merged into main as 893a6aa.

Review

Sign in to review this change.
10 files changed +49 −12
src/contract/openapi/routes/getApiV1Changelog.ts +1 −1
@@ -3,7 +3,7 @@ import type { Route } from "../shared.ts";
33 export const route: Route = {
44 method: "get",
55 path: "/api/v1/changelog",
6 summary: "What went live and what is on its way, as /changelog shows it, for anyone: version, commit, releases (each version a public app's production deploy first served: repo, version, commit, subject, note, tests, servingMs, servedAt; ?repo narrows them), live and onItsWay rows (repo, number, title, at, and for the forge's own landings by: who built it, with: the models and people its commit credits) of public repositories; ?repo=all|owner/name, this forge's own by default (all when it has none); carries a weak ETag of the live version, the chosen repo and the rows, and a repeat sending If-None-Match gets 304 with no body and the same ETag and cache-control",
6 summary: "What went live and what is on its way, as /changelog shows it, for anyone: version (the release number, or null for a build that is not a release, never the word dev), commit, short (its first 7 characters, null without a commit), liveSince (ISO: when this build began serving), releases (each version a public app's production deploy first served: repo, version, commit, subject, note, tests, servingMs, servedAt; ?repo narrows them), live and onItsWay rows (repo, number, title, at, and for the forge's own landings by: who built it, with: the models and people its commit credits) of public repositories; ?repo=all|owner/name, this forge's own by default (all when it has none); carries a weak ETag of the live version, the chosen repo and the rows, and a repeat sending If-None-Match gets 304 with no body and the same ETag and cache-control",
77 alsoStatus: [304],
88 auth: false,
99 role: "anonymous",
src/kernel/version.ts +4 −1
@@ -50,9 +50,12 @@ export function running(
5050 export function runningLine(r: Running = running()): string {
5151 return r.commit === null
5252 ? r.version
53 : `${r.version} · ${r.commit.slice(0, 7)}`;
53 : `${r.version} · ${shortOf(r.commit)}`;
5454 }
5555
56 /** The short id of a commit, seven characters: the one form every door prints. */
57 export const shortOf = (commit: string): string => commit.slice(0, 7);
58
5659 const RELEASE = /^\d+\.\d+\.\d+$/;
5760
5861 /**
src/release/answer.ts +5 −2
@@ -8,7 +8,7 @@ import type { App } from "../app.ts";
88 import { listPublicReleases } from "../core/app_releases.ts";
99 import { getRepoById } from "../core/repos.ts";
1010 import type { User } from "../core/users.ts";
11 import { running } from "../kernel/version.ts";
11 import { releaseOf, running, shortOf } from "../kernel/version.ts";
1212 import { BOOTED, mayRead } from "./gate.ts";
1313 import { chosenRepo, readLandings, type Landing, type Landings } from "./landings.ts";
1414 import { keeperReleaseOfSha, type Stage } from "../keeper/record.ts";
@@ -54,8 +54,11 @@ export async function shippedAnswer(app: App, asked: string | null = null) {
5454 // else is all.
5555 const named = asked !== null && /^[^/\s]{1,80}\/[^/\s]{1,80}$/.test(asked) ? asked : undefined;
5656 return {
57 version: read.version,
57 // The release number, or null for a build that is not one: never the word "dev".
58 version: releaseOf({ version: read.version, commit: read.commit }),
5859 commit: read.commit,
60 short: read.commit === null ? null : shortOf(read.commit),
61 liveSince: BOOTED,
5962 live: read.live.filter(keep),
6063 onItsWay: read.onItsWay.filter(keep),
6164 releases: listPublicReleases(app.db, 50, named),
src/web/feeds.ts +1 −1
@@ -257,7 +257,7 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> {
257257 const live = answer.live.slice(0, CHANGELOG_ENTRIES);
258258 const { tip, waves } = await timePhaseAsync(ctx.request, "waves", () => ownWaves(ctx));
259259 const [ownerName = "", repoName = ""] = (ctx.app.config.forgeRepo ?? "").split("/");
260 const etag = changelogTag(answer.version, live, [tip]);
260 const etag = changelogTag(answer.version ?? "dev", live, [tip]);
261261 const headers = { etag, "cache-control": "public, max-age=300" };
262262 if (holds(ctx.request.headers.get("if-none-match"), etag)) return new Response(null, { status: 304, headers });
263263 const waveOf = new Map<string, Wave>();
src/web/pages/changelog.ts +1 −1
@@ -415,7 +415,7 @@ export async function changelogJson(ctx: Ctx): Promise<Response> {
415415 // The answer is the same for every viewer (public repositories only), so a shared cache may keep
416416 // it.
417417 const { releases } = answer;
418 const etag = changelogTag(answer.version, [...answer.live, ...answer.onItsWay], [asked ?? "", answer.live.length, releases.length, releases[0]?.servedAt ?? "", releases.map((r) => r.tests[0]).join("")]);
418 const etag = changelogTag(answer.version ?? "dev", [...answer.live, ...answer.onItsWay], [asked ?? "", answer.live.length, releases.length, releases[0]?.servedAt ?? "", releases.map((r) => r.tests[0]).join("")]);
419419 const headers = { etag, "cache-control": "public, max-age=5" };
420420 if (holds(ctx.request.headers.get("if-none-match"), etag)) return new Response(null, { status: 304, headers });
421421 return json(answer, 200, headers);
src/web/pages/status.ts +11 −1
@@ -12,6 +12,7 @@
1212 import { statusJson, statusWords, WORD, type StatusWords } from "../../core/status_words.ts";
1313 import type { Ctx } from "../../http/context.ts";
1414 import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts";
15 import { releaseOf, running, shortOf } from "../../kernel/version.ts";
1516 import { stylesheetAsset } from "../asset.ts";
1617 import { html } from "../html.ts";
1718 import { badge } from "../ui.ts";
@@ -49,6 +50,15 @@ function markup(words: StatusWords): string {
4950 return text;
5051 }
5152
53 /**
54 * What is running, as /api/v1/changelog says it: the release number or null, the commit and its
55 * short id.
56 */
57 function runningFields(): { version: string | null; commit: string | null; short: string | null } {
58 const r = running();
59 return { version: releaseOf(r), commit: r.commit, short: r.commit === null ? null : shortOf(r.commit) };
60 }
61
5262 const CSP =
5363 "default-src 'none'; style-src 'self'; img-src 'self' data:; form-action 'none'; base-uri 'none'; frame-ancestors 'none'";
5464
@@ -61,7 +71,7 @@ export function statusPage(ctx: Ctx): Response {
6171 ctx.request,
6272 "render",
6373 () =>
64 new Response(JSON.stringify(statusJson(words)), {
74 new Response(JSON.stringify({ ...statusJson(words), ...runningFields() }), {
6575 headers: { "cache-control": "public, max-age=10", vary: "accept", "content-type": "application/json" },
6676 }),
6777 );
src/web/standards.ts +2 −2
@@ -55,7 +55,7 @@ import { OAUTH_SCOPES } from "../core/oauth.ts";
5555 import { agentCard, serverCard, toolsKey, apiCatalog, cardsLine, DISCOVERY, mcpCard, offeredPlugins, mcpPointers, offeredPluginRepo, pluginSource } from "../core/mcp_card.ts";
5656 import { forgeDocument } from "../core/standards_index.ts";
5757 import { TAGS } from "../contract/served.ts";
58 import { running, UNSTAMPED } from "../kernel/version.ts";
58 import { running, shortOf, UNSTAMPED } from "../kernel/version.ts";
5959 import { GUIDE } from "../view/guide.ts";
6060 import { loadMcp } from "../http/mcp/load.ts";
6161 import { timePhase, timePhaseAsync } from "../core/route_timing.ts";
@@ -444,7 +444,7 @@ function runningSentence(): string {
444444 const r = running();
445445 // A bare `dev` tells an agent nothing: say plainly that the build is unstamped.
446446 const what = r.version === UNSTAMPED ? "a build from source" : r.version;
447 return r.commit === null ? `Running ${what}` : `Running ${what} at ${r.commit.slice(0, 7)}`;
447 return r.commit === null ? `Running ${what}` : `Running ${what} at ${shortOf(r.commit)}`;
448448 }
449449
450450 /**
src/web/studio/cards.ts +3 −1
@@ -831,7 +831,9 @@ export function cardFor(
831831 const live = list(v["live"]).map(obj);
832832 const onItsWay = list(v["onItsWay"]).map(obj);
833833 const commit = text(v["commit"]);
834 status = `live ${text(v["version"])}${commit === "" ? "" : ` · ${commit.slice(0, 7)}`} · ${live.length} shipped · ${onItsWay.length} on its way`;
834 const version = text(v["version"]);
835 const short = text(v["short"]) || commit.slice(0, 7);
836 status = `live ${[version, short].filter((x) => x !== "").join(" · ") || "build"} · ${live.length} shipped · ${onItsWay.length} on its way`;
835837 const row = (l: Record<string, unknown>, way: boolean): CardRow => {
836838 const repo = text(l["repo"]);
837839 const number = text(l["number"]);
test/changelog-api.test.ts +20 −1
@@ -73,11 +73,30 @@ describe("GET /api/v1/changelog", () => {
7373 expect(res.status).toBe(200);
7474 const b: any = await res.json();
7575 expect(b.commit).toBe("a".repeat(40));
76 expect(typeof b.version).toBe("string");
76 expect(b.version).toBeNull();
77 expect(b.short).toBe("aaaaaaa");
78 expect(new Date(b.liveSince).toISOString()).toBe(b.liveSince);
7779 const row = [...b.live, ...b.onItsWay][0];
7880 expect(Object.keys(row).sort()).toEqual(["at", "live", "number", "repo", "title"]);
7981 });
8082
83 test("a release build names its number; /status JSON and llms.txt print the same short id", async () => {
84 const savedVersion = process.env["FORGE_VERSION"];
85 process.env["FORGE_VERSION"] = "1.2.3";
86 try {
87 const b: any = await (await get("")).json();
88 expect(b.version).toBe("1.2.3");
89 expect(b.short).toBe("aaaaaaa");
90 const status: any = await (await fetch(`${servers.url}/status`, { headers: { accept: "application/json" } })).json();
91 expect(status.short).toBe(b.short);
92 expect(status.version).toBe("1.2.3");
93 expect(await (await fetch(`${servers.url}/llms.txt`)).text()).toContain("Running 1.2.3 at aaaaaaa");
94 } finally {
95 if (savedVersion === undefined) delete process.env["FORGE_VERSION"];
96 else process.env["FORGE_VERSION"] = savedVersion;
97 }
98 });
99
81100 test("the repo filter: all, one, and everything when the forge has no repository of its own", async () => {
82101 expect(titles(await (await get("?repo=all")).json())).toEqual(["Other repo landing", "Public landing"]);
83102 expect(titles(await (await get("?repo=alice/notes")).json())).toEqual(["Other repo landing"]);
test/mcp-releases-card.test.ts +1 −1
@@ -174,7 +174,7 @@ describe("MCP releases card", () => {
174174 const card = res.structuredContent.card;
175175 expect(card.kind).toBe("releases");
176176 expect(uris).toContain(`ui://forge/${card.kind}`);
177 expect(card.status).toContain(`live ${json.version}`);
177 expect(card.status).toContain(`live ${[json.version, json.short].filter(Boolean).join(" · ")}`);
178178 const all = [...json.live, ...json.onItsWay];
179179 expect(card.rows.length).toBe(Math.min(20, all.length));
180180 json.live.slice(0, card.rows.length).forEach((l: any, i: number) => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs