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

Client rehearsal: a forge with custom apps for a person with zero technical background, in one link, by Tuesday #1406

Closed opened this in answer to
Closed without merging

scout/forge:scout/1115-client-rehearsal-a-forge-with-custom-app → main 7 commits fork 8 threads · 8 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
19 files changed +828 −10
README.md +4
@@ -400,6 +400,10 @@ The terminal has no backups view, so it has no readout.
400400 grew up in switched off: what a host owes it, the moves in order, and what is
401401 given up.
402402
403 ## A forge for someone else
404
405 `/forges/new` makes a child forge from copied apps and from sentences ("a booking page for my salon"). Whoever claims it sees a plain first screen: their apps, what each is for, what its helpers do, one box to tell them what to change, and what came of earlier asks. On a spawned forge `/` is that screen for everyone, owner included (the claimant is the owner); the full home is `/?all=1`. In the terminal the palette (`:`) has "Tell the crew what you want" and "What you asked for" (Done, Being worked on, Waiting), and the MCP `spawn` tool takes `fresh` apps. No app, copied or new, may be named `forge`. See `docs/SPAWN.md`.
406
403407 ### Passports
404408
405409 A crew run's environment carries `FORGE_PASSPORT`, a 15-minute credential
docs/SPAWN.md +16
@@ -59,3 +59,19 @@ A spawner may give the child one credential: `modelKey`, an API-billed key (`sk-
5959 ## Callers
6060
6161 `POST /api/v1/forges {name, apps[], crew[], direction?, keepAccess?, modelKey?, budgetUsd?, dryRun}` (rw token, admin only) and the MCP `spawn` tool share `src/spawn/door.ts`. `dryRun` is true unless it is `false`: the answer is the plan and what is left behind, and nothing is made. `GET /api/v1/forges` lists the ledger's children. The child's org is its name; `crew` names the agents whose briefs travel. Errors: 401 unauthorized, 403 forbidden / cross_origin, 422 invalid, 409 refused / exists, 500 failed — each with one sentence. The MCP lets an `ro` token plan, never make.
62
63 ## A forge for someone who is not technical (#1115)
64
65 **New apps from a sentence.** `fresh` on the plan (`POST /api/v1/forges {fresh: [{description, name?}]}`, or one line per app in "New apps, from a sentence" on `/forges/new`) starts an app from nothing: the same scaffold every new app begins as, the sentence as its description and as its direction, so the crew builds toward it. Without a `name` the first words of the sentence are the name. At most 10, each one line of up to 200 characters, names distinct from the copied apps'. Each carried crew member joins a new app in the role they most often have on the copied ones (a builder when there are no copied apps). A plan with no new apps has no `fresh` field at all.
66
67 **The claimant's first screen** (`src/web/studio/client-home.ts`). On a spawned forge, `GET /` shows the apps and nothing else: for each, what it is for (its description), its helpers by what they do ("Builds what you ask for", never a username), each "Working on it now" or "Waiting for your word", one box "What do you want changed or added?", and below it what they asked for with its state (Done, Being worked on, Waiting) and the helper's last answer. There is no link to the full app page: that page is the jargon this screen avoids. The page is bare: no menu, map, board or settings. "Show everything" is `/?all=1`, the home the forge always had (including the owner's next steps). The box posts to `POST /tell` with `plain=1`, the same tell as every other door (same-origin, verified email, who may direct the crew), answering in plain words.
68
69 **Left out, on purpose.** A custom domain at spawn (the child keeps `<name>--<parent's host>`; a domain is DNS the owner does, in the child's own settings). A budget still needs a model key, as before.
70
71 **Words that were nerdy** and what the client's screens say instead (`test/client-home.test.ts` keeps them out of the first screen): forge → "your apps"; repository/repo → app; agent, crew, builder, planner → helper; issue, tell → "what you asked for"; run → "working on it now"; production, preview, deploy → left out; admin → "the one in charge"; claim → "make your account to open them". The rehearsal on the live forge (a `client-demo` child with two apps and screenshots) needs a person's session on the live forge and has not been done (a headless browser cannot start in the agent's sandbox either, so no 360px screenshot exists yet); the owner's checklist is: spawn it from `/forges/new` with one copied app and one sentence, open the link in a private window, read the first screen aloud to someone who does not work in software, and add every word they stop on to this list.
72
73 **Names an app may not take.** `forge` is the code repository every child carries (`forkForgeCode`), so `planSpawn` refuses it for a new app; a sentence such as "Forge" yields that name, and "Forge your brand" does not.
74
75 **The terminal.** Everything the page does, the terminal does. In `tty`, the palette (`:`) has **Tell the crew what you want** (asks for `owner/name`, then the sentence; it goes through the same `tell` action as the page's box, so web viewers see it live) and **What you asked for** (your own asks on that app with Done, Being worked on or Waiting and the helper's last answer, from the same `askedBy` read as the page; a guest, or an app you cannot read, shows nothing). New apps from a sentence are `fresh` on the MCP `spawn` tool as on `POST /api/v1/forges`.
outdated

A 'page-only on purpose' decision conflicts with the both-doors rule. Remove it once the terminal has the same actions.

76
77 **The owner on a spawned forge.** `GET /` is the plain first screen for everyone there, the one in charge included, since the person who claims a child is its admin. The full home is `/?all=1`.
scripts/gate.ts +1
@@ -255,6 +255,7 @@ export const GATE: readonly string[] = [
255255 ];
256256
257257 export const EXCLUDED: readonly Exclusion[] = [
258 { file: "test/client-home.test.ts", reason: "not yet admitted", issue: 261 },
258259 { file: "test/api-errors.test.ts", reason: "not yet admitted", issue: 261 },
259260 { file: "test/apps-api.test.ts", reason: "not yet admitted", issue: 261 },
260261 {
src/actions/spawn.ts +52
@@ -15,10 +15,13 @@
1515 import { mkdir, readdir, rename } from "node:fs/promises";
1616 import { join } from "node:path";
1717 import { createApp, type App } from "../app.ts";
18 import { scaffoldFiles } from "../apps/scaffold.ts";
19 import { commitToBranch } from "./repos.ts";
1820 import {
1921 addCrew,
2022 BRIEF_MAX,
2123 createAgentRow,
24 type CrewRole,
2225 getAgentByName,
2326 listCrewRoles,
2427 setCrewRole,
@@ -265,6 +268,13 @@ async function make(
265268 });
266269 }
267270
271 /** The commonest of `roles`; a builder when there are none to count. */
272 function mostOften(roles: readonly CrewRole[]): CrewRole {
273 const counts = new Map<CrewRole, number>();
274 for (const r of roles) counts.set(r, (counts.get(r) ?? 0) + 1);
275 return [...counts].sort((a, b) => b[1] - a[1])[0]?.[0] ?? "builder";
276 }
277
268278 /**
269279 * Every step skips what is already there, so a resumed child is finished,
270280 * not doubled. Answers the child's claim token, minted afresh each time.
@@ -344,6 +354,33 @@ async function copyInto(
344354 copiedRepos.push({ parent, child: repo });
345355 }
346356
357 const freshRepos: Repo[] = [];
358 // Apps started from a sentence: the scaffold every new app begins as,
359 // with the sentence as its direction, so the crew builds toward it.
360 for (const f of plan.fresh ?? []) {
361 let repo = getRepo(child.db, org.username, f.name);
362 if (!repo) {
363 const made = await createRepo(child.db, child.reposRoot, {
364 ownerId: org.id,
365 name: f.name,
366 visibility: "private",
367 description: f.description,

If f.name is forge, getRepo finds the child's code repository and the new app silently becomes it, with its direction overwritten. Refuse reserved names in planSpawn.

368 });
369 if (!made.ok) return err(`could not make ${f.name}: ${made.error}`);
370 const committed = await commitToBranch(child, founder, made.value, {
371 message: `Start ${f.name}`,
372 files: scaffoldFiles({ name: f.name, description: f.description }),
373 });
374 if (!committed.ok) return err(`could not start ${f.name}`);
375 repo = made.value;
376 }
377 if (repo.autonomyDirection === "")
378 repo = updateRepoSettings(child.db, repo, {
379 autonomyDirection: plan.direction === "" ? f.description : `${plan.direction}\n\n${f.description}`,
380 });
381 freshRepos.push(repo);
382 }
383
347384 // The forge's own code, forked into the child with its full history,
348385 // so every child starts from the forge and can follow its parent.
349386 // A cross-forge fork: the history is copied by git, and the upstream
@@ -379,6 +416,21 @@ async function copyInto(
379416 setCrewRole(child.db, repo.id, theirs.user.id, role);
380417 }
381418
419 // A new app has no parent copy to take its crew from: each carried crew
420 // member joins it in the role they have most often on the copied apps.
421 for (const repo of freshRepos) {
422 for (const b of plan.briefs) {
423 const theirs = getAgentByName(child.db, b.agent);
424 if (!theirs) continue;
425 const roles = copiedRepos
426 .flatMap(({ parent }) => listCrewRoles(app.db, parent.id))
427 .filter((c) => c.agent.user.username === b.agent)
428 .map((c) => c.role);
429 addCrew(child.db, repo.id, theirs.user.id, founder.id);
430 setCrewRole(child.db, repo.id, theirs.user.id, mostOften(roles));
431 }
432 }
433
382434 // The child's own keys, made in its own directory now, so they exist
383435 // before its first boot and are provably not the parent's: the key that
384436 // seals its secrets, and its SSH host key.
src/crew/asked.ts added +52
@@ -0,0 +1,52 @@
1 /**
2 * What a person asked the crew on an app, in the plain states they use:
3 * Done, Being worked on, Waiting. One read for every door — the client's
4 * first screen and the terminal — so they never disagree. Only the asker's
5 * own tells, and only on an app they may read: a guest, or an app that is
6 * not theirs to see, yields nothing.
7 */
8
9 import type { App } from "../app.ts";
10 import { listComments, listIssues, type Issue } from "../core/issues.ts";
11 import { canRead, type Repo } from "../core/repos.ts";
12 import type { User } from "../core/users.ts";
13
14 export type AskState = "Done" | "Being worked on" | "Waiting";
15
16 export interface Asked {
17 readonly number: number;
18 readonly title: string;
19 readonly state: AskState;
20 readonly createdAt: string;
21 /** The helper's last answer, when there is one. */
22 readonly answer: string | undefined;
23 }
24
25 /** An ask in a word a person uses: done, being worked on, or waiting its turn. */
26 export function askState(issue: Issue): AskState {
27 if (issue.state === "closed") return "Done";
28 return issue.assigneeId === null ? "Waiting" : "Being worked on";
29 }
30
31 /** The viewer's own asks on `repo`, newest first. */
32 export function askedBy(
33 app: App,
34 user: User | undefined,
35 repo: Repo,
36 limit: number,
37 ): Asked[] {
38 if (user === undefined || !canRead(app.db, repo, user)) return [];
39 return listIssues(app.db, repo.id, {
40 state: "all",
41 author: user.username,
42 limit,
43 }).map((issue) => ({
44 number: issue.number,
45 title: issue.title,
46 state: askState(issue),
47 createdAt: issue.createdAt,
48 answer: listComments(app.db, issue.id)
49 .filter((c) => c.authorName !== user.username)

Any comment not written by the asker counts as "the helper's answer", including a reply from another person. Keep only agent authors' comments so the label is true.

50 .at(-1)?.body,
51 }));
52 }
src/http/mcp.ts +13
@@ -860,6 +860,19 @@ const TOOLS: readonly Tool[] = [
860860 description:
861861 "What the child is for, in your words (at most 2000 characters): its apps' direction, opened as the planner's first issue when the child first boots.",
862862 },
863 fresh: {
864 type: "array",
865 maxItems: 10,
866 items: {
867 type: "object",
868 properties: {
869 description: { type: "string", description: "One line, up to 200 characters: what the new app is for." },
870 name: { type: "string", description: "Its name; the first words of the sentence when left out." },
871 },
872 required: ["description"],
873 },
874 description: "New apps started from a sentence, beside the copied ones.",
875 },
863876 keepAccess: {
864877 type: "boolean",
865878 description:
src/spawn/door.ts +1
@@ -232,6 +232,7 @@ export async function spawnDoor(
232232 // by whoever opens the link.
233233 keepAccess: anon ? false : raw["keepAccess"],
234234 budgetUsd: raw["budgetUsd"],
235 fresh: raw["fresh"],
235236 ...(anon ? {} : { for: raw["for"] }),
236237 };
237238
src/spawn/plan.ts +60
@@ -10,6 +10,9 @@
1010 import { err, ok, type Result } from "../kernel/result.ts";
1111
1212 export const MAX_APPS = 50;
13 /** Apps started fresh from a one-line description, beside the copied ones. */
14 export const MAX_FRESH = 10;
15 export const MAX_FRESH_CHARS = 200;
1316 export const MAX_BRIEFS = 100;
1417 export const MAX_SUBSCRIPTIONS = 200;
1518 export const MAX_BRIEF_CHARS = 20_000;
@@ -30,6 +33,9 @@ export const KEY_BUDGET_NOTE =
3033 export const MAX_BUDGET_USD = 1000;
3134
3235 const NAME = /^[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/;
36 /** Repositories every child carries itself (`forkForgeCode` makes `forge`); an app may not become one. */
37 const RESERVED_NAMES: readonly string[] = ["forge"];
38 const FRESH_NAME = /^[a-z0-9][a-z0-9-]{0,28}[a-z0-9]$/;
3339 const APP_REF = /^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/;
3440
3541 /** An app the viewer can see, as the caller found it. */
@@ -62,6 +68,8 @@ export interface SpawnInput {
6268 * The key itself never enters the plan: only that there is one, capped.
6369 */
6470 readonly budgetUsd?: unknown;
71 /** Apps to start from nothing: a list of `{ description, name? }`; optional. */
72 readonly fresh?: unknown;
6573 }
6674
6775 /** What the parent has to offer. Extra fields are ignored, never copied. */
@@ -78,6 +86,12 @@ export interface PlannedApp {
7886 readonly bytes: number;
7987 }
8088
89 /** An app started fresh: its name and the one line it is to become. */
90 export interface PlannedFresh {
91 readonly name: string;
92 readonly description: string;
93 }
94
8195 export interface SpawnPlan {
8296 readonly name: string;
8397 readonly org: string;
@@ -92,6 +106,8 @@ export interface SpawnPlan {
92106 readonly budgetUsd: number | null;
93107 /** Whom the child is for, for the parent's client list; absent when unsaid. */
94108 readonly forWhom?: string;
109 /** Apps started fresh; absent when there are none. */
110 readonly fresh?: readonly PlannedFresh[];
95111 }
96112
97113 export interface DryRun {
@@ -113,6 +129,22 @@ export const LEFT_BEHIND: readonly string[] = [
113129 "user accounts",
114130 ];
115131
132 /** A name from a description: its first words, as the slug an app is named by. */
133 export function nameFromDescription(description: string): string {
134 const words = description
135 .toLowerCase()
136 .replace(/[^a-z0-9]+/g, " ")
137 .trim()
138 .split(" ")
139 .filter((w) => w !== "");
140 let name = "";
141 for (const w of words.slice(0, 4)) {
142 if (`${name}-${w}`.length > 30) break;
143 name = name === "" ? w : `${name}-${w}`;
144 }
145 return name.slice(0, 30).replace(/-+$/, "");
146 }
147
116148 const refuse = (field: string, reason: string) => err<Refusal>({ field, reason });
117149 const byText = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0);
118150
@@ -141,6 +173,8 @@ export function planSpawn(
141173 if (typeof ref !== "string" || !APP_REF.test(ref)) {
142174 return refuse("apps", "an app reference must look like owner/name");
143175 }
176 if (RESERVED_NAMES.includes(ref.split("/")[1]!.toLowerCase()))
177 return refuse("apps", `${ref}: the name "${ref.split("/")[1]}" is kept for the forge's own code in a child`);
144178 if (seen.has(ref)) return refuse("apps", `${ref} is listed twice`);
145179 seen.add(ref);
146180 const app = known.get(ref);
@@ -197,6 +231,30 @@ export function planSpawn(
197231 if (forWhom.length > MAX_FOR_CHARS) return refuse("for", `at most ${MAX_FOR_CHARS} characters`);
198232 }
199233
234 const fresh: PlannedFresh[] = [];
235 if (input.fresh !== undefined && input.fresh !== null) {
236 if (!Array.isArray(input.fresh)) return refuse("fresh", "must be a list of apps");
237 if (input.fresh.length > MAX_FRESH) return refuse("fresh", `at most ${MAX_FRESH} new apps`);
238 const taken = new Set(apps.map((a) => a.ref.split("/")[1]!.toLowerCase()));
239 for (const item of input.fresh as unknown[]) {
240 const o = (typeof item === "object" && item !== null ? item : {}) as Record<string, unknown>;
241 if (typeof o["description"] !== "string") return refuse("fresh", "a new app needs a line saying what it is for");
242 const description = o["description"].trim();
243 // One line, no control characters: it is shown on pages and written into files.
outdated

taken only compares against copied apps. Add forge here, and test it.

244 if (description === "" || description.length > MAX_FRESH_CHARS || /[\u0000-\u001f\u007f]/.test(description))
245 return refuse("fresh", `a new app is one line of 1-${MAX_FRESH_CHARS} characters`);
246 const name = o["name"] === undefined || o["name"] === "" ? nameFromDescription(description) : o["name"];
247 if (typeof name !== "string" || !FRESH_NAME.test(name))
248 return refuse("fresh", `"${description.slice(0, 40)}" needs a name of letters and digits, e.g. my-shop`);
249 if (RESERVED_NAMES.includes(name))
250 return refuse("fresh", `"${name}" is kept for the forge's own code; pick another name`);
251 if (taken.has(name)) return refuse("fresh", `two apps are named ${name}`);
252 taken.add(name);
253 fresh.push({ name, description });
254 }
255 fresh.sort((a, b) => byText(a.name, b.name));
256 }
257
200258 // `forWhom` only when said, so a plan without it hashes as it always did.
201259 return ok({
202260 name,
@@ -208,6 +266,7 @@ export function planSpawn(
208266 keepAccess,
209267 budgetUsd,
210268 ...(forWhom === "" ? {} : { forWhom }),
269 ...(fresh.length === 0 ? {} : { fresh }),
211270 });
212271 }
213272
@@ -217,6 +276,7 @@ const enc = new TextEncoder();
217276 export function dryRun(plan: SpawnPlan, source: SpawnSource): DryRun {
218277 const copied = [
219278 ...plan.apps.map((a) => `app ${a.ref} (full history, forge.json)`),
279 ...(plan.fresh ?? []).map((f) => `new app ${f.name}: ${f.description}`),
220280 ...plan.briefs.map((b) => `crew brief for ${b.agent}`),
221281 ...plan.subscriptions.map((s) => `subscription ${s} (name only)`),
222282 ...(plan.direction === "" ? [] : ["your words, as the child's direction"]),
src/tui/forge.ts +11
@@ -36,6 +36,7 @@ import { newPullScreen } from "./screens/newpull.ts";
3636 import { newRepoScreen } from "./screens/newrepo.ts";
3737 import { repoScreen } from "./screens/repo.ts";
3838 import { signInScreen } from "./screens/signin.ts";
39 import { askedScreen, tellScreen } from "./screens/tell.ts";
3940 import { local } from "./screens/where.ts";
4041
4142 export { Session, type TuiIdentity };
@@ -72,6 +73,16 @@ const REPO_VERBS: readonly {
7273 open: (f, ctx, repo) => limbsScreen(f, ctx, repo),
7374 },
7475 { id: "new-issue", title: "New issue", open: newIssueScreen },
76 {
77 id: "tell",
78 title: "Tell the crew what you want",
79 open: (f, ctx, repo) => tellScreen(f, ctx, blank("Tell"), repo),
80 },
81 {
82 id: "asked",
83 title: "What you asked for",
84 open: (f, ctx, repo) => askedScreen(f, ctx, blank("Asked"), repo),
85 },
7586 { id: "new-pull", title: "New pull request", open: newPullScreen },
7687 {
7788 id: "settings",
src/tui/screens/tell.ts added +83
@@ -0,0 +1,83 @@
1 /**
2 * Tell the crew, and read what you asked: the terminal's side of the client
3 * home's box and list. Both go through the same actions as the page — `tell`
4 * for the write (so web viewers see it live) and `askedBy` for the plain
5 * states Done, Being worked on, Waiting.
6 */
7
8 import { tell, toldWords, UNVERIFIED_WORDS } from "../../actions/tell.ts";
9 import { askedBy } from "../../crew/asked.ts";
10 import type { Repo } from "../../core/repos.ts";
11 import type { Ctx, Screen } from "../app/app.ts";
12 import { binding } from "../app/keys.ts";
13 import type { Session } from "../session.ts";
14 import { style } from "../term/style.ts";
15 import { truncate } from "../term/width.ts";
16 import { card } from "../ui/widgets.ts";
17 import { ago, errorText, promptScreen, runAsync } from "./common.ts";
18
19 const MAX_ASKS = 10;
20
21 /** One sentence becomes work on `repo`, said the way the page's box says it. */
22 export function tellScreen(f: Session, ctx: Ctx, parent: Screen, repo: Repo): Screen {
23 return promptScreen(ctx, parent, {
24 title: `Tell the crew on ${repo.name}`,
25 label: "What do you want changed or added?",
26 onSubmit: (said) => {
27 if (said === "") return "say what you want";
28 runAsync(ctx, async () => {
29 const told = await tell(f.app, f.user, repo, said);
30 if (!told.ok) {
31 ctx.toast(
32 told.error === "unverified" ? UNVERIFIED_WORDS : errorText(told.error),
33 "danger",
34 );
35 return;
36 }
37 ctx.toast(toldWords(told.value), "success");
38 });
39 return undefined;
40 },
41 });
42 }
43
44 /** What you asked on `repo`, each with its plain state and the helper's last answer. */
45 export function askedScreen(f: Session, ctx: Ctx, parent: Screen, repo: Repo): Screen {
46 const asked = askedBy(f.app, f.user, repo, MAX_ASKS);
47 return {
48 title: "What you asked for",
49 keys: [binding(["esc"], "close")],
50 render(area, s) {
51 parent.render(area, s);
52 const c = ctx.theme.c;
53 const w = Math.min(76, Math.max(30, area.w - 6));
54 const h = Math.min(area.h, Math.max(1, asked.length * 2) + 4);
55 const inner = card(s, {
56 x: area.x + ((area.w - w) >> 1),
57 y: area.y + ((area.h - h) >> 1),
58 w,
59 h,
60 }, c, { title: `What you asked for on ${repo.name}`, footer: "esc close", focused: true });
61 const edge = inner.x + inner.w;
62 if (asked.length === 0) {
63 s.text(inner.x + 1, inner.y, "Nothing asked yet.", style(c.faint, c.card), edge);
64 return;
65 }
66 let y = inner.y;
67 for (const a of asked) {
68 if (y + 1 >= inner.y + inner.h) break;
69 const when = `${a.state} · ${ago(a.createdAt)}`;
70 s.text(inner.x + 1, y, truncate(a.title, Math.max(0, inner.w - when.length - 3)), style(c.fg, c.card), edge);
71 s.text(edge - when.length - 1, y, when, style(c.mutedFg, c.card), edge);
72 if (a.answer !== undefined)
73 s.text(inner.x + 3, y + 1, truncate(`answered: ${a.answer.replace(/\s+/g, " ")}`, Math.max(0, inner.w - 4)), style(c.faint, c.card), edge);
74 y += 2;
75 }
76 },
77 key: (e) => {
78 if (e.key !== "esc" && e.key !== "enter") return true;
79 ctx.pop();
80 return true;
81 },
82 };
83 }
src/web/pages/claim.ts +3 −3
@@ -129,9 +129,9 @@ function claimForm(
129129 ${pageHead("This forge is yours")}
130130 ${card(
131131 html`<p class="mb">
132 ${spawned.org.username} was made for you, with its apps and a crew
133 ready to build them. Make your account to take it: this first account
134 is the forge's admin, so it can change everything here.
132 ${spawned.org.username} was made for you: your apps are ready, and
133 helpers (computer assistants) are ready to work on them. Make your
134 account to open them. You will be the one in charge here.
135135 </p>
136136 <p class="mb" id="claim-access">${accessSentence(spawned, spawner)}</p>
137137 <form method="post" action="/claim">
src/web/pages/new-forge.ts +22
@@ -31,6 +31,8 @@ interface Values {
3131 readonly forWhom: string;
3232 readonly direction: string;
3333 readonly apps: readonly string[];
34 /** New apps, one line each: what each is for. */
35 readonly fresh: string;
3436 readonly crew: readonly string[];
3537 readonly keepAccess: boolean;
3638 readonly budgetUsd: string;
@@ -44,6 +46,7 @@ const EMPTY: Values = {
4446 forWhom: "",
4547 direction: "",
4648 apps: [],
49 fresh: "",
4750 crew: [],
4851 keepAccess: false,
4952 budgetUsd: "",
@@ -166,6 +169,15 @@ function formView(
166169 ? html`<span class="error" id="f-apps-err">${errors["apps"]}</span>`
167170 : null}
168171 </fieldset>
172 ${formField({
173 label: "New apps, from a sentence",
174 name: "fresh",
175 type: "textarea",
176 rows: 3,
177 value: values.fresh,
178 hint: "One app per line, in plain words: \"A booking page for my hair salon\". Each starts from nothing and the crew builds toward it.",
179 ...(errors["fresh"] ? { error: errors["fresh"] } : {}),
180 })}
169181 ${crew.length === 0
170182 ? null
171183 : html`<fieldset class="field">
@@ -322,6 +334,14 @@ function madeView(body: Record<string, unknown>): Html {
322334 </div>`;
323335 }
324336
337 /** The textarea's lines as new apps: blank lines dropped, each line a description. */
338 export const freshOf = (text: string): { description: string }[] =>
339 text
340 .split(/\r?\n/)
341 .map((l) => l.trim())
342 .filter((l) => l !== "")
343 .map((description) => ({ description }));
344
325345 const asBool = (form: Form, name: string): boolean =>
326346 field(form, name) === "on";
327347
@@ -348,6 +368,7 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> {
348368 forWhom: field(form, "for").trim(),
349369 direction: field(form, "direction"),
350370 apps: all(form, "apps"),
371 fresh: field(form, "fresh"),
351372 crew: all(form, "crew"),
352373 keepAccess: asBool(form, "keepAccess"),
353374 budgetUsd: field(form, "budgetUsd").trim(),
@@ -360,6 +381,7 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> {
360381 name: values.name,
361382 apps: values.apps,
362383 crew: values.crew,
384 fresh: freshOf(values.fresh),
363385 keepAccess: values.keepAccess,
364386 ...(values.forWhom === "" ? {} : { for: values.forWhom }),
365387 ...(values.direction.trim() === "" ? {} : { direction: values.direction }),
src/web/studio/actions.ts +17
@@ -47,12 +47,29 @@ async function tellFrom(
4747 back: string,
4848 ): Promise<Response> {
4949 const text = field(form, "text").trim();
50 // The handed-over forge's box (`client-home.ts`) answers in plain words.
51 const plain = field(form, "plain") === "1";
5052 if (text === "")
5153 return flashTo(ctx, back, {
5254 tone: "danger",
5355 message: "Say something first.",
5456 });
5557 const told = await tell(ctx.app, ctx.auth.user, repo, text);
58 if (!told.ok && plain)
59 return flashTo(ctx, back, {
60 tone: "danger",
61 message:
62 told.error === "unverified"
63 ? "Please confirm your email address first, then send this again."
64 : "That could not be sent. Please try again.",
65 });
66 if (told.ok && plain)
67 return flashTo(ctx, back, {
68 message:
69 told.value.routed === undefined
70 ? "Thank you. We have it, and a helper will pick it up soon."
71 : "Thank you. A helper is on it, and the answer will appear here.",
72 });
5673 if (!told.ok)
5774 return flashTo(ctx, back, {
5875 tone: "danger",
src/web/studio/client-home.ts added +141
@@ -0,0 +1,141 @@
1 /**
2 * The first screen of someone who was handed a forge (#1115): their apps,
3 * what each is for in plain words, who is working on it, one box to say what
4 * they want, and what came of what they asked. Nothing else — no map, no
5 * board, no settings — until they ask (`/?all=1`). Every word here is meant
6 * to pass "would a shop owner understand it"; `test/client-home.test.ts`
7 * keeps the jargon out.
8 */
9
10 import { listCrewRoles } from "../../core/agents.ts";
11 import { askedBy } from "../../crew/asked.ts";
12 import type { Repo } from "../../core/repos.ts";
13 import { listRuns } from "../../core/runs.ts";
14 import type { User } from "../../core/users.ts";
15 import type { Ctx } from "../../http/context.ts";
16 import { html, type Html } from "../html.ts";
17 import { page } from "../layout.ts";
18 import { btn, card, timeAgo } from "../ui.ts";
19 import { writableAppsOf } from "./asks.ts";
20
21 const MAX_APPS = 12;
22 const MAX_ASKS = 3;
23 const ANSWER_CHARS = 400;
24
25 /** The code repository every spawned forge carries is not one of the person's apps. */
26 const isTheirs = (r: Repo): boolean => r.name !== "forge";
27
28 /** What the app is for: its description, else the first line of what it was started for. */
29 function whatItIsFor(repo: Repo): string {
30 const said = repo.description.trim() || repo.autonomyDirection.trim().split("\n")[0]!.trim();
31 return said === "" ? "Still being set up." : said;
32 }
33
34 interface Helper {
35 /** What this helper does, in a word a person uses. */
36 readonly job: string;
37 readonly working: boolean;
38 }
39
40 /** A helper's real username is for the crew; a person is told what it does. */
41 const JOBS: Record<string, string> = {
42 builder: "Builds what you ask for",
outdated

Helper names are raw usernames. Give helpers a human-readable name, or show a role in plain words.

43 planner: "Plans the work",
44 reviewer: "Checks the work",
45 };
46
47 /** The helpers on an app, each working (a job is running or queued) or waiting. */
48 function helpersOf(ctx: Ctx, repo: Repo): Helper[] {
49 const busy = new Set<string>();
50 for (const run of listRuns(ctx.app.db, repo.id, { kind: "agent", limit: 50 }))
51 if ((run.state === "running" || run.state === "queued") && run.actorId !== null)
52 busy.add(run.actorId);
53 return listCrewRoles(ctx.app.db, repo.id).map(({ agent, role }) => ({
54 job: JOBS[role] ?? "Helps with your app",
55 working: busy.has(agent.user.id),
56 }));
57 }
58
59 function helpersLine(helpers: readonly Helper[]): Html {
60 if (helpers.length === 0)
61 return html`<p class="muted small">No helpers yet. Whoever sent you this will add some.</p>`;
62 return html`<ul class="list">
63 ${helpers.map(
64 (h) =>
65 html`<li class="row">
66 <span>${h.job}</span><span class="spacer"></span>
67 <span class="${h.working ? "" : "muted"}"
68 >${h.working ? "Working on it now" : "Waiting for your word"}</span
69 >
70 </li>`,
71 )}
72 </ul>`;
73 }
74
75 /** What you asked on this app, newest first, each with the helper's answer when there is one. */
76 function asksOf(ctx: Ctx, user: User, repo: Repo): Html {
77 const asked = askedBy(ctx.app, user, repo, MAX_ASKS);
78 if (asked.length === 0) return html``;
79 return html`<h3 class="small muted">What you asked for</h3>
80 <ul class="list">
81 ${asked.map((issue) => {
82 return html`<li class="stack">
83 <div class="row">
84 <b>${issue.title}</b><span class="spacer"></span
85 ><span class="small muted"
86 >${issue.state} · ${timeAgo(issue.createdAt)}</span
87 >
88 </div>
89 ${issue.answer === undefined
90 ? null
91 : html`<p class="small"><b>A helper answered:</b>
92 ${issue.answer.length > ANSWER_CHARS
93 ? `${issue.answer.slice(0, ANSWER_CHARS).trimEnd()}…`
94 : issue.answer}</p>`}
95 </li>`;
96 })}
97 </ul>`;
98 }
99
100 function appCard(ctx: Ctx, user: User, repo: Repo): Html {
101 const slug = `${repo.ownerName}/${repo.name}`;
102 return card(
103 html`<p class="mb">${whatItIsFor(repo)}</p>
104 ${helpersLine(helpersOf(ctx, repo))}
105 <form method="post" action="/tell" class="stack mt">
106 <input type="hidden" name="app" value="${slug}" />
107 <input type="hidden" name="plain" value="1" />
108 <label class="small muted" for="ask-${repo.id}">What do you want changed or added?</label>
109 <textarea
110 class="input"
111 id="ask-${repo.id}"
112 name="text"
outdated

The "Open" button leads to the full repository page, which is the jargon this screen avoids. Remove it or give it a plain destination.

113 rows="2"
114 maxlength="2000"
115 required
116 placeholder="Say it in your own words"
117 ></textarea>
118 <div class="form-actions">${btn("Send", { variant: "primary" })}</div>
119 </form>
120 ${asksOf(ctx, user, repo)}`,
121 { head: html`<h2>${repo.name}</h2>` },
122 );
123 }
124
125 /** GET / on a handed-over forge: the apps and nothing else. */
126 export function clientHome(ctx: Ctx, user: User): Response {
127 const apps = writableAppsOf(ctx, user).repos.filter(isTheirs).slice(0, MAX_APPS);
128 const body = html`<div class="narrow-wide stack">
129 <h1>Welcome, ${user.displayName || user.username}</h1>
130 <p>
131 These are your apps. Each one has helpers: computer assistants that build
132 it and keep improving it. Tell them what you want, in your own words, and
133 they answer right here.
134 </p>
135 ${apps.length === 0
outdated

Page-only door. Add the terminal equivalent: a tell on a chosen app and a read of the asks with their plain states, going through the same tell action so web viewers see the write live.

136 ? card(html`<p>Your apps are still being set up. Come back in a few minutes.</p>`)
137 : apps.map((r) => appCard(ctx, user, r))}
138 <p class="small muted"><a href="/?all=1">Show everything</a></p>
139 </div>`;
140 return page({ ctx, title: "Your apps", body, bare: true });
141 }
src/web/studio/home.ts +6 −2
@@ -48,6 +48,7 @@ import { writableAppsOf } from "./asks.ts";
4848 import { needsYouSection, type AsksTop } from "./asks_page.ts";
4949 import { composer, feedJs, feedNote, feedRegion } from "./feed.ts";
5050 import { homeTabs } from "./home_tabs.ts";
51 import { clientHome } from "./client-home.ts";
5152 import { crewKeyNote } from "./crew.ts";
5253 import { everydayCard } from "../pages/everyday.ts";
5354 import { nextStepsCard } from "../pages/next-steps.ts";
@@ -172,10 +173,13 @@ export async function studioHome(
172173 user: User,
173174 top?: AsksTop,
174175 ): Promise<Response> {
175 const needsYou = needsYouSection(ctx, user, top);
176 const { repos: appRepos } = writableAppsOf(ctx, user);
177176 // A spawned forge says where it lives: the address its person shares.
178177 const spawned = await spawnedOrg(ctx.app);
178 // Handed over, the first screen is the apps alone; `?all=1` is the rest.
179 if (spawned !== undefined && !ctx.url.searchParams.has("all"))
180 return clientHome(ctx, user);
181 const needsYou = needsYouSection(ctx, user, top);
182 const { repos: appRepos } = writableAppsOf(ctx, user);
179183 const address = when(
180184 spawned?.url,
181185 (url) =>
test/client-home.test.ts added +341
@@ -0,0 +1,341 @@
1 /**
2 * The handed-over forge (#1115): a child made with a copied app and one
3 * started from a sentence; its claimant's first screen is the apps and
4 * nothing else, in words a shop owner knows; one box tells the crew, and
5 * what came of it shows on the app. Plus the plan's rules for a sentence.
6 */
7
8 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
9 import { mkdtemp, rm } from "node:fs/promises";
10 import { tmpdir } from "node:os";
11 import { join } from "node:path";
12 import { createRepo } from "../src/actions/repos.ts";
13 import { childDirOf, spawnForge, type SpawnDeps } from "../src/actions/spawn.ts";
14 import { createApp, type App } from "../src/app.ts";
15 import { addCrew, createAgentRow, setCrewRole } from "../src/core/agents.ts";
16 import { askedBy } from "../src/crew/asked.ts";
17 import { addComment, listIssues } from "../src/core/issues.ts";
18 import { getRepo } from "../src/core/repos.ts";
19 import { createUser, getUserByName, type User } from "../src/core/users.ts";
20 import { commitFiles } from "../src/git/write.ts";
21 import { repoDir } from "../src/git/repos.ts";
22 import { forgeHttp, type ForgeHttp } from "../src/http/server.ts";
23 import { firstBoot } from "../src/spawn/first-boot.ts";
24 import { hostedPlacement } from "../src/spawn/placement.ts";
25 import { nameFromDescription, planSpawn, type SpawnSource } from "../src/spawn/plan.ts";
26 import { freshOf } from "../src/web/pages/new-forge.ts";
27 import { createForgeApp } from "../src/tui/forge.ts";
28 import { headlessTerminal } from "../src/tui/term/terminal.ts";
29 import { quietLogs } from "./helpers/globals.ts";
30 import { settleApp } from "./helpers/tui.ts";
31
32 quietLogs();
33
34 const author = { name: "a", email: "[email protected]" };
35 const SALON = "A booking page for my hair salon";
36 const empty: SpawnSource = { catalog: [], briefs: [], subscriptions: [] };
37 const base = { name: "n", org: "n", apps: [], carryBriefs: false, carrySubscriptions: false };
38
39 describe("a new app from one sentence, in the plan", () => {
40 test("the name comes from the words, and the plan lists it", () => {
41 expect(nameFromDescription(SALON)).toBe("a-booking-page-for");
42 const plan = planSpawn({ ...base, fresh: [{ description: SALON }] }, empty);
43 if (!plan.ok) throw new Error("plan");
44 expect(plan.value.fresh).toEqual([{ name: "a-booking-page-for", description: SALON }]);
45 });
46 test("a plan without new apps has no `fresh` at all", () => {
47 const plan = planSpawn(base, empty);
48 if (!plan.ok) throw new Error("plan");
49 expect("fresh" in plan.value).toBe(false);
50 });
51 test("bad sentences are refused at the boundary", () => {
52 for (const fresh of [
53 "x",
54 [{}],
55 [{ description: "" }],
56 [{ description: "two\nlines" }],
57 [{ description: "x".repeat(201) }],
58 [{ description: "!!!" }],
59 [{ description: "ok", name: "../evil" }],
60 [{ description: "a shop" }, { description: "a shop" }],
61 Array.from({ length: 11 }, (_, i) => ({ description: `app ${i}` })),
62 ]) {
63 const plan = planSpawn({ ...base, fresh }, empty);
64 expect(plan.ok).toBe(false);
65 if (!plan.ok) expect(plan.error.field).toBe("fresh");
66 }
67 });
68 test("an app may not take the name of the code repository every child carries", () => {
69 for (const fresh of [[{ description: "Forge" }], [{ description: "x", name: "forge" }]]) {
70 const plan = planSpawn({ ...base, fresh }, empty);
71 expect(plan.ok).toBe(false);
72 if (!plan.ok) expect(plan.error.field).toBe("fresh");
73 }
74 expect(planSpawn({ ...base, fresh: [{ description: "Forge your brand" }] }, empty).ok).toBe(true);
75 });
76 test("the form's lines become sentences, blanks dropped", () => {
77 expect(freshOf(" one \r\n\n two\n")).toEqual([{ description: "one" }, { description: "two" }]);
78 });
79 });
80
81 describe("the client's first screen", () => {
82 let dir = "";
83 let parent: App;
84 let alice: User;
85 let child: App;
86 let http: ForgeHttp;
87 const ORIGIN = "http://demo.test";
88 let cookie = "";
89
90 const url = (path: string) => `${ORIGIN}${path}`;
91 const get = (path: string) => http.handle(new Request(url(path), { headers: { cookie } }));
92 /** What a person reads: the page without its markup, scripts or styles. */
93 const seen = (html: string) =>
94 html
95 .replace(/<(head|script|style)[\s\S]*?<\/\1>/g, " ")
96 .replace(/<[^>]+>/g, " ")
97 .replace(/\s+/g, " ");
98
99 beforeAll(async () => {
100 dir = await mkdtemp(join(tmpdir(), "forge-client-home-"));
101 parent = createApp({ dataDir: dir, url: "https://forge.test", port: 0 });
102 const made = await createUser(parent.db, { trusted: true, username: "alice", email: "[email protected]", isAdmin: true });
103 if (!made.ok) throw new Error("user");
104 alice = made.value;
105 const repo = await createRepo(parent, alice, { name: "bakery", description: "Orders and the weekly menu" });
106 if (!repo.ok) throw new Error("repo");
107 const c = await commitFiles(repoDir(parent.reposRoot, "alice", "bakery"), {
108 branch: "main",
109 message: "the bakery",
110 files: [
111 { path: "README.md", content: "# bakery\n" },
112 { path: "forge.json", content: JSON.stringify({ app: { run: "bun run src/server.ts", health: "/healthz" } }) },
113 { path: "package.json", content: JSON.stringify({ name: "bakery" }) },
114 ],
115 author,
116 });
117 if (!c.ok) throw new Error("commit");
118 const agent = await createUser(parent.db, { trusted: true, username: "scout", email: "[email protected]", agent: true });
119 if (!agent.ok) throw new Error("agent");
120 createAgentRow(parent.db, { userId: agent.value.id, brief: "scout's brief", createdBy: alice.id });
121 addCrew(parent.db, repo.value.id, agent.value.id, alice.id);
122 setCrewRole(parent.db, repo.value.id, agent.value.id, "builder");
123 const deps: SpawnDeps = {
124 placement: hostedPlacement({ host: "forge.test" }),
125 request: new Request("https://forge.test/x", { method: "POST", headers: { origin: "https://forge.test" } }),
126 url: new URL("https://forge.test/x"),
127 };
128 const spawned = await spawnForge(
129 parent,
130 alice,
131 { ...base, name: "demo", org: "demo", apps: ["alice/bakery"], carryBriefs: true, fresh: [{ description: SALON, name: "salon" }] },
132 {
133 catalog: [{ ref: "alice/bakery", readable: true, bytes: 10, forgeJsonBytes: 0 }],
134 briefs: [{ agent: "scout", text: "scout's brief" }],
135 subscriptions: [],
136 },
137 deps,
138 );
139 if (!spawned.ok) throw new Error(JSON.stringify(spawned.error));
140 const token = (spawned.value.claimUrl ?? "").split("/claim#")[1] ?? "";
141 child = createApp({ dataDir: childDirOf(parent, spawned.value.bodyId), port: 0 });
142 await firstBoot(child);
143 http = forgeHttp(child);
144 const claimed = await http.handle(
145 new Request(url("/claim"), {
146 method: "POST",
147 headers: { origin: ORIGIN },
148 body: new URLSearchParams({ token, username: "dana", email: "[email protected]", password: "a-long-shop-passphrase" }),
149 }),
150 );
151 if (claimed.status !== 303) throw new Error(`claim ${claimed.status}`);
152 cookie = (claimed.headers.get("set-cookie") ?? "").split(";")[0]!;
153 }, 60_000);
154
155 afterAll(async () => {
156 http.close();
157 child.close();
158 parent.close();
159 await rm(dir, { recursive: true, force: true });
160 });
161
162 test("the sentence became an app the crew is directed to build", () => {
163 const repo = getRepo(child.db, "demo", "salon")!;
164 expect(repo.description).toBe(SALON);
165 expect(repo.autonomyDirection).toBe(SALON);
166 expect(getRepo(child.db, "demo", "bakery")).toBeDefined();
167 });
168
169 test("the home is the apps, each in plain words, and nothing else", async () => {
170 const res = await get("/");
171 expect(res.status).toBe(200);
172 const raw = await res.text();
173 const text = seen(raw);
174 expect(text).toContain("Welcome");
175 expect(text).toContain("Orders and the weekly menu");
176 expect(text).toContain(SALON);
177 expect(text).toContain("Waiting for your word");
178 expect(text).toContain("What do you want changed or added?");
179 // No map, no board, no settings until asked; and nothing a shop owner
180 // would have to look up.
181 for (const nerdy of [
182 "repo", "issue", "pull", "branch", "commit", "merge", "deploy", "agent",
183 "crew", "token", "API", "Map", "Board", "Settings", "Audit", "preview",
184 "production", "forge",
185 ])
186 expect(text).not.toMatch(new RegExp(`\\b${nerdy}`, "i"));
187 expect(raw).not.toContain('href="/map"');
188 // The code repository every handed-over forge carries is not one of the apps.
189 expect(raw).not.toContain("demo/forge");
190 });
191
192 test("everything is one click away", async () => {
193 const text = seen(await (await get("/?all=1")).text());
194 expect(text).toContain("Map");
195 });
196
197 test("what the client says becomes work, answered on the app, in plain words", async () => {
198 const said = "Please add a price list to the front page";
199 const sent = await http.handle(
200 new Request(url("/tell"), {
201 method: "POST",
202 headers: { cookie, origin: ORIGIN },
203 body: new URLSearchParams({ app: "demo/salon", plain: "1", text: said }),
204 }),
205 );
206 expect(sent.status).toBe(303);
207 expect(sent.headers.get("location")).toBe("/");
208 const repo = getRepo(child.db, "demo", "salon")!;
209 const issue = listIssues(child.db, repo.id, { state: "all", author: "dana" })[0];
210 if (issue === undefined) throw new Error(`not told: ${sent.headers.get("set-cookie")}`);
211 expect(issue.title).toBe(said);
212 const helper = await createUser(child.db, { trusted: true, username: "helper1", email: "[email protected]", agent: true });
213 if (!helper.ok) throw new Error("helper");
214 addComment(child.db, { issueId: issue.id, authorId: helper.value.id, body: "Done: the price list is on the front page." });
215 const text = seen(await (await get("/")).text());
216 expect(text).toContain("What you asked for");
217 expect(text).toContain(said);
218 expect(text).toContain("A helper answered: Done: the price list is on the front page.");
219 });
220
221 test("the thanks shows on the bare page, and the home stays fast with helper state", async () => {
222 const sent = await http.handle(
223 new Request(url("/tell"), {
224 method: "POST",
225 headers: { cookie, origin: ORIGIN },
226 body: new URLSearchParams({ app: "demo/bakery", plain: "1", text: "Add opening hours" }),
227 }),
228 );
229 const flash = (sent.headers.get("set-cookie") ?? "").split(";")[0]!;
230 const res = await http.handle(new Request(url("/"), { headers: { cookie: `${cookie}; ${flash}` } }));
231 expect(seen(await res.text())).toMatch(/Thank you\./);
232 const t0 = performance.now();
233 for (let i = 0; i < 20; i++) await (await get("/")).text();
234 expect((performance.now() - t0) / 20).toBeLessThan(50);
235 });
236
237 test("no card leads to the repository page, and no helper shows a username", async () => {
238 const raw = await (await get("/")).text();
239 expect(raw).not.toContain('href="/demo/');
240 expect(seen(raw)).not.toContain("scout");
241 expect(seen(raw)).toContain("Builds what you ask for");
242 });
243
244 test("a post from another origin is refused", async () => {
245 const res = await http.handle(
246 new Request(url("/tell"), {
247 method: "POST",
248 headers: { cookie, origin: "https://evil.test" },
249 body: new URLSearchParams({ app: "demo/salon", text: "x" }),
250 }),
251 );
252 expect(res.status).toBe(403);
253 });
254
255 /** The terminal as dana: the same two things the page does, by the palette. */
256 async function terminalAs(user: User | undefined) {
257 const terminal = headlessTerminal(120, 40);
258 const { app } = createForgeApp(
259 child,
260 { sshUsername: user?.username ?? "guest", remoteAddress: "127.0.0.1", fingerprint: "SHA256:x", ...(user ? { user } : {}) },
261 { terminal, exitHooks: false },
262 );
263 app.start();
264 const type = async (text: string) => {
265 for (const ch of text) app.dispatch({ type: "key", key: ch, ctrl: false, alt: false, shift: false });
266 await settleApp(app);
267 };
268 const enter = async () => {
269 app.dispatch({ type: "key", key: "enter", ctrl: false, alt: false, shift: false });
270 await settleApp(app);
271 };
272 await settleApp(app);
273 /** Palette → verb → owner/name. */
274 const verb = async (name: string, spec: string) => {
275 await type(":");
276 await type(name);
277 await enter();
278 await type(spec);
279 await enter();
280 };
281 return { app, verb, type, enter, text: () => app.screen.toText() };
282 }
283
284 test("the terminal tells an app through the same tell, and the ask is on the page", async () => {
285 const dana = getUserByName(child.db, "dana")!;
286 const t = await terminalAs(dana);
287 await t.verb("Tell the crew what you want", "demo/salon");
288 await t.type("Add a gift card option");
289 await t.enter();
290 await settleApp(t.app);
291 const repo = getRepo(child.db, "demo", "salon")!;
292 const issue = listIssues(child.db, repo.id, { state: "all", author: "dana" }).find((i) => i.title === "Add a gift card option");
293 expect(issue).toBeDefined();
294 expect(seen(await (await get("/")).text())).toContain("Add a gift card option");
295 t.app.stop();
296 });
297
298 test("the terminal reads the asks with their plain states", async () => {
299 const dana = getUserByName(child.db, "dana")!;
300 const t = await terminalAs(dana);
301 await t.verb("What you asked for", "demo/salon");
302 const text = t.text();
303 expect(text).toContain("Please add a price list to the front page");
304 expect(text).toContain("Add a gift card option");
305 expect(text).toMatch(/Done|Being worked on|Waiting/);
306 expect(text).toContain("answered: Done: the price list");
307 t.app.stop();
308 });
309
310 test("asks are plain states and private to the asker; a guest sees nothing", () => {
311 const repo = getRepo(child.db, "demo", "salon")!;
312 const dana = getUserByName(child.db, "dana")!;
313 const mine = askedBy(child, dana, repo, 10);
314 expect(mine.length).toBeGreaterThan(1);
315 for (const a of mine) expect(["Done", "Being worked on", "Waiting"]).toContain(a.state);
316 expect(askedBy(child, undefined, repo, 10)).toEqual([]);
317 const helper = getUserByName(child.db, "helper1")!;
318 expect(askedBy(child, helper, repo, 10)).toEqual([]);
319 });
320
321 test("a guest in the terminal cannot tell the crew", async () => {
322 const t = await terminalAs(undefined);
323 const repo = getRepo(child.db, "demo", "salon")!;
324 const before = listIssues(child.db, repo.id, { state: "all" }).length;
325 await t.verb("Tell the crew what you want", "demo/salon");
326 await t.type("sneaky");
327 await t.enter();
328 await settleApp(t.app);
329 expect(listIssues(child.db, repo.id, { state: "all" }).length).toBe(before);
330 t.app.stop();
331 });
332 });
333
334 describe("copied apps and the name forge", () => {
335 test("a copied app named forge is refused too", () => {
336 const source: SpawnSource = { catalog: [{ ref: "alice/forge", readable: true, bytes: 1, forgeJsonBytes: 0 }], briefs: [], subscriptions: [] };
337 const plan = planSpawn({ ...base, apps: ["alice/forge"] }, source);
338 expect(plan.ok).toBe(false);
339 if (!plan.ok) expect(plan.error.field).toBe("apps");
340 });
341 });
test/first-login.test.ts +1 −1
@@ -45,7 +45,7 @@ describe("the first login to a spawned forge", () => {
4545 let daily = "";
4646
4747 const url = (path: string) => `${servers.url}${path}`;
48 const page = async (cookie: string, path = "/") =>
48 const page = async (cookie: string, path = "/?all=1") =>
4949 (await (await fetch(url(path), { headers: { cookie } })).text()).replace(
5050 /\s+/g,
5151 " ",
test/spawn-child-apps.test.ts +3 −3
@@ -170,7 +170,7 @@ describe("a spawned child's apps", () => {
170170
171171 test("after claiming, the home shows the app, and says the crew has no model key and where to add one", async () => {
172172 const home = (
173 await (await fetch(`${servers.url}/`, { headers: { cookie } })).text()
173 await (await fetch(`${servers.url}/?all=1`, { headers: { cookie } })).text()
174174 ).replace(/\s+/g, " ");
175175 expect(home).toContain("bakery");
176176 expect(home).not.toContain("No apps yet");
@@ -203,7 +203,7 @@ describe("a spawned child's apps", () => {
203203 expect(asReader).not.toContain("The crew has no model key yet");
204204 // Nor on the home: there the note is for an admin or a writer of an app.
205205 const readerHome = await (
206 await fetch(`${servers.url}/`, {
206 await fetch(`${servers.url}/?all=1`, {
207207 headers: { cookie: `forge_session=${session.token}` },
208208 })
209209 ).text();
@@ -259,7 +259,7 @@ describe("a spawned child's apps", () => {
259259 expect(added.ok).toBe(true);
260260 expect(crewHasCredential(child.db, {})).toBe(true);
261261 const home = await (
262 await fetch(`${servers.url}/`, { headers: { cookie } })
262 await fetch(`${servers.url}/?all=1`, { headers: { cookie } })
263263 ).text();
264264 expect(home).not.toContain("The crew has no model key yet");
265265 });
test/spawn-keys.test.ts +1 −1
@@ -400,7 +400,7 @@ describe("a spawned child's own keys and domain", () => {
400400 const cookie = (claimed.headers.get("set-cookie") ?? "").split(";")[0]!;
401401 const home = (
402402 await (
403 await fetch(`${childServers.url}/`, { headers: { cookie } })
403 await fetch(`${childServers.url}/?all=1`, { headers: { cookie } })
404404 ).text()
405405 ).replace(/\s+/g, " ");
406406 expect(home).toContain(

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs