@vibes.diy/prompts 14.3.287 → 14.3.289

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,9 +7,10 @@ stands on the board-games skill, which owns the board's look, turns, seats and w
7
7
  Standard chess on 8×8 is the chess skill's (`chess.js` and Stockfish); this doc replaces both for
8
8
  every other game:
9
9
 
10
- 1. **The rules come from ffish**, Fairy-Stockfish's rules library, in a Web Worker. It knows
11
- about 120 variants by name and reads a new one from a few lines of text, so an app never
12
- writes a move generator, even for a piece nobody has played before.
10
+ 1. **The rules come from ffish**, Fairy-Stockfish's rules library, in a Web Worker, whether the
11
+ opponent is the computer or a friend on another phone. It knows about 120 variants by name and
12
+ reads a new one from a few lines of text, so an app never writes a move generator, even for a
13
+ piece nobody has played before.
13
14
  2. **The computer opponent is fairy-stockfish-single**, the Fairy-Stockfish engine built to run on
14
15
  one thread, in a second Web Worker. It plays every variant the rules worker knows, at any
15
16
  strength, and keeps the page responsive while it thinks.
@@ -80,6 +81,23 @@ flagRegionBlack = *1
80
81
  promotionPieceTypes = q
81
82
  ```
82
83
 
84
+ **A piece that moves differently swaps its letter onto another piece type.** Bishops that also
85
+ jump like knights are the built-in archbishop (bishop plus knight) wearing the bishop's letter:
86
+
87
+ ```ini
88
+ [leapingbishops:chess]
89
+ bishop = -
90
+ archbishop = b
91
+ promotionPieceTypes = qrbn
92
+ ```
93
+
94
+ Name the promotion pieces again after a swap: removing `bishop` also drops it from promotion, and
95
+ `b` in `promotionPieceTypes` now means the archbishop.
96
+
97
+ The built-in types cover most club ideas: `archbishop` (B+N), `chancellor` (R+N), `amazon` (Q+N),
98
+ `centaur` (K+N), `commoner` (moves like a king but is not one), `wazir`, `fers`, `alfil`. Anything else
99
+ is a `customPiece` in Betza notation. Variants.ini lists every type and its letter.
100
+
83
101
  The section name is the variant's id for `new ff.Board("pawnwars")` and for the engine's
84
102
  `UCI_Variant`. Load the same string into both workers.
85
103
 
@@ -103,6 +121,15 @@ vibe's page does not have. `VibesDIY/fairy-stockfish-single` is the same engine
103
121
  - **Credit it.** ffish and the engine are GPL-3 and run unmodified in their own workers; a muted
104
122
  line under the board says "Rules and engine: Fairy-Stockfish (GPL-3)".
105
123
 
124
+ ## Two players on two phones
125
+
126
+ A friend on their own phone is the board-games turn rule: one game doc holds the `variant`, the
127
+ `moves` list and the two seats, and only the seat whose turn it is writes. Each phone asks its
128
+ rules worker for the position after `moves` and accepts a move only when it is in `legal`, the same
129
+ as against the computer; there is just no engine worker. `access.js` cannot run ffish, so it checks
130
+ the seat, the turn, that `variant` is unchanged, and that the new `moves` is the old list with
131
+ exactly one move appended (every earlier move identical), so a turn can only add to the game.
132
+
106
133
  ## Drawing the board — any size
107
134
 
108
135
  Draw the board-games SVG board from the FEN, whatever its size: `parseBoard(fen)` in the example
package/llms/fireproof.md CHANGED
@@ -21,6 +21,8 @@ Each document has an `_id`, which can be auto-generated or set explicitly. Auto-
21
21
 
22
22
  Use granular documents, e.g. one document per user action, so saving a form or clicking a button should typically create or update a single document, or just a few documents. Avoid patterns that require a single document to grow without bound.
23
23
 
24
+ A flow someone moves through in steps (a quiz, a wizard, a game run, a bag or cart, a booking) is data from its first step. Write its parent record with the first step, then save each answer, pick, move or line as its own document carrying the parent's id (`attemptId`, `orderId`, `bagId`) the moment it is made, with a deterministic `_id` such as `` `${attemptId}:${step}` `` so a repeat rewrites one row. The parent's open record and a `useLiveQuery` on that id rebuild the screen, so a reload, another device or the person's own agent lands where they were. Scores, types and totals are computed from those rows; a snapshot stored on the parent when the flow finishes sits beside them and never replaces them. React state holds only what means nothing outside this screen: the open tab, the choice not yet confirmed, a hover.
25
+
24
26
  `useLiveQuery` populates and refreshes the UI reactively as data arrives, so render an inviting empty state while a list has nothing in it. Writes are optimistic and local: `put()`/`save()`/`del()` land in the local replica instantly, and transport or offline failures queue and retry on their own. The server's access rules have the final word: a refused write converges **server-wins** to the server's version, and the **platform** tells the visitor — in the app's own `forbidden("…")` words when it gave some, its own line otherwise, and "saved on this device" when a signed-out visitor's save waits for sign-in. So write plainly and let the store be the feedback: render from `useLiveQuery`/`useDocument`, gate write surfaces up front with `useVibe(dbName).can.create/edit/delete` so only allowed actions render, and keep `try/catch` for a save carrying `_files` (covered with the image uploader below). A toggle shows the whole shape — flip it at once, follow its receipt beside the control, and the list re-reads itself:
25
27
 
26
28
  ```jsx
@@ -0,0 +1,2 @@
1
+ import type { LlmConfig } from "./types.js";
2
+ export declare const groupPlanConfig: LlmConfig;
@@ -0,0 +1,7 @@
1
+ export const groupPlanConfig = {
2
+ name: "group-plan",
3
+ label: "Group plans",
4
+ description: "A job a group does together that ends in one result or one action: poll everyone then pick a date, collect each person's top picks then return a short bookable list, a meeting point that respects what each person privately needs, items people claim, an RSVP or order placed once for the group. Answers are one row per person, a person's private need is read only by its author and the scheduled tick that computes the plan, the plan record is written only by backend.js and quotes no private need, the scheduled tick notifies the owner only when a decision is needed (quorum, conflict, deadline) and stops at its check budget, an approval counts only from a member other than the proposer and only while the proposal's text, audience and amount are unchanged, and each outside action is claimed once as an intent (ifRev: null) and is done only when a receipt confirms it. A single person's own list or tracker, or a poll with no decision to act on, does not need it",
5
+ cues: ["poll everyone", "everyone's availability", "find a time that works", "plan for the group", "rsvp for"],
6
+ };
7
+ //# sourceMappingURL=group-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-plan.js","sourceRoot":"","sources":["../../jsr/llms/group-plan.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,eAAe,GAAc;IACxC,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,u8BAAu8B;IACz8B,IAAI,EAAE,CAAC,eAAe,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,UAAU,CAAC;CAC/G,CAAC"}
@@ -0,0 +1,315 @@
1
+ # Group plans: collect, decide, act once, report
2
+
3
+ This doc is in view because the app holds a job a group does together: a poll
4
+ that becomes a date, picks that become a bookable list, items people claim, a
5
+ plan that has to respect what each person privately needs. The app is where the
6
+ job lives. Anyone who opens it sees the current state, the one open decision and
7
+ the result, without reading back through a chat.
8
+
9
+ **Every record kind has a fixed set of writers.** People write their own
10
+ `answer` and `constraint` records, and create the `job` and set its goal. `onChange` writes `staleness`.
11
+ The scheduled tick in `backend.js` writes the `plan`, every `intent` and
12
+ `receipt`, and the job's progress. A member writes a `proposal` as themselves,
13
+ and a member other than the proposer writes the `approval`. Everything in this
14
+ doc follows from keeping those writers apart.
15
+
16
+ ## The records
17
+
18
+ All nine kinds live in one database, `job`, and each carries a `type`.
19
+
20
+ - **`job`**, one record with `_id: "job"`: `goal` (one sentence), `status`
21
+ (`collecting`, `deciding`, `acting`, `done` or `stopped`), `waitingOn` (who
22
+ or what, in words), `deadline` (ISO time or null), `quorum` (how many
23
+ answers mean "enough"), `checksLeft` (the budget for scheduled checks; 2016
24
+ is a week of 5-minute ticks) and `receiptId` once done. A page sets `goal`,
25
+ `deadline` and `quorum`, and may lower `checksLeft` to stop early. `status`,
26
+ `waitingOn` and `receiptId` move only in the tick. The page's first line
27
+ reads from it: "Waiting on 2 more picks · closes Friday 6pm".
28
+ - **`answer`**, one per person per question, `_id: "answer:<question>:<handle>"`:
29
+ `question`, `value`, `authorHandle`, `at`. One row per answer, never an array
30
+ on a shared record, so two people answering at once never overwrite each
31
+ other and the planner can count them.
32
+ - **`constraint`**, one per person, `_id: "constraint:<handle>"`: what only
33
+ that person and the plan's code should see ("I have a 6:10 train", "the
34
+ Saturday set is a must for me"). Its `authorHandle` is the only member who reads it.
35
+ - **`staleness`**, `_id: "staleness"`, written only by `onChange`: a marker
36
+ that an input moved. It names the changed record, so no member is granted
37
+ it; the tick reads it in admin mode. Its `_rev` is what the plan was
38
+ computed from.
39
+ - **`plan`**, `_id: "plan"`, written only by `backend.js`: the outcome and
40
+ nothing else ("Meet at the north gate at 4. Leave by 5:40."), plus `basedOn`,
41
+ the `staleness` rev it was computed from. It never quotes a constraint. A
42
+ constraint that shaped it shows as a count or a role ("one person has an
43
+ early train"), never as who or what.
44
+ - **`proposal`**, `_id: "proposal:<n>"`: `kind` (the action), `text` (exactly
45
+ what will happen), `audience` (the member handles it reaches, sorted),
46
+ `amount` (cents, or 0), `hash` (of text, audience and amount), `proposedBy`.
47
+ - **`approval`**, `_id: "approval:<proposalId>"`: `proposalId`, `hash`,
48
+ `approvedBy`. Create-only.
49
+ - **`intent`**, `_id: "intent:<kind>:<key>"`: an action about to happen once
50
+ (`rsvp`, `publish`, `order`, `invite`), its `status` (`claimed`, `sent`,
51
+ `confirmed` or `unclear`) and its `idempotencyKey`, which is its `_id`.
52
+ - **`receipt`**, `_id: "receipt:<intentId>"`: what the outside world answered
53
+ (a payment id, a booking reference, a reply). "Done" means a receipt exists.
54
+
55
+ ## Private things stay private because of who can read them
56
+
57
+ **Among the members, only its author reads a constraint, and the plan is computed where
58
+ every record is in reach: a `scheduled` tick.** `onChange` reads only what the
59
+ triggering person could read, so it can't see the others' constraints. A
60
+ `scheduled` tick runs in admin mode and sees them all. So `onChange` marks the
61
+ plan stale, and the next tick recomputes it with a plain function and writes
62
+ the `plan` record. No other member is granted the constraint channel, and the group's
63
+ assistant reads the app as an ordinary member, so it never reads a constraint
64
+ and can't repeat one. The app's owner can still open every record with the
65
+ admin toggle, so a person who owns the app should say so beside the form.
66
+
67
+ ### `access.js`
68
+ ```js
69
+ // Summary: anyone in the group answers and reads the plan; among members, a
70
+ // constraint is read only by its author (the tick and the owner's admin toggle
71
+ // see all); the plan, intents, receipts and the job's progress are written only
72
+ // by the scheduled tick.
73
+ export function job(doc, oldDoc, user, ctx) {
74
+ if (!user) throw { forbidden: "sign in to take part" };
75
+ if (oldDoc && oldDoc.type !== doc.type) throw { forbidden: "a record keeps its type" };
76
+ const me = user.userHandle;
77
+ switch (doc.type) {
78
+ case "answer":
79
+ ctx.requireAccess("group");
80
+ if (doc.authorHandle !== me || doc._id !== `answer:${doc.question}:${me}`)
81
+ throw { forbidden: "you answer for yourself" };
82
+ return { channels: ["group"] };
83
+ case "constraint":
84
+ ctx.requireAccess("group");
85
+ if (doc.authorHandle !== me || doc._id !== `constraint:${me}`)
86
+ throw { forbidden: "you note your own needs" };
87
+ return { channels: [`private:${me}`], grant: { users: { [me]: [`private:${me}`] } } };
88
+ case "proposal":
89
+ ctx.requireAccess("group");
90
+ if (oldDoc) throw { forbidden: "a proposal is replaced by a new one, never edited" };
91
+ if (doc.proposedBy !== me) throw { forbidden: "you propose as yourself" };
92
+ return { channels: ["group"] };
93
+ case "approval":
94
+ ctx.requireAccess("group");
95
+ if (oldDoc) throw { forbidden: "an approval is given once" }; // write-once
96
+ if (doc.approvedBy !== me) throw { forbidden: "you approve as yourself" };
97
+ return { channels: ["group"] };
98
+ case "staleness":
99
+ ctx.requireBackend("onChange");
100
+ return { channels: ["machine"] }; // granted to no member: it names which record changed
101
+ case "plan":
102
+ case "intent":
103
+ case "receipt":
104
+ ctx.requireBackend("scheduled"); // only the tick plans and acts
105
+ return { channels: ["group"] };
106
+ case "job": {
107
+ ctx.requireAccess("group");
108
+ // A page sets the goal and may run the budget down; progress belongs to the tick.
109
+ const moved = oldDoc
110
+ ? doc.status !== oldDoc.status || doc.waitingOn !== oldDoc.waitingOn ||
111
+ doc.receiptId !== oldDoc.receiptId || doc.checksLeft > oldDoc.checksLeft
112
+ : doc.status !== "collecting" || doc.receiptId != null;
113
+ if (moved) ctx.requireBackend("scheduled");
114
+ return { channels: ["group"] };
115
+ }
116
+ default:
117
+ throw { forbidden: "unknown record" };
118
+ }
119
+ }
120
+ ```
121
+
122
+ The `group` channel's membership comes from the app's membership records, the
123
+ way the access docs teach a group. When the app is made for a chat's group,
124
+ its members are the chat's linked members.
125
+
126
+ ## The backend does the waiting
127
+
128
+ **`onChange` marks the plan stale, `scheduled` recomputes it, finishes what was
129
+ started and decides whether a person is needed.** The tick costs no model
130
+ credits. It calls `ctx.notify` only when someone has to decide something or
131
+ the job is done, so most ticks are silent.
132
+
133
+ The notify goes to the app's owner, and `dedupeKey` keeps it to one
134
+ notification per reason. When a chat's assistant made the app for a group,
135
+ the owner is the group's handle, so that notification is the job handing
136
+ itself back to the chat's assistant, which reads the plan and speaks to the
137
+ group.
138
+
139
+ ### `backend.js`
140
+ ```js
141
+ export const config = { scheduled: { interval: "5m" } };
142
+ const DB = "job";
143
+ const INPUTS = ["answer", "constraint", "approval"];
144
+
145
+ export async function onChange(event, ctx) {
146
+ if (event.dbName !== DB || event.docId.startsWith("seed:")) return;
147
+ const t = event.deleted ? event.oldDoc?.type : event.doc?.type; // a withdrawn answer moves the plan too
148
+ if (!INPUTS.includes(t)) return;
149
+ // seq counts per record, so docId and seq together name this change; two marks in one millisecond still differ.
150
+ await ctx.db.put({ type: "staleness", change: `${event.docId}:${event.seq}`, at: Date.now() }, { db: DB, id: "staleness" });
151
+ }
152
+
153
+ export async function scheduled(event, ctx) {
154
+ const job = await ctx.db.get("job", { db: DB });
155
+ if (!job) return;
156
+
157
+ // Pending intents settle first, whatever the budget, the job's status or the approval say now.
158
+ // Nothing is sent here: a claimed or sent intent is only looked up, and an unclear one asks a person.
159
+ for (const intent of await allOfType(ctx, "intent")) {
160
+ if (intent.status === "unclear") await notifyOwner(ctx, `unclear:${intent._id}`, "A send may not have gone through. Ask before trying again.");
161
+ // finish is safe to repeat, so a tick that stopped between confirm, done and notify completes here.
162
+ else if (intent.status === "confirmed" || (await settle(ctx, intent))) return finish(ctx, job, intent);
163
+ }
164
+ if (job.status === "done" || job.status === "stopped") return;
165
+
166
+ // The budget: a job that has used its checks stops and says so once.
167
+ if ((job.checksLeft ?? 0) <= 0) {
168
+ await ctx.db.put({ ...job, status: "stopped", waitingOn: "stopped checking" }, { db: DB, id: "job", ifRev: job._rev });
169
+ await notifyOwner(ctx, `stopped:${job._rev}`, "Stopped checking: the budget ran out.");
170
+ return;
171
+ }
172
+
173
+ // Read the marker first: a change that lands while we compute leaves a newer rev, so the next tick runs again.
174
+ const stale = await ctx.db.get("staleness", { db: DB });
175
+ const plan = await ctx.db.get("plan", { db: DB });
176
+ if (stale && stale._rev !== plan?.basedOn) {
177
+ const answers = await allOfType(ctx, "answer");
178
+ const constraints = await allOfType(ctx, "constraint"); // admin mode: every author's
179
+ const next = computePlan(job, answers, constraints); // plain code, no model call
180
+ await ctx.db.put({ type: "plan", ...next, basedOn: stale._rev, computedAt: Date.now() }, { db: DB, id: "plan" });
181
+ if (next.answerCount >= job.quorum) await notifyOwner(ctx, `quorum:${next.version}`, "Enough answers are in.");
182
+ if (next.conflict) await notifyOwner(ctx, `conflict:${next.version}`, "Two needs collide.");
183
+ }
184
+ if (job.deadline && Date.parse(job.deadline) < Date.now()) await notifyOwner(ctx, "deadline", "The deadline passed.");
185
+
186
+ // Act on an approved proposal, or finish one an earlier tick claimed.
187
+ const proposal = await approvedProposal(ctx); // the newest proposal whose approval still holds, or null
188
+ if (proposal) {
189
+ const result = await actOnce(ctx, proposal.kind, proposal._id, (key) => send(proposal, key));
190
+ if (result?.confirmed) return finish(ctx, job, { _id: `intent:${proposal.kind}:${proposal._id}` });
191
+ }
192
+
193
+ await ctx.db.put({ ...job, checksLeft: job.checksLeft - 1 }, { db: DB, id: "job", ifRev: job._rev }).catch((err) => {
194
+ if (err.code !== "conflict") throw err; // someone edited the job; the next tick counts again
195
+ });
196
+ }
197
+
198
+ // Claim, act, confirm. A create-only claim lets exactly one tick win.
199
+ async function actOnce(ctx, kind, key, act) {
200
+ const id = `intent:${kind}:${key}`;
201
+ let intent = await ctx.db.get(id, { db: DB });
202
+ const fresh = !intent;
203
+ if (fresh) {
204
+ try {
205
+ await ctx.db.put({ type: "intent", kind, status: "claimed", idempotencyKey: id }, { db: DB, id, ifRev: null });
206
+ } catch (err) {
207
+ if (err.code !== "conflict") throw err;
208
+ return null; // another tick holds it; the next one picks it up
209
+ }
210
+ intent = await ctx.db.get(id, { db: DB });
211
+ }
212
+ // The receipt is written before the intent says confirmed, so a confirmed intent always has one.
213
+ if (intent.status === "confirmed") return { confirmed: true };
214
+ if (intent.status === "unclear") return null; // the tick re-asks a person until they decide
215
+ // An intent an earlier tick left: a receipt it wrote is the answer; otherwise ask the destination by the same key.
216
+ const receipt = fresh ? null : await ctx.db.get(`receipt:${id}`, { db: DB });
217
+ const found = receipt ?? (fresh ? null : await lookUp(intent));
218
+ const result = found ?? (fresh || honorsKey(kind) ? await act(id) : { unclear: true });
219
+ if (result.confirmed) {
220
+ await ctx.db.put({ type: "receipt", intentId: id, ...result }, { db: DB, id: `receipt:${id}`, ifRev: null }).catch((err) => {
221
+ if (err.code !== "conflict") throw err; // an earlier tick wrote it before it stopped
222
+ });
223
+ }
224
+ const status = result.confirmed ? "confirmed" : result.unclear ? "unclear" : "sent";
225
+ await ctx.db.put({ ...intent, status }, { db: DB, id, ifRev: intent._rev });
226
+ return result;
227
+ }
228
+
229
+ // An intent an earlier tick left: its receipt, or the destination's answer under the same key, confirms it.
230
+ async function settle(ctx, intent) {
231
+ const found = (await ctx.db.get(`receipt:${intent._id}`, { db: DB })) ?? (await lookUp(intent));
232
+ if (!found?.confirmed) return false; // still pending; the next tick asks again
233
+ await ctx.db.put({ type: "receipt", intentId: intent._id, confirmed: true, answer: found.answer }, { db: DB, id: `receipt:${intent._id}`, ifRev: null }).catch((err) => {
234
+ if (err.code !== "conflict") throw err;
235
+ });
236
+ await ctx.db.put({ ...intent, status: "confirmed" }, { db: DB, id: intent._id, ifRev: intent._rev });
237
+ return true;
238
+ }
239
+
240
+ // Done means a receipt exists: the job says so and the owner hears it once, however the receipt arrived.
241
+ // Every step repeats safely: the job write is skipped once done, and the dedupeKey collapses the notify.
242
+ async function finish(ctx, job, intent) {
243
+ if (job.status !== "done") {
244
+ await ctx.db.put({ ...job, status: "done", waitingOn: "", receiptId: `receipt:${intent._id}` }, { db: DB, id: "job", ifRev: job._rev });
245
+ }
246
+ await notifyOwner(ctx, `done:${intent._id}`, "Done: the receipt is in.");
247
+ }
248
+
249
+ async function notifyOwner(ctx, reason, body) {
250
+ await ctx.notify({ toHandle: ctx.appInfo.ownerHandle, body, dedupeKey: `${ctx.appInfo.appSlug}:${reason}` });
251
+ }
252
+
253
+ async function allOfType(ctx, type) {
254
+ const rows = [];
255
+ let after;
256
+ do {
257
+ const page = await ctx.db.query({ db: DB, field: "type", key: type, limit: 500, after });
258
+ rows.push(...page);
259
+ after = page.next;
260
+ } while (after);
261
+ return rows;
262
+ }
263
+ ```
264
+
265
+ The app's own logic fills in the rest:
266
+
267
+ - `computePlan` counts the answers, picks the option that breaks no
268
+ constraint and describes constraints only as counts. It returns
269
+ `{ summary, pick, answerCount, conflict, version }`, where `version`
270
+ changes whenever the pick or the count does.
271
+ - `send(proposal, key)` takes the action and passes `key` to the destination
272
+ as its idempotency key. It returns `{ confirmed: true, ... }` with the
273
+ destination's answer, or `{ unclear: true }` when the call dropped.
274
+ - `lookUp(intent)` asks the destination what happened under that key, and
275
+ returns `{ confirmed: true, answer }` or null.
276
+ - `honorsKey(kind)` is true only for a destination that honors the key.
277
+
278
+ ## An action happens once: claim, act, confirm
279
+
280
+ **Claim an intent with `ifRev: null` before acting, pass its id as the
281
+ idempotency key, and write a receipt only from a confirmed answer.** A
282
+ create-only put lets exactly one handler win; an `access.js` `oldDoc` check
283
+ alone can race. The claim is not the receipt.
284
+
285
+ - **A tick that stops after the claim** leaves an intent with no receipt. The
286
+ next tick finds it through `actOnce`, asks the destination by the same key
287
+ what happened, then confirms or retries.
288
+ - **Only a destination that honors the key can be retried blind:** Stripe,
289
+ or this app's own records. Email and texts have no such key. An intent to
290
+ one of those whose send went unclear is marked `unclear`, the owner is told
291
+ once, and a person decides before anything is sent again.
292
+ - **Done is told once.** When the receipt lands, the tick sets the job `done`
293
+ with its `receiptId` and notifies the owner with what happened.
294
+
295
+ ## Approval is a tap bound to what was shown
296
+
297
+ **An approval counts only while the proposal's text, audience and amount are
298
+ unchanged.** `approvedProposal` recomputes the hash from the current proposal
299
+ and the current member list, and compares it to the approval's `hash`. If
300
+ someone joined, the price moved or the words changed, the action waits and a
301
+ new proposal asks again. The proposer's own approval never counts. Taking money
302
+ or publishing to a wider audience always needs one, and an action that spends a
303
+ person's money or speaks for one person counts only that person's approval.
304
+ Actions run only in the `scheduled` tick, after this check.
305
+
306
+ ## What the page shows
307
+
308
+ - First line: the job's status in words, from the `job` record.
309
+ - The open decision, if there is one: the proposal's text, with Approve for
310
+ anyone but its proposer.
311
+ - The plan, from the `plan` record, once there is one.
312
+ - "Only you see this" beside each person's constraint form (or "only you and
313
+ the app's owner", when a person rather than a group's assistant owns it). The form writes
314
+ their own `constraint` record and nothing else.
315
+ - The receipt once it exists, with what confirmed it.
package/llms/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { chessConfig } from "./chess.js";
6
6
  export { chessVariantsConfig } from "./chess-variants.js";
7
7
  export { surfaceBoardConfig } from "./surface-board.js";
8
8
  export { ownerSecretConfig } from "./owner-secret.js";
9
+ export { groupPlanConfig } from "./group-plan.js";
9
10
  export { thirdPartyEmbedConfig } from "./third-party-embed.js";
10
11
  export { weatherConfig } from "./weather.js";
11
12
  export { keepsakeConfig } from "./keepsake.js";
@@ -81,7 +82,7 @@ export { uiTestimonialsConfig } from "./ui-testimonials.js";
81
82
  export type { LlmConfig, SkillCredential, SkillEgress } from "./types.js";
82
83
  export { cueMatches, cueMatchedSkills, type CueCatalogEntry } from "./cues.js";
83
84
  export { expandSkills, onSkillMenu, skillGraphProblems, universalSkillNames, type NeedsCatalogEntry } from "./needs.js";
84
- export declare const allConfigs: readonly [LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig];
85
+ export declare const allConfigs: readonly [LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig, LlmConfig];
85
86
  export { mapsConfig } from "./maps.js";
86
87
  export declare const SKILL_ALIASES: ReadonlyMap<string, string>;
87
88
  export declare function canonicalSkillName(name: string): string;
package/llms/index.js CHANGED
@@ -6,6 +6,7 @@ import { chessConfig } from "./chess.js";
6
6
  import { chessVariantsConfig } from "./chess-variants.js";
7
7
  import { surfaceBoardConfig } from "./surface-board.js";
8
8
  import { ownerSecretConfig } from "./owner-secret.js";
9
+ import { groupPlanConfig } from "./group-plan.js";
9
10
  import { thirdPartyEmbedConfig } from "./third-party-embed.js";
10
11
  import { weatherConfig } from "./weather.js";
11
12
  import { keepsakeConfig } from "./keepsake.js";
@@ -85,6 +86,7 @@ export { chessConfig } from "./chess.js";
85
86
  export { chessVariantsConfig } from "./chess-variants.js";
86
87
  export { surfaceBoardConfig } from "./surface-board.js";
87
88
  export { ownerSecretConfig } from "./owner-secret.js";
89
+ export { groupPlanConfig } from "./group-plan.js";
88
90
  export { thirdPartyEmbedConfig } from "./third-party-embed.js";
89
91
  export { weatherConfig } from "./weather.js";
90
92
  export { keepsakeConfig } from "./keepsake.js";
@@ -203,6 +205,7 @@ export const allConfigs = [
203
205
  weatherConfig,
204
206
  stripeConfig,
205
207
  stripeSubscriptionsConfig,
208
+ groupPlanConfig,
206
209
  blocklyConfig,
207
210
  strudelConfig,
208
211
  physicsConfig,
package/llms/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../jsr/llms/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAA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SAAS,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAChH,KAAK,MAAM,CAAC,IAAI,IAAI;YAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK;gBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/llms/stripe.md CHANGED
@@ -1078,15 +1078,17 @@ and `rev`, a fresh random string on every write, which is the version the
1078
1078
  Pay link names. Its lines take one of two shapes, and a shop picks the one
1079
1079
  that fits:
1080
1080
 
1081
- - **Lines on the bag.** `lines: [{ productId, qty }]` on the bag itself, and
1082
- every change is one put of the whole bag with a new `rev`. Right for most
1083
- shops: one record, one write, nothing to keep in step.
1084
1081
  - **A record per line.** Each line is its own `type: "line"` record with
1085
1082
  `bagId`, `productId`, `qty` and whatever options it carries (size, milk,
1086
1083
  engraving), and every line write also puts the bag with a new `rev` and
1087
- `touchedAt`. Right when a line is rich enough to edit on its own screen.
1088
- The line carries the `touchedAt` of the bag write that went with it, so a
1089
- line newer than the bag was written after the link and is not in it.
1084
+ `touchedAt`. Right for most shops: each line can be read, counted and
1085
+ changed on its own, the shop can tally a product across bags, and anyone
1086
+ helping the buyer adds a line without rewriting the rest. The line carries
1087
+ the `touchedAt` of the bag write that went with it, so a line newer than
1088
+ the bag was written after the link and is not in it.
1089
+ - **Lines on the bag.** `lines: [{ productId, qty }]` on the bag itself, and
1090
+ every change is one put of the whole bag with a new `rev`. Right only for a
1091
+ bag of one or two fixed things that nobody reads line by line.
1090
1092
 
1091
1093
  A line's options are the shop's to price: `priceBag` reads them off the line
1092
1094
  and adds what the owner's product record says they cost, so a modifier is
@@ -1187,9 +1189,17 @@ answer, and the page puts the bag on it.
1187
1189
  ### `App.jsx`
1188
1190
  ```jsx partial
1189
1191
  // The buyer's open bag: theirs alone (access.js routes it to their own channel), and the newest one
1190
- // no paid order names. Every Add is a put of the whole bag with a fresh rev.
1192
+ // no paid order names. Its lines are records naming it by bagId; every Add puts one line and the
1193
+ // bag with a fresh rev.
1191
1194
  const { docs: bags } = useLiveQuery("type", { key: "bag" });
1192
1195
  const bag = me && bags.filter((b) => b.buyerHandle === me.userHandle && !orders.some((o) => o.bagId === b._id && o.status === "paid")).sort((a, b) => b.touchedAt - a.touchedAt)[0];
1196
+ const { docs: bagLines } = useLiveQuery("bagId", { key: bag?._id ?? "" });
1197
+ const savedLines = bagLines.filter((l) => l.type === "line" && l.buyerHandle === me?.userHandle);
1198
+ // A bag this page started that the live query has not returned yet: two quick Adds share it.
1199
+ const startedBag = useRef(null);
1200
+ useEffect(() => {
1201
+ if (bag) startedBag.current = null; // the query has it now, and a paid bag must not be reused
1202
+ }, [bag?._id]);
1193
1203
  // A guest's bag: page state kept in localStorage, emptied when their payment comes back paid.
1194
1204
  const [guestLines, setGuestLines] = useState(() => {
1195
1205
  try {
@@ -1207,12 +1217,21 @@ useEffect(() => {
1207
1217
  useEffect(() => {
1208
1218
  if (!me && back?.status === "paid") setGuestLines([]);
1209
1219
  }, [me, back?.status]);
1210
- const lines = ((me ? bag?.lines : guestLines) ?? []).filter((l) => forSale.some((p) => p._id === l.productId));
1211
- const add = (productId) => {
1212
- const kept = (me ? bag?.lines : guestLines) ?? [];
1213
- const next = kept.some((l) => l.productId === productId) ? kept.map((l) => (l.productId === productId ? { ...l, qty: l.qty + 1 } : l)) : [...kept, { productId, qty: 1 }];
1214
- if (!me) return setGuestLines(next);
1215
- database.put({ ...(bag ?? { _id: "bag-" + crypto.randomUUID(), type: "bag", buyerHandle: me.userHandle }), lines: next, rev: crypto.randomUUID(), touchedAt: Date.now() });
1220
+ const lines = (me ? savedLines : guestLines).filter((l) => forSale.some((p) => p._id === l.productId));
1221
+ const add = async (productId) => {
1222
+ if (!me) {
1223
+ const next = guestLines.some((l) => l.productId === productId) ? guestLines.map((l) => (l.productId === productId ? { ...l, qty: l.qty + 1 } : l)) : [...guestLines, { productId, qty: 1 }];
1224
+ return setGuestLines(next);
1225
+ }
1226
+ // One line per product, its id derived from the bag and the product, so a second Add is a new
1227
+ // quantity on the same line, options and all. The bag takes its new rev FIRST, so a Pay link to
1228
+ // the old version is refused before its line changes; the line shares the bag's touchedAt, so
1229
+ // /pay counts it in this version.
1230
+ const bagId = bag?._id ?? (startedBag.current ??= "bag-" + crypto.randomUUID());
1231
+ const touchedAt = Date.now();
1232
+ const line = savedLines.find((l) => l.productId === productId);
1233
+ await database.put({ ...(bag ?? { _id: bagId, type: "bag", buyerHandle: me.userHandle }), rev: crypto.randomUUID(), touchedAt });
1234
+ await database.put({ ...(line ?? { _id: `${bagId}:${productId}`, type: "line", bagId, buyerHandle: me.userHandle, productId }), qty: (line?.qty ?? 0) + 1, touchedAt });
1216
1235
  };
1217
1236
  // The same address anyone helping the buyer would hand them. The subtotal is a preview; /pay prices it.
1218
1237
  const payUrl = bag && setup?.pay && `${setup.pay}?bag=${encodeURIComponent(bag._id)}&rev=${encodeURIComponent(bag.rev)}&mode=${setup.mode}`;
package/llms/ui-quiz.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Quiz
2
2
 
3
- A short multiple-choice quiz that keeps score: an astronomy club's star-chart check, a refresher round before a test, a pub quiz warm-up, a training check for new staff. Reach for it when the app asks a handful of questions one at a time, says right or wrong after each answer, ends on a score and lets people come back to beat it. Each finished attempt someone saves is its own document, so their past scores are there on the next visit and on any device.
3
+ A short multiple-choice quiz that keeps score: an astronomy club's star-chart check, a refresher round before a test, a pub quiz warm-up, a training check for new staff. Reach for it when the app asks a handful of questions one at a time, says right or wrong after each answer, ends on a score and lets people come back to beat it. Every answer is its own document the moment it is checked, keyed to its attempt, so a reload or another device opens the quiz at the question the person reached, their past attempts are there on the next visit, and the score is computed from the answers.
4
4
 
5
5
  Built from @vibes.diy/ui components; persisted state lives in Fireproof. Every write surface is gated on `useVibe(dbName).can`.
6
6
 
7
7
  ## The block
8
8
 
9
- One view with one job: answer the questions, then keep the score. A `Heading` and a muted line open the page. The quiz sits on a `Card`: an `Eyebrow` with the question number beside an `info` `Badge` counting correct answers so far (it steps aside on the result, which states the score once), and a `Progress` (`info`) across the top. Each question is a `Heading level={2}` over a `RadioGroup`; `Check answer` is the view's one lead, then the answer shows as a `Badge` (`up` right, `down` wrong) with the right option in muted `Text`, and the lead becomes `Next question`. The result swaps in an `IconTile` (`up` for a pass, `warn` otherwise), the score and a recap of every question with its own `up` or `down` `Badge`. `Save score` is then the lead, with `loading` while the write lands, beside a quiet `Play again`. A signed-in person's earlier attempts sit below as `RowCard`s, newest first, each with a `Badge` toned by how it went. Saving waits on its `can` verdict from `useVibe("quiz")`, the database the attempts live in: a `Skeleton` inside an `aria-busy` wrapper while it resolves, a `Sign in to save your score` lead wired to `useViewer().requestLogin()` for a visitor who has not signed in, and a sentence in the app's own words when saving is closed. Anyone can take the quiz without signing in; the attempt lives only in the page until it is saved, and the copy says so.
9
+ One view with one job: answer the questions, then keep the score. A `Heading` and a muted line open the page. The quiz sits on a `Card`: an `Eyebrow` with the question number beside an `info` `Badge` counting correct answers so far (it steps aside on the result, which states the score once), and a `Progress` (`info`) across the top. Each question is a `Heading level={2}` over a `RadioGroup`; `Check answer` is the view's one lead, then the answer shows as a `Badge` (`up` right, `down` wrong) with the right option in muted `Text`, and the lead becomes `Next question`. The result swaps in an `IconTile` (`up` for a pass, `warn` otherwise), the score and a recap of every question with its own `up` or `down` `Badge`. A quiet `Play again` sits beside a line saying the attempt is kept. A signed-in person's finished attempts sit below as `RowCard`s, newest first, each with a `Badge` toned by how it went. Keeping answers waits on its `can` verdict from `useVibe("quiz")`, the database the attempts live in: a `Skeleton` inside an `aria-busy` wrapper while it resolves, a `Sign in to keep your answers` lead wired to `useViewer().requestLogin()` for a visitor who has not signed in, and a sentence in the app's own words when keeping is closed. Anyone can take the quiz without signing in; a visitor's answers stay on the page, and the copy invites them to sign in so every answer is kept as they go.
10
10
 
11
11
  ### `App.jsx`
12
12
  ```jsx
@@ -71,67 +71,87 @@ const when = (ms) => new Date(ms).toLocaleDateString(undefined, { month: "short"
71
71
 
72
72
  export default function App() {
73
73
  const { database, useLiveQuery } = useFireproof("quiz");
74
- const { docs } = useLiveQuery("type", { key: "attempt" });
74
+ const { docs: attempts } = useLiveQuery("type", { key: "attempt" });
75
75
  const { can, me } = useVibe("quiz");
76
76
  const { requestLogin } = useViewer();
77
77
 
78
- // The attempt is a draft: it lives in the page until it ends and someone saves it.
79
- const [step, setStep] = useState(0);
80
- const [choice, setChoice] = useState("");
81
- const [revealed, setRevealed] = useState(false);
82
- const [results, setResults] = useState([]);
83
- const [saving, setSaving] = useState(false);
84
- const [savedResults, setSavedResults] = useState(undefined);
85
-
86
- const question = QUESTIONS[step];
87
- const score = results.filter(Boolean).length;
88
- const done = results.length === TOTAL;
89
- const lastRight = results[results.length - 1];
90
-
91
- // One document per saved attempt; this person's, newest first.
78
+ // This person's attempts, newest first. One without `finishedAt` is the quiz they are partway
79
+ // through: a reload, another device or another tab opens it at the question they reached.
92
80
  const mine = me
93
- ? docs
94
- .filter((d) => d.quiz === QUIZ_ID && d.authorHandle === me.userHandle)
95
- .sort((a, b) => b.createdAt - a.createdAt)
96
- .slice(0, 5)
81
+ ? attempts.filter((d) => d.quiz === QUIZ_ID && d.authorHandle === me.userHandle).sort((a, b) => b.createdAt - a.createdAt)
97
82
  : [];
83
+ const open = mine.find((a) => !a.finishedAt);
84
+ const finished = mine.filter((a) => a.finishedAt).slice(0, 5);
98
85
 
99
- // The verdict for the doc saveScore writes, carrying the same fields it stamps.
100
- const canSave = can.create({ type: "attempt", quiz: QUIZ_ID, authorHandle: me?.userHandle });
86
+ const [choice, setChoice] = useState("");
87
+ // The answer just checked, kept on screen until Next; the saved row is the record.
88
+ const [shown, setShown] = useState(null);
89
+ // The attempt whose result is on screen once its last answer lands.
90
+ const [doneId, setDoneId] = useState(null);
91
+ // A new attempt's id is made once, so the gate and both puts check one complete record.
92
+ const [newAttemptId, setNewAttemptId] = useState(() => "attempt-" + crypto.randomUUID());
93
+ const [pageAnswers, setPageAnswers] = useState([]);
101
94
 
102
- function check() {
103
- setRevealed(true);
104
- setResults((r) => [...r, choice === question.answer]);
105
- }
95
+ // One `answer` document per question, keyed by its attempt: the attempt's answers are a query, and
96
+ // every score, recap and later view (which question trips people up) is computed from them.
97
+ const attemptId = open?._id ?? doneId ?? newAttemptId;
98
+ const { docs: rows } = useLiveQuery("attemptId", { key: attemptId });
99
+ const saved = rows.filter((d) => d.type === "answer").sort((a, b) => a.step - b.step);
100
+
101
+ // The answer this Check would save, complete, so the verdict is on the exact record the put writes.
102
+ const nextStep = shown ? shown.step : saved.length;
103
+ const candidate = {
104
+ _id: `${attemptId}:${nextStep}`,
105
+ type: "answer",
106
+ attemptId,
107
+ quiz: QUIZ_ID,
108
+ step: nextStep,
109
+ choice,
110
+ right: choice === QUESTIONS[nextStep]?.answer,
111
+ authorHandle: me?.userHandle,
112
+ };
113
+ // A signed-in person keeps each answer as it is made, when `can` says so. A visitor plays in the page.
114
+ const canKeep = can.create(candidate);
115
+ const keeping = Boolean(me) && !canKeep.pending && canKeep.ok;
116
+ const answers = keeping ? saved : pageAnswers;
117
+
118
+ const step = shown ? shown.step : answers.length;
119
+ const done = !shown && answers.length === TOTAL;
120
+ const question = QUESTIONS[step];
121
+ const score = answers.filter((a) => a.right).length;
122
+ // Next waits until the checked answer is a row (and, on the last question, until the attempt is
123
+ // finished), so the next question is read from the saved answers rather than racing them.
124
+ const landed = !shown || !keeping || (shown.step === TOTAL - 1 ? doneId !== null : saved.length > shown.step);
106
125
 
107
- function next() {
108
- setStep((s) => s + 1);
126
+ async function check() {
127
+ const entry = { step, choice, right: choice === question.answer };
128
+ setShown(entry);
109
129
  setChoice("");
110
- setRevealed(false);
130
+ if (!keeping) return setPageAnswers((a) => [...a, entry]);
131
+ // The attempt is written with its first answer, so the person's place exists from step one.
132
+ const attempt = open ?? { _id: attemptId, type: "attempt", quiz: QUIZ_ID, authorHandle: me.userHandle, createdAt: Date.now() };
133
+ if (!open) await database.put(attempt);
134
+ // A deterministic id per question: checking the same question twice rewrites one row, never two.
135
+ await database.put({ ...candidate, ...entry, answeredAt: Date.now() });
136
+ if (step === TOTAL - 1) {
137
+ // The score stored on the attempt is a snapshot beside the answers, for lists that read attempts alone.
138
+ const correct = score + (entry.right ? 1 : 0);
139
+ await database.put({ ...attempt, correct, total: TOTAL, finishedAt: Date.now() });
140
+ setDoneId(attempt._id);
141
+ }
111
142
  }
112
143
 
113
144
  function playAgain() {
114
- setStep(0);
115
145
  setChoice("");
116
- setRevealed(false);
117
- setResults([]);
118
- setSavedResults(undefined);
119
- }
120
-
121
- async function saveScore() {
122
- setSaving(true);
123
- try {
124
- await database.put({ type: "attempt", quiz: QUIZ_ID, correct: score, total: TOTAL, authorHandle: me?.userHandle, createdAt: Date.now() });
125
- // Marks this exact attempt as saved, so the button can't post it twice.
126
- setSavedResults(results);
127
- } finally {
128
- setSaving(false);
129
- }
146
+ setShown(null);
147
+ setDoneId(null);
148
+ setNewAttemptId("attempt-" + crypto.randomUUID());
149
+ setPageAnswers([]);
130
150
  }
131
151
 
132
152
  let ending;
133
- if (savedResults === results) ending = <Text muted>Saved. It is in your attempts below.</Text>;
134
- else if (canSave.pending)
153
+ if (keeping) ending = <Text muted>Kept. It is in your attempts below.</Text>;
154
+ else if (canKeep.pending)
135
155
  ending = (
136
156
  <div aria-busy="true">
137
157
  <Skeleton variant="row" />
@@ -141,18 +161,12 @@ export default function App() {
141
161
  ending = (
142
162
  <Stack gap={2}>
143
163
  <Text size="sm" muted>
144
- Sign in to keep this score. Signing in may start the quiz over.
164
+ Sign in and every answer is kept as you go, so you can pick up where you left off.
145
165
  </Text>
146
- <Button onClick={requestLogin}>Sign in to save your score</Button>
166
+ <Button onClick={requestLogin}>Sign in to keep your answers</Button>
147
167
  </Stack>
148
168
  );
149
- else if (!canSave.ok) ending = <Text muted>Scores aren't being kept right now. Play on for practice.</Text>;
150
- else
151
- ending = (
152
- <Button loading={saving} onClick={saveScore}>
153
- Save score
154
- </Button>
155
- );
169
+ else ending = <Text muted>Scores aren't being kept right now. Play on for practice.</Text>;
156
170
 
157
171
  const passed = score >= PASS;
158
172
 
@@ -171,7 +185,7 @@ export default function App() {
171
185
  <Eyebrow>{done ? "Finished" : `Question ${step + 1} of ${TOTAL}`}</Eyebrow>
172
186
  {!done && <Badge tone="info">{score} correct</Badge>}
173
187
  </Row>
174
- <Progress value={results.length} max={TOTAL} tone="info" label="Quiz progress" />
188
+ <Progress value={answers.length} max={TOTAL} tone="info" label="Quiz progress" />
175
189
  </Stack>
176
190
 
177
191
  {done ? (
@@ -188,7 +202,7 @@ export default function App() {
188
202
  <Stack gap={2}>
189
203
  {QUESTIONS.map((item, i) => (
190
204
  <Row key={item.q} gap={2} wrap={false}>
191
- <Badge tone={results[i] ? "up" : "down"}>{results[i] ? "Right" : "Missed"}</Badge>
205
+ <Badge tone={answers[i]?.right ? "up" : "down"}>{answers[i]?.right ? "Right" : "Missed"}</Badge>
192
206
  <Text size="sm" muted truncate>
193
207
  {item.q}
194
208
  </Text>
@@ -205,18 +219,20 @@ export default function App() {
205
219
  ) : (
206
220
  <Stack gap={4}>
207
221
  <Heading level={2}>{question.q}</Heading>
208
- <RadioGroup label="Your answer" value={choice} onChange={setChoice} options={question.options} disabled={revealed} />
209
- {revealed && (
222
+ <RadioGroup label="Your answer" value={shown ? shown.choice : choice} onChange={setChoice} options={question.options} disabled={Boolean(shown)} />
223
+ {shown && (
210
224
  <Row gap={2} wrap={false}>
211
- <Badge tone={lastRight ? "up" : "down"}>{lastRight ? "Correct" : "Not quite"}</Badge>
212
- {!lastRight && <Text muted>The answer is “{answerLabel(question)}”.</Text>}
225
+ <Badge tone={shown.right ? "up" : "down"}>{shown.right ? "Correct" : "Not quite"}</Badge>
226
+ {!shown.right && <Text muted>The answer is “{answerLabel(question)}”.</Text>}
213
227
  </Row>
214
228
  )}
215
229
  <Row justify="end">
216
- {revealed ? (
217
- <Button onClick={next}>Next question</Button>
230
+ {shown ? (
231
+ <Button disabled={!landed} onClick={() => setShown(null)}>
232
+ Next question
233
+ </Button>
218
234
  ) : (
219
- <Button disabled={!choice} onClick={check}>
235
+ <Button disabled={!choice || (Boolean(me) && canKeep.pending)} onClick={check}>
220
236
  Check answer
221
237
  </Button>
222
238
  )}
@@ -226,11 +242,11 @@ export default function App() {
226
242
  </Stack>
227
243
  </Card>
228
244
 
229
- {me && mine.length > 0 && (
245
+ {finished.length > 0 && (
230
246
  <Stack gap={3}>
231
247
  <Heading level={2}>Your attempts</Heading>
232
248
  <Stack gap={2}>
233
- {mine.map((a) => (
249
+ {finished.map((a) => (
234
250
  <RowCard key={a._id}>
235
251
  <Row justify="between" wrap={false}>
236
252
  <Text>
@@ -238,7 +254,7 @@ export default function App() {
238
254
  </Text>
239
255
  <Row gap={2} wrap={false}>
240
256
  <Text size="sm" muted>
241
- {when(a.createdAt)}
257
+ {when(a.finishedAt)}
242
258
  </Text>
243
259
  <Badge tone={a.correct === a.total ? "up" : a.correct >= PASS ? "info" : "warn"}>
244
260
  {a.correct === a.total ? "Perfect" : a.correct >= PASS ? "Passed" : "Practise"}
@@ -258,8 +274,9 @@ export default function App() {
258
274
 
259
275
  ## Adapting
260
276
 
261
- - Change the questions, not the flow: each one is `{ q, options: [{ value, label }], answer }`, the attempt is a list of right-or-wrong results in page state, and the database is touched only when a finished attempt is saved.
262
- - Keep one attempt document per saved run and compute everything else (best score, average, a class board) from them at read time; a single "best score" document that each attempt rewrites loses scores when two people finish at once.
277
+ - Change the questions, not the flow: each one is `{ q, options: [{ value, label }], answer }`; the attempt document is written with the first answer, each answer is its own `answer` document with `attemptId`, `step`, the `choice` and whether it was `right`, and the attempt gains `finishedAt` and a score snapshot with the last one.
278
+ - Keep the person's own picks, not only the result: a personality quiz saves each answer's `choice` (and the trait it scores) and computes the type from the answers, so a reload resumes, a retake can be compared answer by answer, and a later view can show which questions moved the result.
279
+ - Keep one attempt document per run and compute everything else (best score, average, a class board) from them at read time; a single "best score" document that each attempt rewrites loses scores when two people finish at once.
263
280
  - Store what a later view might group or sort by on the attempt (`quiz` for which quiz, `correct`, `total`, a `level`), and give each quiz its own `QUIZ_ID` so several quizzes can share one database.
264
281
  - A board of everyone's scores names each player with `useViewer()`'s `ViewerTag` from the stored `authorHandle`. Scores people would rather keep to themselves (a staff assessment, a medical exam drill) need an access function that limits who can read them before they are shown to anyone else.
265
282
  - A new write surface gets its own verdict: `can.create(draft)` with the fields the write stamps, `can.edit(doc)` or `can.delete(doc)` on the document it changes, always on `useVibe` of the database it writes.
@@ -1,6 +1,6 @@
1
1
  # Storefront
2
2
 
3
- A small shop: product cards to browse, a category filter and a search, a bag that adds things up, and a checkout that places the order. It fits a potter's ceramics, a bakery's preorders, a club's merch table or a school fair's stall. Reach for it whenever the app's core is a short catalogue that people pick from and then order. The catalogue is the owner's: each thing for sale is a `product` record the owner adds on the app's own Products screen, with its name, price, a short line, a category and a photo, so changing what the shop sells is an edit in the app, never a rebuild. The bag lives in the page while someone shops. Each placed order persists as its own document, so the shop can see what to make and the buyer can see what they ordered. It records orders; taking card payment is the `stripe` skill, which reads these same product records.
3
+ A small shop: product cards to browse, a category filter and a search, a bag that adds things up, and a checkout that places the order. It fits a potter's ceramics, a bakery's preorders, a club's merch table or a school fair's stall. Reach for it whenever the app's core is a short catalogue that people pick from and then order. The catalogue is the owner's: each thing for sale is a `product` record the owner adds on the app's own Products screen, with its name, price, a short line, a category and a photo, so changing what the shop sells is an edit in the app, never a rebuild. A signed-in buyer's bag is saved as they shop: an open order and one line document per product, keyed by the order's id, so the bag is there after a reload or on another device, and placing it moves that same order to received. The shop can see what to make, line by line, and the buyer can see what they ordered. It records orders; taking card payment is the `stripe` skill, which reads these same product records.
4
4
 
5
5
  Built from @vibes.diy/ui components; persisted state lives in Fireproof. Every write surface is gated on `useVibe(dbName).can`.
6
6
 
@@ -10,7 +10,7 @@ Two screens, one job each. The **Shop** fills the bag and places the order: a `N
10
10
 
11
11
  The **Products** screen is the owner's, behind `can.create` on a product draft: a form for the name, price, short line, category and photo, then one row per product whose price edits in place and whose `On sale` checkbox puts it in front of buyers or takes it away. The catalogue starts empty, and an owner who opens an empty shop lands on this screen with "Add the first thing you sell"; a visitor sees a warm `Empty` until the first product goes on sale. Every price is a whole number in the currency's smallest unit (cents for usd, whole yen for jpy) beside its `currency`, the unit card payments charge in, and the page shows, edits and adds prices through that unit.
12
12
 
13
- An order is one document holding a snapshot of each line's title, unit price and quantity, the totals, the currency and the buyer's handle, so a later price change never rewrites an order already placed; the person's own orders list under the bag, each with a `Badge` for its status (`info` received, `warn` ready to collect, `up` collected). Checkout waits on its `can` verdict from `useVibe("orders")`: a `Skeleton` inside an `aria-busy` wrapper while it resolves, a sentence in the app's own words when ordering is closed, and for a visitor who has not signed in a `Sign in to place your order` lead wired to `useViewer().requestLogin()`, with the bag they filled kept in place. Sign-in is required here, unlike a local-first note, because a signed-out write stays on the device until sign-in: an order placed that way would never reach the shop. That sign-in lead belongs to the pay-when-you-collect order alone: a shop that takes card payment with the `stripe` skill shows Pay to every visitor, signed in or not, because Stripe's own page takes the buyer's email and sends the receipt, and it asks for sign-in only when the owner asked for it.
13
+ An order is a document with its lines beside it: each `line` carries the `orderId`, the product, the quantity and, once placed, the title and unit price it was bought at, and the order holds the totals, the currency and the buyer's handle, so a later price change never rewrites an order already placed and every line can be read, counted and fixed on its own; the person's own orders list under the bag, each with a `Badge` for its status (`info` received, `warn` ready to collect, `up` collected). Checkout waits on its `can` verdict from `useVibe("orders")`: a `Skeleton` inside an `aria-busy` wrapper while it resolves, a sentence in the app's own words when ordering is closed, and for a visitor who has not signed in a `Sign in to place your order` lead wired to `useViewer().requestLogin()`, with the bag they filled kept in place. Sign-in is required here, unlike a local-first note, because a signed-out write stays on the device until sign-in: an order placed that way would never reach the shop. That sign-in lead belongs to the pay-when-you-collect order alone: a shop that takes card payment with the `stripe` skill shows Pay to every visitor, signed in or not, because Stripe's own page takes the buyer's email and sends the receipt, and it asks for sign-in only when the owner asked for it.
14
14
 
15
15
  ### `App.jsx`
16
16
  ```jsx
@@ -213,9 +213,29 @@ export default function App() {
213
213
 
214
214
  const [category, setCategory] = useState("all");
215
215
  const [query, setQuery] = useState("");
216
- // The bag is a draft: it lives in the page until the order is placed.
217
- const [bag, setBag] = useState({});
216
+ // A signed-in buyer's bag is their order in the making: an `order` with status "open" and one
217
+ // `line` document per product, keyed by its orderId. Every Add writes its line at once, so the bag
218
+ // is there after a reload and on their phone, and placing the order moves the same id along.
219
+ const mine = me ? orders.filter((o) => o.authorHandle === me.userHandle).sort((a, b) => b.createdAt - a.createdAt) : [];
220
+ const open = mine.find((o) => o.status === "open");
221
+ const placed = mine.filter((o) => o.status !== "open");
222
+ const { docs: lineDocs } = useLiveQuery("orderId", { key: open?._id ?? "" });
223
+ // The verdict for the order this bag becomes, carrying the fields change() stamps on it.
224
+ const orderDraft = { type: "order", status: "open", authorHandle: me?.userHandle };
225
+ const canOrder = can.create(orderDraft);
226
+ // A line write and the move to received are their own decisions, each checked on the record it writes.
227
+ // The line verdict reads one representative line; access.js holds every line to its buyer the same way.
228
+ const canLine = can.create({ type: "line", orderId: open?._id ?? "order-new", productId: "", qty: 1, authorHandle: me?.userHandle });
229
+ const canPlace = open ? can.edit({ ...open, status: "received" }) : canOrder;
230
+ const keeping = Boolean(me) && !canOrder.pending && canOrder.ok && canLine.ok;
231
+ // A visitor's bag stays in the page until they sign in; then their saved lines join it.
232
+ const [pageBag, setPageBag] = useState({});
233
+ const savedBag = Object.fromEntries(lineDocs.filter((l) => l.type === "line").map((l) => [l.productId, l.qty]));
234
+ const bag = keeping ? { ...pageBag, ...savedBag } : pageBag;
218
235
  const [placing, setPlacing] = useState(false);
236
+ // The id of an order this page has started but the live query has not returned yet, so two
237
+ // quick Adds land on one order instead of opening two.
238
+ const startedOrder = useRef(null);
219
239
 
220
240
  // One currency per bag: the shop sells in CURRENCY, so a record priced in another stays off the shelf.
221
241
  const forSale = products.filter((p) => p.onSale && p.currency === CURRENCY).sort((a, b) => a.createdAt - b.createdAt);
@@ -230,26 +250,39 @@ export default function App() {
230
250
  const count = lines.reduce((n, l) => n + l.qty, 0);
231
251
  const subtotal = lines.reduce((n, l) => n + l.unitAmount * l.qty, 0);
232
252
  const shipping = subtotal === 0 || subtotal >= FREE_SHIPPING ? 0 : SHIPPING;
233
- const mine = me ? orders.filter((o) => o.authorHandle === me.userHandle).sort((a, b) => b.createdAt - a.createdAt) : [];
234
253
 
235
- // The verdict for the order placeOrder writes, carrying the same fields it stamps.
236
- const orderDraft = { type: "order", status: "received", authorHandle: me?.userHandle };
237
- const canOrder = can.create(orderDraft);
254
+ // One line per product, its id derived from the order and the product, so the same product
255
+ // twice is one line with a new quantity; a line at zero stays as a row and drops out of the bag.
256
+ const lineFor = (orderId, productId, qty) => ({ _id: `${orderId}:${productId}`, type: "line", orderId, productId, qty, authorHandle: me.userHandle, updatedAt: Date.now() });
238
257
 
239
- function change(id, delta) {
240
- setBag((b) => {
241
- const qty = Math.min(MAX_QTY, Math.max(0, (b[id] ?? 0) + delta));
242
- const { [id]: _gone, ...rest } = b;
243
- return qty === 0 ? rest : { ...rest, [id]: qty };
244
- });
258
+ async function change(id, delta) {
259
+ const qty = Math.min(MAX_QTY, Math.max(0, (bag[id] ?? 0) + delta));
260
+ if (!keeping) {
261
+ const { [id]: _gone, ...rest } = pageBag;
262
+ return setPageBag(qty === 0 ? rest : { ...rest, [id]: qty });
263
+ }
264
+ // The order is written with its first line, so the bag exists from the first Add.
265
+ const orderId = open?._id ?? startedOrder.current;
266
+ if (orderId) return database.put(lineFor(orderId, id, qty));
267
+ const fresh = "order-" + crypto.randomUUID();
268
+ startedOrder.current = fresh;
269
+ await database.put({ _id: fresh, ...orderDraft, currency: CURRENCY, createdAt: Date.now() });
270
+ await database.put(lineFor(fresh, id, qty));
245
271
  }
246
272
 
247
273
  async function placeOrder() {
248
274
  setPlacing(true);
249
275
  try {
250
- await database.put({ ...orderDraft, lines, currency: CURRENCY, subtotal, shipping, total: subtotal + shipping, createdAt: Date.now() });
251
- // Emptied only once the order lands, so a local failure keeps the bag.
252
- setBag({});
276
+ const orderId = open?._id ?? startedOrder.current ?? "order-" + crypto.randomUUID();
277
+ const order = open ?? { _id: orderId, ...orderDraft, currency: CURRENCY, createdAt: Date.now() };
278
+ // Each line keeps the title and unit price it was bought at, so a later price change never
279
+ // rewrites a placed order; the order keeps a snapshot of the totals beside its lines.
280
+ for (const l of lines) await database.put({ ...lineFor(orderId, l.productId, l.qty), title: l.title, unitAmount: l.unitAmount });
281
+ // A saved line whose product went off sale is not in this order: it goes to zero with it.
282
+ for (const l of lineDocs) if (l.type === "line" && l.qty > 0 && !lines.some((x) => x.productId === l.productId)) await database.put({ ...l, qty: 0, updatedAt: Date.now() });
283
+ await database.put({ ...order, status: "received", subtotal, shipping, total: subtotal + shipping, itemCount: count, placedAt: Date.now() });
284
+ setPageBag({});
285
+ startedOrder.current = null;
253
286
  toast.success("Order placed. We'll be in touch about collection.");
254
287
  } finally {
255
288
  setPlacing(false);
@@ -257,7 +290,7 @@ export default function App() {
257
290
  }
258
291
 
259
292
  let checkout;
260
- if (canOrder.pending)
293
+ if (canPlace.pending)
261
294
  checkout = (
262
295
  <div aria-busy="true">
263
296
  <Skeleton variant="row" />
@@ -269,7 +302,7 @@ export default function App() {
269
302
  Sign in to place your order
270
303
  </Button>
271
304
  );
272
- else if (!canOrder.ok) checkout = <Text muted>The shop isn't taking orders right now. Check back soon.</Text>;
305
+ else if (!canPlace.ok) checkout = <Text muted>The shop isn't taking orders right now. Check back soon.</Text>;
273
306
  else
274
307
  checkout = (
275
308
  <Button block disabled={count === 0} loading={placing} onClick={placeOrder}>
@@ -429,16 +462,16 @@ export default function App() {
429
462
  </Stack>
430
463
  </Card>
431
464
 
432
- {mine.length > 0 && (
465
+ {placed.length > 0 && (
433
466
  <Card variant="tight">
434
467
  <Stack gap={3}>
435
468
  <Heading level={3}>Your orders</Heading>
436
- {mine.map((o) => (
469
+ {placed.map((o) => (
437
470
  <Row key={o._id} justify="between" wrap={false}>
438
471
  <Stack gap={1}>
439
472
  <Text num>{money(o.total, o.currency ?? CURRENCY)}</Text>
440
473
  <Text size="sm" muted>
441
- {new Date(o.createdAt).toLocaleDateString()} · {plural(o.lines.reduce((n, l) => n + l.qty, 0), "item", "items")}
474
+ {new Date(o.placedAt ?? o.createdAt).toLocaleDateString()} · {plural(o.itemCount ?? 0, "item", "items")}
442
475
  </Text>
443
476
  </Stack>
444
477
  <Badge tone={ORDER_STATUS[o.status]?.tone ?? "info"}>{ORDER_STATUS[o.status]?.label ?? "Received"}</Badge>
@@ -465,8 +498,8 @@ export default function App() {
465
498
 
466
499
  - The catalogue is records, so a shop with three things and a shop with forty are the same code. It ships empty: example products for a first look go in the app's seed data, which the owner clears, and the owner adds the real ones on **Products**. Swap `CATEGORIES`, `BADGES`, the shipping rule and `CURRENCY` for the shop's own.
467
500
  - Product records belong to the owner: `access.js` takes a `product` only from the owner (`ctx.requireRole("owner")`), with an `amount` that is a positive whole number, a three-letter lowercase `currency` and an `onSale` true or false, and puts it on a channel every visitor reads. Keep the `orders` database and the field names `title`, `amount`, `currency` and `onSale`: they are the `stripe` skill's, so its checkout reads these records and prices this bag unchanged.
468
- - Keep the order a snapshot of titles, unit prices and quantities: an order is a record of what was agreed, so a later price change must not touch it.
469
- - Orders hold who bought what, so `access.js` and the app's sharing should keep each order between its buyer and the shop: a buyer creates and reads their own, the shop reads them all and moves each through `ORDER_STATUS` behind `can.edit(order)`.
501
+ - Keep each line a snapshot of its title, unit price and quantity once placed, and the order a snapshot of its totals: an order is a record of what was agreed, so a later price change must not touch it. Lines are their own documents keyed by `orderId`, never an array on the order, so the shop can count a product across orders, a buyer's agent can fill the same bag, and one line can change without rewriting the rest.
502
+ - Orders hold who bought what, so `access.js` and the app's sharing should keep each order between its buyer and the shop: a buyer creates and reads their own orders and lines (a `line` routes with the order its `orderId` names), the shop reads them all and moves each through `ORDER_STATUS` behind `can.edit(order)`.
470
503
  - Card payment is the `stripe` skill, and it comes in when the person asks to take money: its checkout replaces `Place order` with one `pay(...)` that sends each product and its quantity, `backend.js` prices every line from these records, and the order becomes the one `/checkout` writes. Anyone pays: the `Sign in to place your order` lead goes away with `Place order`, and a guest's bag stays on the page until they pay. Until then, keep the pay-when-you-collect line truthful, and offer `▸ [pay] Take card payments with Stripe` as the capability option.
471
504
  - A new write surface gets its own verdict: `can.create(draft)` with the fields the write stamps, `can.edit(doc)` or `can.delete(doc)` on the document it changes, always on `useVibe` of the database it writes.
472
505
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/prompts",
3
- "version": "14.3.287",
3
+ "version": "14.3.289",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "exports": {
@@ -39,10 +39,10 @@
39
39
  "license": "Apache-2.0",
40
40
  "dependencies": {
41
41
  "@adviser/cement": "~0.5.34",
42
- "@vibes.diy/api-types": "14.3.287",
43
- "@vibes.diy/call-ai-v2": "14.3.287",
44
- "@vibes.diy/identity": "14.3.287",
45
- "@vibes.diy/use-vibes-types": "14.3.287",
42
+ "@vibes.diy/api-types": "14.3.289",
43
+ "@vibes.diy/call-ai-v2": "14.3.289",
44
+ "@vibes.diy/identity": "14.3.289",
45
+ "@vibes.diy/use-vibes-types": "14.3.289",
46
46
  "arktype": "~2.2.9",
47
47
  "json-schema-faker": "~0.6.3"
48
48
  },