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
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13873-api-v1-changelog-names-the-running-commi → main 5 commits fork
10 files
changed +49
−12
src/contract/openapi/routes/getApiV1Changelog.ts +1 −1
| @@ -3,7 +3,7 @@ import type { Route } from "../shared.ts"; | ||
| 3 | 3 | export const route: Route = { |
| 4 | 4 | method: "get", |
| 5 | 5 | 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", | |
| 7 | 7 | alsoStatus: [304], |
| 8 | 8 | auth: false, |
| 9 | 9 | role: "anonymous", |
src/kernel/version.ts +4 −1
| @@ -50,9 +50,12 @@ export function running( | ||
| 50 | 50 | export function runningLine(r: Running = running()): string { |
| 51 | 51 | return r.commit === null |
| 52 | 52 | ? r.version |
| 53 | : `${r.version} · ${r.commit.slice(0, 7)}`; | |
| 53 | : `${r.version} · ${shortOf(r.commit)}`; | |
| 54 | 54 | } |
| 55 | 55 | |
| 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 | ||
| 56 | 59 | const RELEASE = /^\d+\.\d+\.\d+$/; |
| 57 | 60 | |
| 58 | 61 | /** |
src/release/answer.ts +5 −2
| @@ -8,7 +8,7 @@ import type { App } from "../app.ts"; | ||
| 8 | 8 | import { listPublicReleases } from "../core/app_releases.ts"; |
| 9 | 9 | import { getRepoById } from "../core/repos.ts"; |
| 10 | 10 | import type { User } from "../core/users.ts"; |
| 11 | import { running } from "../kernel/version.ts"; | |
| 11 | import { releaseOf, running, shortOf } from "../kernel/version.ts"; | |
| 12 | 12 | import { BOOTED, mayRead } from "./gate.ts"; |
| 13 | 13 | import { chosenRepo, readLandings, type Landing, type Landings } from "./landings.ts"; |
| 14 | 14 | import { keeperReleaseOfSha, type Stage } from "../keeper/record.ts"; |
| @@ -54,8 +54,11 @@ export async function shippedAnswer(app: App, asked: string | null = null) { | ||
| 54 | 54 | // else is all. |
| 55 | 55 | const named = asked !== null && /^[^/\s]{1,80}\/[^/\s]{1,80}$/.test(asked) ? asked : undefined; |
| 56 | 56 | 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 }), | |
| 58 | 59 | commit: read.commit, |
| 60 | short: read.commit === null ? null : shortOf(read.commit), | |
| 61 | liveSince: BOOTED, | |
| 59 | 62 | live: read.live.filter(keep), |
| 60 | 63 | onItsWay: read.onItsWay.filter(keep), |
| 61 | 64 | releases: listPublicReleases(app.db, 50, named), |
src/web/feeds.ts +1 −1
| @@ -257,7 +257,7 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> { | ||
| 257 | 257 | const live = answer.live.slice(0, CHANGELOG_ENTRIES); |
| 258 | 258 | const { tip, waves } = await timePhaseAsync(ctx.request, "waves", () => ownWaves(ctx)); |
| 259 | 259 | 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]); | |
| 261 | 261 | const headers = { etag, "cache-control": "public, max-age=300" }; |
| 262 | 262 | if (holds(ctx.request.headers.get("if-none-match"), etag)) return new Response(null, { status: 304, headers }); |
| 263 | 263 | 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> { | ||
| 415 | 415 | // The answer is the same for every viewer (public repositories only), so a shared cache may keep |
| 416 | 416 | // it. |
| 417 | 417 | 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("")]); | |
| 419 | 419 | const headers = { etag, "cache-control": "public, max-age=5" }; |
| 420 | 420 | if (holds(ctx.request.headers.get("if-none-match"), etag)) return new Response(null, { status: 304, headers }); |
| 421 | 421 | return json(answer, 200, headers); |
src/web/pages/status.ts +11 −1
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | import { statusJson, statusWords, WORD, type StatusWords } from "../../core/status_words.ts"; |
| 13 | 13 | import type { Ctx } from "../../http/context.ts"; |
| 14 | 14 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; |
| 15 | import { releaseOf, running, shortOf } from "../../kernel/version.ts"; | |
| 15 | 16 | import { stylesheetAsset } from "../asset.ts"; |
| 16 | 17 | import { html } from "../html.ts"; |
| 17 | 18 | import { badge } from "../ui.ts"; |
| @@ -49,6 +50,15 @@ function markup(words: StatusWords): string { | ||
| 49 | 50 | return text; |
| 50 | 51 | } |
| 51 | 52 | |
| 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 | ||
| 52 | 62 | const CSP = |
| 53 | 63 | "default-src 'none'; style-src 'self'; img-src 'self' data:; form-action 'none'; base-uri 'none'; frame-ancestors 'none'"; |
| 54 | 64 | |
| @@ -61,7 +71,7 @@ export function statusPage(ctx: Ctx): Response { | ||
| 61 | 71 | ctx.request, |
| 62 | 72 | "render", |
| 63 | 73 | () => |
| 64 | new Response(JSON.stringify(statusJson(words)), { | |
| 74 | new Response(JSON.stringify({ ...statusJson(words), ...runningFields() }), { | |
| 65 | 75 | headers: { "cache-control": "public, max-age=10", vary: "accept", "content-type": "application/json" }, |
| 66 | 76 | }), |
| 67 | 77 | ); |
src/web/standards.ts +2 −2
| @@ -55,7 +55,7 @@ import { OAUTH_SCOPES } from "../core/oauth.ts"; | ||
| 55 | 55 | import { agentCard, serverCard, toolsKey, apiCatalog, cardsLine, DISCOVERY, mcpCard, offeredPlugins, mcpPointers, offeredPluginRepo, pluginSource } from "../core/mcp_card.ts"; |
| 56 | 56 | import { forgeDocument } from "../core/standards_index.ts"; |
| 57 | 57 | import { TAGS } from "../contract/served.ts"; |
| 58 | import { running, UNSTAMPED } from "../kernel/version.ts"; | |
| 58 | import { running, shortOf, UNSTAMPED } from "../kernel/version.ts"; | |
| 59 | 59 | import { GUIDE } from "../view/guide.ts"; |
| 60 | 60 | import { loadMcp } from "../http/mcp/load.ts"; |
| 61 | 61 | import { timePhase, timePhaseAsync } from "../core/route_timing.ts"; |
| @@ -444,7 +444,7 @@ function runningSentence(): string { | ||
| 444 | 444 | const r = running(); |
| 445 | 445 | // A bare `dev` tells an agent nothing: say plainly that the build is unstamped. |
| 446 | 446 | 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)}`; | |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
src/web/studio/cards.ts +3 −1
| @@ -831,7 +831,9 @@ export function cardFor( | ||
| 831 | 831 | const live = list(v["live"]).map(obj); |
| 832 | 832 | const onItsWay = list(v["onItsWay"]).map(obj); |
| 833 | 833 | 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`; | |
| 835 | 837 | const row = (l: Record<string, unknown>, way: boolean): CardRow => { |
| 836 | 838 | const repo = text(l["repo"]); |
| 837 | 839 | const number = text(l["number"]); |
test/changelog-api.test.ts +20 −1
| @@ -73,11 +73,30 @@ describe("GET /api/v1/changelog", () => { | ||
| 73 | 73 | expect(res.status).toBe(200); |
| 74 | 74 | const b: any = await res.json(); |
| 75 | 75 | 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); | |
| 77 | 79 | const row = [...b.live, ...b.onItsWay][0]; |
| 78 | 80 | expect(Object.keys(row).sort()).toEqual(["at", "live", "number", "repo", "title"]); |
| 79 | 81 | }); |
| 80 | 82 | |
| 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 | ||
| 81 | 100 | test("the repo filter: all, one, and everything when the forge has no repository of its own", async () => { |
| 82 | 101 | expect(titles(await (await get("?repo=all")).json())).toEqual(["Other repo landing", "Public landing"]); |
| 83 | 102 | 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", () => { | ||
| 174 | 174 | const card = res.structuredContent.card; |
| 175 | 175 | expect(card.kind).toBe("releases"); |
| 176 | 176 | 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(" · ")}`); | |
| 178 | 178 | const all = [...json.live, ...json.onItsWay]; |
| 179 | 179 | expect(card.rows.length).toBe(Math.min(20, all.length)); |
| 180 | 180 | json.live.slice(0, card.rows.length).forEach((l: any, i: number) => { |
new above
offline