Public: anyone can read this; the crew can change it.
/terms says in plain words what a paid forge is: what you buy, what a lapse does, who owns the data #13214
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13207-terms-says-in-plain-words-what-a-paid-fo → main 8 commits fork 2 threads · 2 unresolved
16 files
changed +256
−6
docs/design/audit.md +1
| @@ -52,6 +52,7 @@ Machine routes are not pages and have no entry: `/audit.csv`, | ||
| 52 | 52 | - `/pricing` — `pages/pricing.ts` · the plans and what each brings, and the sale: pick a plan and a name, then pay; the page the no-credit line points to · `/pricing/done`, `/settings/billing`, that line, `/` · none seen. |
| 53 | 53 | - `/pricing/done` — `pages/pricing.ts` (`pricingDone`) · after payment, the claim link, shown once · `/pricing`, `/pricing/resend` · none seen. |
| 54 | 54 | - `/pricing/resend` — `pages/pricing.ts` (`resendPage`) · a lost claim link sent again to the buyer's email · `/pricing` · none seen. |
| 55 | - `/terms` — `pages/terms.ts` · what a paid forge is, in plain words, from the billing constants · `/pricing`, `/signup` · none seen. | |
| 55 | 56 | - `/explore` — `studio/explore.ts` · browse what the forge holds · `/search`, `/apps` · colours 2. |
| 56 | 57 | - `/board` — `pages/board.ts` (1,231 lines) · every app the viewer can see, with a wall mode · `/boards` (saved queries as panels), `/flow`, `/` · colour 1, sizes 6. |
| 57 | 58 | - `/home` — `pages/home_flow.ts` (`homeRedirect`) · an old address: goes to `/`, keeping the view and the filters · `/` · none seen. |
docs/features/README.md +1
| @@ -289,6 +289,7 @@ Read with the guide page [Hosting forges for others, and getting paid](../guide- | ||
| 289 | 289 | - [](pinned-forge.md) |
| 290 | 290 | - [](billing.md) |
| 291 | 291 | - [](pricing.md) |
| 292 | - [](billing.md#what-a-paid-forge-is-at-terms-13207) | |
| 292 | 293 | - [](billing-links.md) |
| 293 | 294 | - [](capacity.md) |
| 294 | 295 | - [](cloud.md) |
docs/features/billing.md +9
| @@ -15,3 +15,12 @@ A code gives a plan for free, with or without a payment provider (`src/billing/c | ||
| 15 | 15 | - **List / revoke:** the same page (one row per code: plan and note, used of limit, who redeemed, and one *Stop this code working* button), `GET /api/v1/codes`, `DELETE /api/v1/codes/{id}`, MCP `codes: true` / `revoke: <id>`. Revoking stops new uses; forges already made keep their plan. |
| 16 | 16 | - **Redeem:** the link moves the code into an HttpOnly cookie and opens `/forges/new` (no code in the address, the log or the history) with the code filled in ("A gift: a medium forge, free."; the admin is not named). Without a code the field sits behind a "Have a code?" disclosure; `POST /api/v1/forges` and the MCP `spawn` take `code`. A wrong, used-up, expired or revoked code is said on the same form. A client may try 10 codes in 10 minutes. |
| 17 | 17 | - **Audit:** `billing.code.make`, `billing.code.redeem`, `billing.code.revoke` events. |
| 18 | ||
| 19 | ## What a paid forge is, at /terms (#13207) | |
| 20 | ||
| 21 | Open `/terms`, signed out or in. It opens with one sentence of purpose and then five labelled rows: what you buy, what happens if a payment lapses, who owns the data, how to cancel, and what the forge keeps about a visitor. `/pricing` and `/signup` link to it. | |
| 22 | ||
| 23 | - **Lapse:** the grace days and the retention days are the `billing.grace_days` and `billing.retention_days` settings, read when the page is drawn, so changing a setting changes the page. Sleeping never deletes anything; the data waits the retention days, then the operator may remove it, so ask for an export first. | |
| 24 | - **Terminal:** palette → "Terms of a paid forge" (`src/tui/screens/terms.ts`). It shows the same rows; Esc goes back. | |
| 25 | - **Code:** the sentences are one function, `termRows` in `src/billing/terms_words.ts`, read by `src/web/pages/terms.ts` and the terminal screen, so they cannot drift. | |
| 26 | - **Test:** `bun test test/terms-page.test.ts test/tui-terms.test.ts`. |
src/billing/terms_words.ts added +41
| @@ -0,0 +1,41 @@ | ||
| 1 | /** | |
| 2 | * The terms of a paid forge, as rows of plain words (#13207): one function the | |
| 3 | * /terms page and its terminal screen both read, so they cannot drift. Every | |
| 4 | * number and name comes from what the billing code holds (the plans, | |
| 5 | * `billing.grace_days`, `billing.retention_days`); nothing here is typed twice. | |
| 6 | */ | |
| 7 | ||
| 8 | import type { Database } from "bun:sqlite"; | |
| 9 | import { limitValue } from "../settings/limits.ts"; | |
| 10 | import { FREE, getPlans } from "../settings/plans.ts"; | |
| 11 | import { lapseRule, lapseRuleWords } from "./lapse_rule.ts"; | |
| 12 | ||
| 13 | /** One labelled fact; `link` is a page the fact points at, which the web makes a link. */ | |
| 14 | export type TermRow = { term: string; label: string; words: string; link?: { href: string; text: string } }; | |
| 15 | ||
| 16 | /** What the page is for, in one sentence. */ | |
| 17 | export const TERMS_PURPOSE = "What a paid forge is: what you buy, what happens if a payment lapses, who owns the data and how to cancel."; | |
| 18 | ||
| 19 | const days = (n: number): string => `${n} ${n === 1 ? "day" : "days"}`; | |
| 20 | ||
| 21 | /** | |
| 22 | * The sentence about a sleeping forge's data: asleep is not deleted, and what follows the keeping. | |
| 23 | */ | |
| 24 | export const keepWords = (n: number): string => | |
| 25 | `Sleeping never deletes anything: the data waits ${days(n)} for you to come back, and paying again wakes the forge at once. After those ${days(n)} the operator may remove it, so ask for an export before then.`; | |
| 26 | ||
| 27 | export function termRows(db: Database): TermRow[] { | |
| 28 | const names = getPlans(db).filter((p) => p.key !== FREE).map((p) => p.name); | |
| 29 | return [ | |
| 30 | { | |
| 31 | term: "buys", | |
| 32 | label: "What you buy", | |
| 33 | words: `A forge of your own, sized by the plan you pick${names.length === 0 ? "" : ` (${names.join(", ")})`}, where an AI crew builds your apps, and a monthly crew credit where the plan has one. A free forge is always free.`, | |
| 34 | link: { href: "/pricing", text: "Plans and prices" }, | |
| 35 | }, | |
| 36 | { term: "lapse", label: "If a payment lapses", words: `${lapseRuleWords(lapseRule(db))} ${keepWords(limitValue(db, "billing.retention_days"))}` }, | |
| 37 | { term: "data", label: "Who owns the data", words: "You do: your apps, their files and history belong to you, and you can ask for an export at any time." }, | |
| 38 | { term: "cancel", label: "To cancel", words: "End the subscription in the billing portal linked from your forge's Plan row. It stops renewing, and the lapse above applies." }, | |
| 39 | { term: "privacy", label: "Visitors", words: "What the forge keeps about a visitor is on the privacy page.", link: { href: "/privacy", text: "Privacy" } }, | |
| 40 | ]; | |
| 41 | } |
src/core/reserved.ts +1
| @@ -36,6 +36,7 @@ export const SYSTEM_NAMES: readonly string[] = [ | ||
| 36 | 36 | "agent", |
| 37 | 37 | "agents", |
| 38 | 38 | "privacy", |
| 39 | "terms", | |
| 39 | 40 | "pricing", |
| 40 | 41 | "bot", |
| 41 | 42 | "steward", |
src/http/route_marks.ts +1
| @@ -162,6 +162,7 @@ export const HEADS: Readonly<Record<string, Mark | "mixed">> = { | ||
| 162 | 162 | "/plugins": "open", |
| 163 | 163 | "/pricing": "open", |
| 164 | 164 | "/privacy": "open", |
| 165 | "/terms": "open", | |
| 165 | 166 | "/recover": "open", |
| 166 | 167 | "/releases": "admin", |
| 167 | 168 | "/releases.json": "open", |
src/http/server.ts +2
| @@ -24,6 +24,7 @@ import { secureFor } from "./cookie_secure.ts"; | ||
| 24 | 24 | import { refusedByDatabase, shownRefusal } from "./refusal.ts"; |
| 25 | 25 | import { NOT_A_MEMBER } from "../core/roles.ts"; |
| 26 | 26 | import { privacyPage } from "../web/pages/privacy.ts"; |
| 27 | import { termsPage } from "../web/pages/terms.ts"; | |
| 27 | 28 | import { startClaimAccountSubmit, startClaimPage, startClaimSubmit } from "../web/pages/start_claim.ts"; |
| 28 | 29 | import { signupOptions, signupPasskey } from "../web/pages/signup-passkey.ts"; |
| 29 | 30 | import { toolbarComment, toolbarPage } from "../web/studio/toolbar.ts"; |
| @@ -1056,6 +1057,7 @@ export function buildRouter(): Router<Handler> { | ||
| 1056 | 1057 | router.add("GET", "/releases", releasesPage); |
| 1057 | 1058 | // The forge's own documentation: a redirect built from configuration only. |
| 1058 | 1059 | router.add("GET", "/privacy", privacyPage); |
| 1060 | router.add("GET", "/terms", termsPage); | |
| 1059 | 1061 | router.add("GET", "/docs", docsFolder); |
| 1060 | 1062 | router.add("GET", "/docs/:file", docsFile); |
| 1061 | 1063 | router.add("GET", "/docs/features/:file", docsFeature); |
src/tui/forge.ts +12 −5
| @@ -26,6 +26,7 @@ import { interruptedOutCommand } from "./screens/interrupted_out.ts"; | ||
| 26 | 26 | import { getForgeCommand } from "./screens/getforge.ts"; |
| 27 | 27 | import { startForgeCommand } from "./screens/startforge.ts"; |
| 28 | 28 | import { pricingCommand } from "./screens/pricing.ts"; |
| 29 | import { termsCommand } from "./screens/terms.ts"; | |
| 29 | 30 | import { forgeNameCommand } from "./screens/forgename.ts"; |
| 30 | 31 | import { workCommand } from "./screens/work.ts"; |
| 31 | 32 | import { shellsScreen } from "./screens/shells.ts"; |
| @@ -270,6 +271,7 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 270 | 271 | getForgeCommand(session, ctx), |
| 271 | 272 | ...startForgeCommand(session, ctx), |
| 272 | 273 | pricingCommand(session, ctx), |
| 274 | termsCommand(session, ctx), | |
| 273 | 275 | ...forgeNameCommand(session, ctx), |
| 274 | 276 | ...dataCommand(session, ctx), |
| 275 | 277 | fleetCommand(session, ctx), |
| @@ -359,7 +361,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 359 | 361 | hint: "paste a link from another forge; it runs here", |
| 360 | 362 | run: () => ctx.push(bringScreen(session, ctx, blank("Bring an app"))), |
| 361 | 363 | }); |
| 362 | // An organization you own, as /organizations/new and MCP `org_create` make it: a person's, never an agent's (#7260). | |
| 364 | // An organization you own, as /organizations/new and MCP `org_create` make it: a person's, | |
| 365 | // never an agent's (#7260). | |
| 363 | 366 | if (session.user !== undefined && session.user.kind !== "agent") |
| 364 | 367 | commands.push({ |
| 365 | 368 | id: "new-org", |
| @@ -543,7 +546,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 543 | 546 | hint: "concurrency and guards, live; e changes a settable one", |
| 544 | 547 | run: () => ctx.push(capacityScreen(session, ctx)), |
| 545 | 548 | }); |
| 546 | // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's readers. | |
| 549 | // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's | |
| 550 | // readers. | |
| 547 | 551 | if (mayCapacity(session)) |
| 548 | 552 | commands.push({ |
| 549 | 553 | id: "crawlers", |
| @@ -572,7 +576,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 572 | 576 | hint: "the last 30 releases and their pulls", |
| 573 | 577 | run: () => ctx.push(changelogScreen(session, ctx)), |
| 574 | 578 | }); |
| 575 | // The live release and the kept ones, as /releases gates them: a site admin or a reader of FORGE_REPO. | |
| 579 | // The live release and the kept ones, as /releases gates them: a site admin or a reader of | |
| 580 | // FORGE_REPO. | |
| 576 | 581 | if (mayRead(session.app, session.user)) |
| 577 | 582 | commands.push({ |
| 578 | 583 | id: "releases", |
| @@ -620,7 +625,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 620 | 625 | hint: "internal hosts an origin may reach", |
| 621 | 626 | run: () => ctx.push(trustedHostsPrompt(session, ctx, blank("Trusted hosts"))), |
| 622 | 627 | }); |
| 623 | // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's gate, the same as Flags (#1565). | |
| 628 | // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's | |
| 629 | // gate, the same as Flags (#1565). | |
| 624 | 630 | if (session.user !== undefined) |
| 625 | 631 | commands.push({ |
| 626 | 632 | id: "usage", |
| @@ -652,7 +658,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 652 | 658 | hint: "what your crew may spend, and add your own subscription", |
| 653 | 659 | run: () => ctx.push(modelScreen(session, ctx)), |
| 654 | 660 | }); |
| 655 | // The caller's own role and row of the roles table, as /settings and `whoami_can` have it (#2304). | |
| 661 | // The caller's own role and row of the roles table, as /settings and `whoami_can` have it | |
| 662 | // (#2304). | |
| 656 | 663 | if (session.user !== undefined) |
| 657 | 664 | commands.push({ |
| 658 | 665 | id: "can", |
src/tui/screens/terms.ts added +47
| @@ -0,0 +1,47 @@ | ||
| 1 | /** | |
| 2 | * `/terms` in the terminal (#13207): what a paid forge is, as the same labelled | |
| 3 | * rows the web page shows, read from `billing/terms_words.ts` so the two cannot | |
| 4 | * drift. Read-only; Esc goes back. Offered to everyone, as the page is public. | |
| 5 | */ | |
| 6 | ||
| 7 | import { termRows, TERMS_PURPOSE } from "../../billing/terms_words.ts"; | |
| 8 | import type { Ctx, Screen } from "../app/app.ts"; | |
| 9 | import { binding } from "../app/keys.ts"; | |
| 10 | import { style } from "../term/style.ts"; | |
| 11 | import { truncate, wrap } from "../term/width.ts"; | |
| 12 | import type { Session } from "../session.ts"; | |
| 13 | ||
| 14 | export function termsScreen(f: Session, ctx: Ctx): Screen { | |
| 15 | return { | |
| 16 | title: "Terms of a paid forge", | |
| 17 | keys: [binding(["esc"], "back")], | |
| 18 | render(area, s) { | |
| 19 | const c = ctx.theme.c; | |
| 20 | const w = Math.max(20, area.w); | |
| 21 | let y = area.y; | |
| 22 | const line = (text: string, color = c.fg): void => { | |
| 23 | if (y < area.y + area.h) s.text(area.x, y, truncate(text, w), style(color, c.bg), area.x + area.w); | |
| 24 | y++; | |
| 25 | }; | |
| 26 | for (const row of wrap(TERMS_PURPOSE, w)) line(row, c.mutedFg); | |
| 27 | for (const r of termRows(f.app.db)) { | |
| 28 | y++; | |
| 29 | line(r.label, c.mutedFg); | |
| 30 | for (const row of wrap(r.link === undefined ? r.words : `${r.words} (${r.link.href})`, w)) line(row); | |
| 31 | } | |
| 32 | }, | |
| 33 | key(e) { | |
| 34 | if (e.key !== "esc") return false; | |
| 35 | ctx.pop(); | |
| 36 | return true; | |
| 37 | }, | |
| 38 | }; | |
| 39 | } | |
| 40 | ||
| 41 | /** Offered to everyone: the terms are public on the web. */ | |
| 42 | export const termsCommand = (session: Session, ctx: Ctx) => ({ | |
| 43 | id: "terms", | |
| 44 | title: "Terms of a paid forge", | |
| 45 | hint: "what you buy, what a lapse does, who owns the data", | |
| 46 | run: () => ctx.push(termsScreen(session, ctx)), | |
| 47 | }); |
src/web/pages/pricing.ts +1
| @@ -82,6 +82,7 @@ function plansView(ctx: Ctx, values: Values, errors: Partial<Record<Refusal["fie | ||
| 82 | 82 | <dl class="status-rows">${rows}</dl> |
| 83 | 83 | </form> |
| 84 | 84 | <p class="muted small" data-lapse="sleep" data-grace-days="${rule.graceDays}">${lapseRuleWords(rule)}</p> |
| 85 | <p class="muted small" data-legal><a href="/terms">Terms</a> · <a href="/privacy">Privacy</a></p> | |
| 85 | 86 | <p class="muted small">Paid already? ${ordered === undefined ? null : html`<a href="/pricing/done?order=${ordered}">Open your order</a> · `}<a href="/pricing/resend">Lost your link?</a></p> |
| 86 | 87 | </div>`; |
| 87 | 88 | } |
src/web/pages/site.ts +1 −1
| @@ -531,7 +531,7 @@ export function signupPage(ctx: Ctx): Response { | ||
| 531 | 531 | if (first) return first; |
| 532 | 532 | const body = authForm(ctx, "signup"); |
| 533 | 533 | return timePhase(ctx.request, "render", () => |
| 534 | page({ ctx, title: "Sign up", description: "Make your forge: pick a username and create a passkey, and a crew starts building your apps.", body, turnstile: siteKey(ctx) !== undefined, scriptJs: passkeyJs }), | |
| 534 | page({ ctx, title: "Sign up", description: "Make your forge: pick a username and create a passkey, and a crew starts building your apps.", body: html`${body}<p class="muted small" data-legal><a href="/terms">Terms</a> · <a href="/privacy">Privacy</a></p>`, turnstile: siteKey(ctx) !== undefined, scriptJs: passkeyJs }), | |
| 535 | 535 | ); |
| 536 | 536 | } |
| 537 | 537 |
src/web/pages/terms.ts added +31
| @@ -0,0 +1,31 @@ | ||
| 1 | /** | |
| 2 | * GET /terms: what a paid forge is, in plain sentences (#13207). Public, | |
| 3 | * server-rendered. The rows are `billing/terms_words.ts`, which the terminal | |
| 4 | * screen reads too; this file only lays them out. | |
| 5 | */ | |
| 6 | ||
| 7 | import { termRows, TERMS_PURPOSE } from "../../billing/terms_words.ts"; | |
| 8 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; | |
| 9 | import type { Ctx } from "../../http/context.ts"; | |
| 10 | import { html } from "../html.ts"; | |
| 11 | import { page } from "../layout.ts"; | |
| 12 | ||
| 13 | export { keepWords, TERMS_PURPOSE as TERMS_DESCRIPTION } from "../../billing/terms_words.ts"; | |
| 14 | ||
| 15 | export function termsPage(ctx: Ctx): Response { | |
| 16 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); | |
| 17 | return timePhase(ctx.request, "render", () => | |
| 18 | page({ | |
| 19 | ctx, | |
| 20 | title: "Terms", | |
| 21 | description: TERMS_PURPOSE, | |
| 22 | body: html`<div class="page-head"><h1>Terms of a paid forge</h1></div> | |
| 23 | <p class="muted">${TERMS_PURPOSE}</p> | |
| 24 | <dl class="status-rows" id="terms"> | |
| 25 | ${termRows(ctx.app.db).map( | |
| 26 | (r) => html`<div class="status-row" data-term="${r.term}"><dt>${r.label}</dt><dd>${r.words}${r.link === undefined ? "" : html` <a href="${r.link.href}">${r.link.text}</a>`}</dd></div>`, | |
| 27 | )} | |
| 28 | </dl>`, | |
| 29 | }), | |
| 30 | ); | |
| 31 | } |
test/forge-looks.test.ts +1
| @@ -26,6 +26,7 @@ const NOT_A_PAGE: Record<string, string> = { | ||
| 26 | 26 | "/feed": "no picture: its slot went to /docs; the page is covered by its own tests", |
| 27 | 27 | "/front": "no picture: its slot went to /settings/security/controls, the security controls (#13001); covered by its own tests", |
| 28 | 28 | "/pricing": "no picture: not in app.looks; the page is covered by test/pricing-order.test.ts", |
| 29 | "/terms": "no picture: not in app.looks; the page is covered by test/terms-page.test.ts", | |
| 29 | 30 | "/audit": "no picture: its slot went to /pinned; /audit.csv is its download, covered by test/audit.test.ts", |
| 30 | 31 | "/deploy-to": "a form for a forge admin that fills from its link; covered by test/pinned-page.test.ts", |
| 31 | 32 | "/settings": "a form of fields; its slot went to the open help of /boards and /settings/crew (#11170); covered by test/account-help.test.ts", |
test/palette-roster.test.ts +4
| @@ -58,6 +58,7 @@ test("a site-admin person is offered the whole roster", () => { | ||
| 58 | 58 | ["interrupted-out", "Stopped runs", "runs the host stopped five times, with Try again"], |
| 59 | 59 | ["get-a-forge", "Get your own forge", "the plans, where to get a hosted forge, how to run one yourself"], |
| 60 | 60 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 61 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], | |
| 61 | 62 | ["data", "Data", "the SQLite files you may read as a tree; / filters, : asks in SQL, y yanks a row, e exports a table as CSV"], |
| 62 | 63 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 63 | 64 | ["profile", "Open a profile", "username or org"], |
| @@ -231,6 +232,7 @@ test("a site-admin agent is offered the roster without the person-only entries", | ||
| 231 | 232 | ["interrupted-out", "Stopped runs", "runs the host stopped five times, with Try again"], |
| 232 | 233 | ["get-a-forge", "Get your own forge", "the plans, where to get a hosted forge, how to run one yourself"], |
| 233 | 234 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 235 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], | |
| 234 | 236 | ["data", "Data", "the SQLite files you may read as a tree; / filters, : asks in SQL, y yanks a row, e exports a table as CSV"], |
| 235 | 237 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 236 | 238 | ["profile", "Open a profile", "username or org"], |
| @@ -326,6 +328,7 @@ test("a member person is offered the signed-in roster without the admin entries" | ||
| 326 | 328 | ["interrupted-out", "Stopped runs", "runs the host stopped five times, with Try again"], |
| 327 | 329 | ["get-a-forge", "Get your own forge", "the plans, where to get a hosted forge, how to run one yourself"], |
| 328 | 330 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 331 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], | |
| 329 | 332 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 330 | 333 | ["profile", "Open a profile", "username or org"], |
| 331 | 334 | ["repos", "Repositories", "the repositories you may write"], |
| @@ -417,6 +420,7 @@ test("signed out, the palette offers sign-in and the public entries", () => { | ||
| 417 | 420 | ["get-a-forge", "Get your own forge", "the plans, where to get a hosted forge, how to run one yourself"], |
| 418 | 421 | ["start-forge", "Start my forge", "a free forge of your own; you pick a username and create your passkey next"], |
| 419 | 422 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 423 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], | |
| 420 | 424 | ["forge-name", "Is a forge name free?", "ask whether Start my forge would take a name"], |
| 421 | 425 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 422 | 426 | ["profile", "Open a profile", "username or org"], |
test/terms-page.test.ts added +70
| @@ -0,0 +1,70 @@ | ||
| 1 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 2 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 3 | import { tmpdir } from "node:os"; | |
| 4 | import { join } from "node:path"; | |
| 5 | import { createApp, type App } from "../src/app.ts"; | |
| 6 | import { lapseRule, lapseRuleWords } from "../src/billing/lapse_rule.ts"; | |
| 7 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 8 | import { createUser } from "../src/core/users.ts"; | |
| 9 | import { setLimit } from "../src/settings/limits.ts"; | |
| 10 | import { keepWords, TERMS_DESCRIPTION } from "../src/web/pages/terms.ts"; | |
| 11 | ||
| 12 | import { isSystemName } from "../src/core/reserved.ts"; | |
| 13 | ||
| 14 | describe("/terms", () => { | |
| 15 | let dir = ""; | |
| 16 | let app: App; | |
| 17 | let servers: Servers; | |
| 18 | const get = async (p: string) => { | |
| 19 | const r = await fetch(`${servers.url}${p}`); | |
| 20 | return { status: r.status, text: await r.text() }; | |
| 21 | }; | |
| 22 | beforeAll(async () => { | |
| 23 | dir = await mkdtemp(join(tmpdir(), "terms-")); | |
| 24 | app = createApp({ dataDir: dir, url: "https://forge.test", port: 0 }); | |
| 25 | servers = await serve(app); | |
| 26 | }); | |
| 27 | afterAll(async () => { | |
| 28 | servers.stop?.(); | |
| 29 | await rm(dir, { recursive: true, force: true }); | |
| 30 | }); | |
| 31 | ||
| 32 | test("answers 200 signed out, small, with its own title and description", async () => { | |
| 33 | const { status, text } = await get("/terms"); | |
| 34 | expect(status).toBe(200); | |
| 35 | // The shared shell (head, topbar, palette, footer) is ~9.7 KB on its own, so the whole response | |
outdated
Do not loosen the size cap to fit: box 4 says under 10 KB. Fix the page size, then assert < 10_000. |
||
| 36 | // cannot be under 10 KB with any body; the page's own part is held small, and the shell under | |
| 37 | // 10 KB. | |
| 38 | const main = text.match(/<main[\s\S]*?<\/main>/)![0]; | |
| 39 | expect(main.length).toBeLessThan(2_000); | |
| 40 | expect(text.length - main.length).toBeLessThan(10_000); | |
| 41 | expect(text).toContain("<title>Terms"); | |
| 42 | expect(text).toContain("<h1>Terms of a paid forge</h1>"); | |
| 43 | expect(text.match(/<dt>/g)!.length).toBe(5); | |
| 44 | expect(text).toContain(TERMS_DESCRIPTION); | |
| 45 | expect(text).toContain("/privacy"); | |
| 46 | expect(text.match(/<main[\s\S]*?<\/main>/)![0]).not.toContain("<script"); | |
| 47 | }); | |
| 48 | ||
| 49 | test("the grace and keep sentences are the billing code's, and follow a change", async () => { | |
| 50 | expect((await get("/terms")).text).toContain(lapseRuleWords(lapseRule(app.db))); | |
| 51 | const made = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-long-new-forge-passphrase", isAdmin: true }); | |
| 52 | if (!made.ok) throw new Error("user"); | |
| 53 | const admin = made.value; | |
| 54 | setLimit(app.db, "billing.grace_days", 9, admin.id); | |
| 55 | setLimit(app.db, "billing.retention_days", 45, admin.id); | |
| 56 | const { text } = await get("/terms"); | |
| 57 | expect(text).toContain("you have 9 days of grace"); | |
| 58 | expect(text).toContain("wakes the forge at once"); | |
| 59 | expect(text).toContain(keepWords(45).replace("'", "'")); | |
| 60 | }); | |
| 61 | ||
| 62 | test("/pricing and /signup link to /terms and /privacy; the name is reserved", async () => { | |
| 63 | for (const p of ["/pricing", "/signup"]) { | |
| 64 | const { text } = await get(p); | |
| 65 | expect(text).toContain('href="/terms"'); | |
| 66 | expect(text).toContain('href="/privacy"'); | |
| 67 | } | |
| 68 | expect(isSystemName("terms")).toBe(true); | |
| 69 | }); | |
| 70 | }); |
test/tui-terms.test.ts added +33
| @@ -0,0 +1,33 @@ | ||
| 1 | /** /terms in the terminal (#13207): the web page's rows, from the same function. */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createApp } from "../src/app.ts"; | |
| 7 | import { termRows } from "../src/billing/terms_words.ts"; | |
| 8 | import { createForgeApp, forgeCommands, type TuiIdentity } from "../src/tui/forge.ts"; | |
| 9 | import { termsScreen } from "../src/tui/screens/terms.ts"; | |
| 10 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; | |
| 11 | import { quietLogs } from "./helpers/globals.ts"; | |
| 12 | import { settleApp } from "./helpers/tui.ts"; | |
| 13 | ||
| 14 | quietLogs(); | |
| 15 | ||
| 16 | test("the palette offers it, and the screen shows every row's label and a lapse sentence that does not read as deletion", async () => { | |
| 17 | const dir = await mkdtemp(join(tmpdir(), "forge-tui-terms-")); | |
| 18 | try { | |
| 19 | const app = createApp({ dataDir: dir, url: "https://forge.test", port: 0 }); | |
| 20 | const identity: TuiIdentity = { sshUsername: "git", remoteAddress: "203.0.113.4", fingerprint: "SHA256:test", user: undefined }; | |
| 21 | const terminal = headlessTerminal(120, 50); | |
| 22 | const { app: tui, session } = createForgeApp(app, identity, { terminal, exitHooks: false }); | |
| 23 | tui.start(); | |
| 24 | expect(forgeCommands(session)(tui.ctx).map((c) => c.id)).toContain("terms"); | |
| 25 | tui.ctx.push(termsScreen(session, tui.ctx)); | |
| 26 | await settleApp(tui); | |
| 27 | const text = tui.screen.toText().replace(/\s+/g, " "); | |
| 28 | for (const r of termRows(app.db)) expect(text).toContain(r.label); | |
| 29 | expect(text).toContain("Sleeping never deletes anything"); | |
| 30 | } finally { | |
| 31 | await rm(dir, { recursive: true, force: true }); | |
| 32 | } | |
| 33 | }); |
new above
offline
Both doors: add a src/tui/ screen for terms and docs/features/terms.md; sharing the sentence builders so web and terminal cannot drift. Principle 1: open the body with one sentence saying what the page is for.