@homie-rocks/studio 0.27.0 → 0.29.0
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.
- package/CHANGELOG.md +59 -1
- package/README.md +40 -2
- package/bin/homie-studio.mjs +24 -0
- package/chat/CHAT.md +5 -1
- package/chat/LOUNGE.md +114 -0
- package/chat/OWNERS.md +6 -2
- package/lib/build.mjs +5 -0
- package/lib/feedback.mjs +181 -0
- package/lib/lounge-cli.mjs +70 -0
- package/lib/mcp-tools.mjs +140 -1
- package/lib/mcp.mjs +6 -2
- package/lib/redact.mjs +99 -0
- package/lib/scaffold.mjs +25 -2
- package/lib/template-history.json +80 -0
- package/mcp/ui/card.css +8 -0
- package/mcp/ui/feedback.js +112 -0
- package/mcp/ui/setup.js +2 -0
- package/netplay/NETPLAY.md +11 -1
- package/package.json +1 -1
- package/site/SITE.md +13 -0
- package/worker/chat-store.mjs +2 -1
- package/worker/chat.mjs +13 -1
- package/worker/discover.mjs +5 -0
- package/worker/index.mjs +38 -3
- package/worker/lounge-page.mjs +623 -0
- package/worker/lounge-store.mjs +281 -0
- package/worker/lounge.mjs +547 -0
- package/worker/office-page.mjs +99 -0
- package/worker/office.mjs +19 -1
- package/worker/players.mjs +5 -0
- package/worker/room.mjs +116 -12
- package/worker/site.mjs +6 -1
- package/worker/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,9 +17,67 @@ To bring a studio up to date, tell Claude: "Upgrade my studio to the newest Homi
|
|
|
17
17
|
`npx -y @homie-rocks/studio@latest upgrade`, which shows what's new since the version your studio pins (from this
|
|
18
18
|
file) and what the upgrade would change, and changes nothing until you agree.
|
|
19
19
|
|
|
20
|
+
## [0.29.0] - 2026-10-03
|
|
21
|
+
|
|
22
|
+
**Plugin 0.30.0** · [#44](https://github.com/homie-rocks/homie/pull/44)
|
|
23
|
+
|
|
24
|
+
The Lounge: a community room on your own studio, with play nights, moderators, live rooms and "show what you made" cards, and chat history you can turn on.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- The Lounge. `"lounge": true` in studio.json gives your studio a community room at `/lounge/`, in your studio's own look: one column of talk on a phone with "What's on" a tap away, the talk beside a sidebar on a computer. It is room chat in a room of its own, on your own Cloudflare: reactions and quick lines for anyone, typing for players signed in with a passkey (Sign in and Make a passkey are on the page itself), and every typed line through the word list and your Workers AI review (Clef) before anyone sees it. Slow mode is 3 s to start with. `chat/LOUNGE.md` has the whole of it.
|
|
29
|
+
- Play nights. Set them in the office (a name, a time in your own zone, how long, a game) or with `homie-studio lounge night "<title>" --at <time>`. Everyone sees the time in their own zone, a countdown, "On now", the game's Play, and Add to calendar (a small `.ics` the browser makes).
|
|
30
|
+
- Live rooms in the Lounge, each with Watch and Join: your studio's own, and with a directory the busiest across it (`"featured": "studio"` keeps it to yours, `"none"` shows none).
|
|
31
|
+
- Show what you made. A signed-in person pastes a link to a game and it becomes a card with the game's own title, pitch, picture and a Play button. Only a Homie studio's game can be one (yours, or a site that answers the studio manifest), its words pass the word list and the review like a typed line, and each person posts three an hour. Typed links stay held.
|
|
32
|
+
- Moderators. Name a player account as a moderator from one of their lines in the office (or `homie-studio lounge mod <player id>`): from the Lounge page they take a line down, mute or kick its sender for up to an hour (their lines come down with them) and set slow mode, never on your lines or another moderator's. You have the same from the page, for up to a day, and everything else in the office's new Lounge section: its rules, play nights, moderators, last lines and reports.
|
|
33
|
+
- Chat history you can turn on (`history`, a number of days, 1 to 90). In the office, "Keep what is said" for the Lounge, or `homie-studio lounge history <days>`; for a game, `"chat": { "history": 7 }` or the office. What is kept, in your studio's own D1: typed lines, quick lines, cards and your own studio lines, the name shown, when, and for a signed-in sender their account id. Never a reaction, an address or a browser key. It is deleted after that many days; keeping fewer days (or none) deletes the rest at once. The room gives kept lines back when it opens ("Earlier messages" pages further), a report still finds an older line, and a mute or kick from a kept line holds its sender's account.
|
|
34
|
+
- Anyone takes their own message down: Delete on their own line in the Lounge (a signed-in person's kept lines too, a guest's while it is in the room's last minutes). Deleting an account at `/account/` deletes every line it kept, and the account's download has them.
|
|
35
|
+
- `homie-studio lounge` (rules, play nights, moderators, last lines, reports), `lounge night`, `lounge history`, `lounge rules`, `lounge mod` and `lounge remove`. From your AI's office key, keeping more days, opening chat up, a new moderator, a mute or a kick only ASK (your one tap); a play night, slow mode, taking a line down and keeping less happen at once.
|
|
36
|
+
- `/lounge/api/now`: the Lounge's public facts (its rules, play nights and live rooms) as JSON, and the studio's manifest names its Lounge. homie.rocks can show a Lounge live when its rules allow it (`hub`): a visitor's own browser opens the Lounge's socket, as for a room's card; they react there and type on your site. The sitemap and llms.txt list the Lounge's page; robots.txt keeps its socket and APIs out.
|
|
37
|
+
- "Get Homie updates" on the setup card (Claude, Claude Desktop and the Claude Code mod): a link to homie.rocks's own sign-up for a short email when Homie ships something. The person signs up there themselves (double opt-in); the card never asks for an address.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Room chat's rules have one more field, `history`. It is 0 for every game and for the Lounge until an owner turns it on, and always 0 on a kids server, a beginner server and a kids Lounge, so nothing changes for a studio that does nothing: a room still keeps the last 50 lines of the last 15 minutes in memory and nothing else.
|
|
42
|
+
- A line on the wire may carry `card`, `mod`, `kept` and, on a page's own copy, `mine`; a page that knows none of them shows the line's words. A watching page may send `unsay` for its own line. The room's facts count watching pages (`counts.shells`). The relay stays revision 8.
|
|
43
|
+
|
|
44
|
+
### Upgrade notes
|
|
45
|
+
|
|
46
|
+
- `homie-studio upgrade` adds migration `0009_studio_lounge.sql` (kept chat, play nights, moderators; all empty until you use them) and `npm run deploy` applies it. Nothing else changes until you add `"lounge": true` to studio.json and deploy. A game already called `lounge` keeps its page, and the build says the Lounge is off.
|
|
47
|
+
- Before you turn history on, read `chat/OWNERS.md`: it says what is kept and what that means for children's data. The Lounge's page tells people what is kept, in its "How it works".
|
|
48
|
+
|
|
49
|
+
## [0.28.0] - 2026-10-03
|
|
50
|
+
|
|
51
|
+
**Plugin 0.29.0** · [#43](https://github.com/homie-rocks/homie/pull/43) · [release-2026-10-03-studio-0.28.0](https://github.com/homie-rocks/homie/releases/tag/release-2026-10-03-studio-0.28.0)
|
|
52
|
+
|
|
53
|
+
Tell Homie: when something confuses you or gets in your way, Claude can offer to send the people who make Homie a short note about it. You see the note word for word first, and nothing is sent without your yes.
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
|
|
57
|
+
- `homie_feedback`, a new tool on both Homie MCP servers (the remote one at homie.rocks, and the local `homie-studio mcp` in Homie for Claude Desktop), with the same name and inputs on each:
|
|
58
|
+
- `draft` (the default) sends nothing. It answers with the note exactly as it would go: its kind (stuck, confusing, idea, praise or bug), the words, and what goes with them (the step or skill, the studio's and the plugin's versions, the app, and whether Claude offered it or you asked). Keys, tokens, private links, code, home folders, email addresses, network addresses and your Cloudflare account's name are taken out first, and the note says what was taken out.
|
|
59
|
+
- `send` sends only the note you were shown. It names the draft, and a note whose words or details changed since then is refused.
|
|
60
|
+
- `decline` records your no.
|
|
61
|
+
- A note goes only to homie.rocks: a studio.json can name Homie's own directory or this computer, nothing else.
|
|
62
|
+
- A Tell Homie card in Claude Desktop and Claude on the web or a phone: the note as it would go, with **Send**, **Edit** (your own words, your kind, an optional reply address) and **Don't send**.
|
|
63
|
+
- In Claude Code, the Homie mod:
|
|
64
|
+
- `/feedback <your words>` shows your note in a Tell Homie pane with Send and Don't send. `/feedback` alone opens the pane to write one, or puts an ask for Claude to draft one in your prompt box. The Studio pane has a **Tell Homie** button (`t`).
|
|
65
|
+
- Every send from Claude waits for **Send** in Claude Code's own question, with the note's exact words. Once you have sent or declined a note in a session, Claude cannot offer another.
|
|
66
|
+
- A note is drawn in the transcript as a framed note.
|
|
67
|
+
- In Codex, Homie's hooks hold every send until your own `proceed <code>`, with the note's exact words in the hold.
|
|
68
|
+
- Skills and the studio's `AGENTS.md` (a new "Telling Homie" section) tell Claude when to offer: after an error it could not fix, when you sound confused or frustrated, and at the end of your first studio setup or first publish. It offers at most once a session, never makes help wait on it, and takes no for an answer.
|
|
69
|
+
|
|
70
|
+
### Changed
|
|
71
|
+
|
|
72
|
+
- The studio-setup and publish skills, the plugin's README and both MCP servers' instructions describe Tell Homie.
|
|
73
|
+
|
|
74
|
+
### Upgrade notes
|
|
75
|
+
|
|
76
|
+
- Nothing to do. `homie-studio upgrade` adds the "Telling Homie" section to the studio's `AGENTS.md`. The tool is on the Homie MCP for every app; in Claude Code, update the plugin for `/feedback` and the send hold. Notes are private; homie.rocks/privacy says what is kept.
|
|
77
|
+
|
|
20
78
|
## [0.27.0] - 2026-10-03
|
|
21
79
|
|
|
22
|
-
**Plugin 0.28.0** · [#42](https://github.com/homie-rocks/homie/pull/42)
|
|
80
|
+
**Plugin 0.28.0** · [#42](https://github.com/homie-rocks/homie/pull/42) · [release-2026-10-03-studio-0.27.0](https://github.com/homie-rocks/homie/releases/tag/release-2026-10-03-studio-0.27.0)
|
|
23
81
|
|
|
24
82
|
Search engines and AI agents read a studio's site correctly: schema.org data on every page, a full VideoGame on every landing, and a sitemap, robots.txt and llms.txt made from what is public.
|
|
25
83
|
|
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ npx homie-studio stats # the studio's own number
|
|
|
27
27
|
npx homie-studio office # who is playing now, in every live room (the back office)
|
|
28
28
|
npx homie-studio servers # each game's servers: humans-only, hybrid AI seats, beginner guides
|
|
29
29
|
npx homie-studio chat # room chat: each game's rules, the rooms' last minutes, reports
|
|
30
|
+
npx homie-studio lounge # the studio's Lounge: play nights, moderators, kept chat
|
|
30
31
|
npx homie-studio upgrade # what a newer template adds to this studio (--apply to take it)
|
|
31
32
|
```
|
|
32
33
|
|
|
@@ -49,6 +50,14 @@ feed; MCP Apps cards (setup, build progress, studio, codex) are served as `ui://
|
|
|
49
50
|
answers in plain text. Homie for Claude Desktop (`desktop/` in this repository) is this server as a Desktop
|
|
50
51
|
Extension: the plain Claude app gets it with one install, and no terminal.
|
|
51
52
|
|
|
53
|
+
**Tell Homie** (0.28.0): `homie_feedback` drafts a short note to the people who make Homie (stuck, confusing, idea,
|
|
54
|
+
praise or bug) from what happened, and sends it only after the person has seen it word for word and said yes: its
|
|
55
|
+
card (`ui://homie-studio/feedback`) has Send, Edit and Don't send, and a send must name the draft the person saw,
|
|
56
|
+
with the same words. Keys, home folders, email addresses, code and a workers.dev account name are taken out before
|
|
57
|
+
it is shown (`lib/feedback.mjs`, with the Homie mod's own redaction). Claude offers one at most once a session, and a
|
|
58
|
+
no is final for it. It goes to homie.rocks (`/api/feedback/tell`): a studio.json can name only Homie's own directory or
|
|
59
|
+
this computer, so a borrowed studio cannot send notes elsewhere.
|
|
60
|
+
|
|
52
61
|
## From a phone: a one-line hand-off
|
|
53
62
|
|
|
54
63
|
The Claude app on a phone hands a build to a Claude Code cloud session with one line, `Continue building <Studio>:
|
|
@@ -345,10 +354,38 @@ npx homie-studio chat words # the bu
|
|
|
345
354
|
lines taken down), the same in the owner's own game, the reports players make, and Announce (a studio line).
|
|
346
355
|
- **Speech bubbles:** `net.on('say')` and the port kit's `createBubbles` / `paintBubbles`; Gem Rush, Ember Vale and
|
|
347
356
|
Gem Rush 3D draw them over the speaker.
|
|
348
|
-
- **Nothing is stored** but a report (the one message, 30 days): the room keeps 15 minutes in memory.
|
|
357
|
+
- **Nothing is stored** but a report (the one message, 30 days): the room keeps 15 minutes in memory. An owner may
|
|
358
|
+
turn a room's `history` on (0.29.0, a number of days; off for every game, never on a kids server): then what was
|
|
359
|
+
said (never a reaction) is kept in the studio's own D1 for that long, and people take their own lines down.
|
|
349
360
|
[chat/CHAT.md](chat/CHAT.md) is the short version and why Clef; [chat/OWNERS.md](chat/OWNERS.md) a plain note for
|
|
350
361
|
studio owners on chat and children's data; NETPLAY.md section 19 the wire.
|
|
351
362
|
|
|
363
|
+
## The Lounge: a room for the studio's community
|
|
364
|
+
|
|
365
|
+
`"lounge": true` in studio.json gives the studio a community room at `/lounge/` (0.29.0): room chat in a lasting room
|
|
366
|
+
of its own, on the studio's own Cloudflare like everything else. Reactions and quick lines for anyone, typing for
|
|
367
|
+
players signed in with a passkey (signing in is on the page), every typed line through the word list and the Clef
|
|
368
|
+
review first.
|
|
369
|
+
|
|
370
|
+
```sh
|
|
371
|
+
npx homie-studio lounge # its rules, play nights, moderators, lines, reports
|
|
372
|
+
npx homie-studio lounge night "Night Rush night" --at 2026-10-09T19:00:00-07:00 --game night-rush
|
|
373
|
+
npx homie-studio lounge history 14 # keep what is said for 14 days (asked: the owner confirms)
|
|
374
|
+
npx homie-studio lounge mod <player id> # a moderator (asked)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
- **Play nights** the owner sets in the office: everyone sees the time in their own zone, a countdown and Add to
|
|
378
|
+
calendar. **Live rooms** with Watch and Join: the studio's, and with a directory the busiest across it.
|
|
379
|
+
- **Show what you made:** a signed-in person pastes a link to a Homie studio's game and it becomes a card with the
|
|
380
|
+
game's own title, pitch and picture (read from that studio's manifest; its words pass the word list and the
|
|
381
|
+
review). Typed links stay held.
|
|
382
|
+
- **Keeping it kind:** anyone reports a line or takes their own down; moderators the owner names Remove, Mute and
|
|
383
|
+
Kick (an hour at most) and set slow mode from the page; the owner has all of it and the office. A kids Lounge
|
|
384
|
+
keeps to emoji and quick lines and keeps nothing.
|
|
385
|
+
- **History is off** until the owner turns it on (1 to 90 days), and the page says what is kept.
|
|
386
|
+
- **homie.rocks** can show a Lounge live when its rules allow (`hub`): the visitor's browser opens the Lounge's own
|
|
387
|
+
socket, as for a room's card; they react there and type here. [chat/LOUNGE.md](chat/LOUNGE.md) has the whole of it.
|
|
388
|
+
|
|
352
389
|
## Selling things: the shop
|
|
353
390
|
|
|
354
391
|
A studio sells items for its games (0.24.0; Stripe's own agent tools since 0.24.3) with **its own Stripe account**: the studio is the seller, money goes
|
|
@@ -785,7 +822,8 @@ pinned a tarball at `https://homie.rocks/npm/homie-studio-<version>.tgz`, which
|
|
|
785
822
|
## Beta
|
|
786
823
|
|
|
787
824
|
This is a beta. Bugs, port requests and questions go to
|
|
788
|
-
<https://github.com/homie-rocks/homie/issues/new/choose
|
|
825
|
+
<https://github.com/homie-rocks/homie/issues/new/choose>, or, from inside Claude or Codex, to the people who make
|
|
826
|
+
Homie as a short note you see and send yourself (`homie_feedback`, above).
|
|
789
827
|
|
|
790
828
|
## License
|
|
791
829
|
|
package/bin/homie-studio.mjs
CHANGED
|
@@ -106,6 +106,11 @@
|
|
|
106
106
|
* minutes, players' reports, the review's day; chat rules <game> [--server <id>]
|
|
107
107
|
* --mode off|emoji|lines|text --who anyone|signed-in|members … | --reset;
|
|
108
108
|
* chat remove <game> <room> <line id>; chat budget <neurons>; chat words
|
|
109
|
+
* homie-studio lounge the studio's Lounge (studio.json "lounge", chat/LOUNGE.md): its rules, play
|
|
110
|
+
* nights, moderators, last lines and reports; lounge night "<title>" --at <time>
|
|
111
|
+
* [--minutes 120] [--game <id>]; lounge night remove <id>; lounge history <days>;
|
|
112
|
+
* lounge rules [--slow <s>] [--who …] | --reset; lounge mod <player> [--remove];
|
|
113
|
+
* lounge remove <line id> | --all
|
|
109
114
|
* homie-studio servers [--game <id>] every server of every game (worker/servers.mjs): its policy, door, the AI's
|
|
110
115
|
* level, live rooms and AI, members, and builds that predate servers
|
|
111
116
|
* homie-studio servers new <game> "<Name>" --policy open|humans-only|hybrid|beginner [--ai <n>] [--guides <n>]
|
|
@@ -258,6 +263,7 @@ import { statsKey, statsLink, statsRevoke, statsShare, statsShow } from '../lib/
|
|
|
258
263
|
import { playersOwner, playersShow } from '../lib/players.mjs';
|
|
259
264
|
import { officeAnnounce, officeClose, officeInvite, officeKey, officeKick, officeLaunch, officeLines, officeLink, officeMute, officeRevoke, officeShow } from '../lib/office.mjs';
|
|
260
265
|
import { chatBudget, chatLines, chatRemove, chatRulesSet, chatShow, chatWords } from '../lib/chat-cli.mjs';
|
|
266
|
+
import { loungeLines, loungeMod, loungeNight, loungeRemove, loungeRulesSet, loungeShow } from '../lib/lounge-cli.mjs';
|
|
261
267
|
import { detectLocalAi, localAiVars } from '../lib/local-ai.mjs';
|
|
262
268
|
import { agentsBrain, agentsBrainKey, agentsPass, agentsPasses, agentsRevoke, agentsTry, serversClose, serversLevel, serversLines, serversList, serversMember, serversNew, serversSet } from '../lib/servers.mjs';
|
|
263
269
|
import { AgentSeat } from '../lib/agent-seat.mjs';
|
|
@@ -479,8 +485,13 @@ function print(result) {
|
|
|
479
485
|
lines.push(result.note);
|
|
480
486
|
break;
|
|
481
487
|
case 'chat remove':
|
|
488
|
+
case 'lounge night':
|
|
489
|
+
case 'lounge remove':
|
|
482
490
|
lines.push(result.message);
|
|
483
491
|
break;
|
|
492
|
+
case 'lounge':
|
|
493
|
+
lines.push(...loungeLines(result));
|
|
494
|
+
break;
|
|
484
495
|
case 'shop':
|
|
485
496
|
case 'shop orders':
|
|
486
497
|
case 'shop check':
|
|
@@ -498,6 +509,8 @@ function print(result) {
|
|
|
498
509
|
break;
|
|
499
510
|
case 'chat rules':
|
|
500
511
|
case 'chat budget':
|
|
512
|
+
case 'lounge rules':
|
|
513
|
+
case 'lounge mod':
|
|
501
514
|
case 'shop refund':
|
|
502
515
|
lines.push(result.asked ? `Asked: ${result.what}` : result.message, ...(result.asked ? [`Owner's one-tap link (until the ask ends, 15 min): ${result.link}`, result.use] : []));
|
|
503
516
|
break;
|
|
@@ -791,6 +804,17 @@ async function main() {
|
|
|
791
804
|
if (sub === 'close') return officeClose(root, positional[2], positional[3], { url, minutes: flags.get('minutes'), reopen: flags.has('reopen') });
|
|
792
805
|
if (sub === 'revoke') return officeRevoke(root, { url });
|
|
793
806
|
}
|
|
807
|
+
if (cmd === 'lounge') {
|
|
808
|
+
// The Lounge (0.29.0, chat/LOUNGE.md): its rules and history, play nights, moderators, lines.
|
|
809
|
+
const url = flags.get('url');
|
|
810
|
+
if (!sub) return loungeShow(root, { url });
|
|
811
|
+
if (sub === 'night') return loungeNight(root, positional.slice(2), flags, { url });
|
|
812
|
+
if (sub === 'history') return loungeRulesSet(root, flags, { url, history: positional[2] });
|
|
813
|
+
if (sub === 'rules') return loungeRulesSet(root, flags, { url });
|
|
814
|
+
if (sub === 'mod') return loungeMod(root, positional[2], { url, remove: flags.has('remove') });
|
|
815
|
+
if (sub === 'remove') return loungeRemove(root, positional[2], { url, all: flags.has('all') });
|
|
816
|
+
return { ok: false, command: 'lounge', why: `unknown: lounge ${sub} (night, history, rules, mod, remove)` };
|
|
817
|
+
}
|
|
794
818
|
if (cmd === 'chat') {
|
|
795
819
|
// Room chat (0.23.0, NETPLAY.md section 19): rules, the room's last minutes, reports, the review's budget.
|
|
796
820
|
const url = flags.get('url');
|
package/chat/CHAT.md
CHANGED
|
@@ -48,11 +48,15 @@ studio's owner is responsible for, read [OWNERS.md](OWNERS.md).
|
|
|
48
48
|
| `links`, `swears` | `block` or `allow` (a link is never clickable; slurs, sexual words, threats and contact details are always held) | `block` |
|
|
49
49
|
| `ai` | review typed messages with the studio's own Workers AI | `true` |
|
|
50
50
|
| `bubbles`, `watchers`, `hub` | over the speaker's character; watchers may send; homie.rocks may show it | `true` |
|
|
51
|
+
| `history` | days to keep what is said (typed lines, quick lines, cards; never a reaction) in the studio's own D1, 0 to 90 (0.29.0; never on a kids server) | `0`: nothing past the room's few minutes |
|
|
51
52
|
| `emoji`, `lines` | up to 3 more reactions; up to 12 quick lines (each passes the chat floor at build) | the five; 8 friendly lines |
|
|
52
53
|
| `block`, `allow` | the studio's own words to hold (`word*` inside words) or to let through | none |
|
|
53
54
|
|
|
54
55
|
`"chat": false` turns it off. A kids server, and every beginner server, keeps chat to emoji and
|
|
55
|
-
quick lines whatever the game says.
|
|
56
|
+
quick lines whatever the game says, and keeps nothing.
|
|
57
|
+
|
|
58
|
+
**A room for the studio's community** is the Lounge (0.29.0): room chat at `/lounge/` with play nights, moderators,
|
|
59
|
+
live rooms, "show what you made" cards and history the owner can turn on. Read [LOUNGE.md](LOUNGE.md).
|
|
56
60
|
|
|
57
61
|
**Where it sits on the screen, in game.json `"screen"`**, so a game with a busy HUD keeps typed
|
|
58
62
|
chat without anything covering its clock, its title or its controls. The Chat pill sits in the
|
package/chat/LOUNGE.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# The Lounge
|
|
2
|
+
|
|
3
|
+
A studio's own community room, at `/lounge/` on the studio's site (`@homie-rocks/studio` 0.29.0): play nights,
|
|
4
|
+
demos, "show what you made", and talking with the people who play your games. It runs on your own Cloudflare
|
|
5
|
+
account like everything else in the studio. Nobody else hosts it, reads it or moderates it for you.
|
|
6
|
+
|
|
7
|
+
It is room chat ([CHAT.md](CHAT.md), [NETPLAY.md section 19](../netplay/NETPLAY.md)) in a room of its own: the same
|
|
8
|
+
reactions floating up every screen, quick lines, typing for signed-in players, the same word list and Clef review
|
|
9
|
+
before anyone sees a typed line, and the same owner's tools. On top of that it has what a lasting room needs:
|
|
10
|
+
history (only if you turn it on), moderators, play nights, live rooms to jump into, and cards for games people made.
|
|
11
|
+
|
|
12
|
+
## Turn it on
|
|
13
|
+
|
|
14
|
+
In `studio.json`:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
"lounge": true
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
or, to say more:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
"lounge": {
|
|
24
|
+
"name": "The Lounge",
|
|
25
|
+
"blurb": "Play nights, demos and what everybody is making. Come and say hi.",
|
|
26
|
+
"featured": "directory",
|
|
27
|
+
"kids": false,
|
|
28
|
+
"chat": { "slow": 5 }
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Field | | Default |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `name`, `tab` | the page's title, and the word in the site's top line | "The Lounge", "Lounge" |
|
|
35
|
+
| `blurb` | one line under the title | the line above |
|
|
36
|
+
| `featured` | live rooms in the sidebar: `directory` (yours, then the busiest across your directory), `studio` (yours only), `none` | `directory` |
|
|
37
|
+
| `kids` | emoji and quick lines only, nothing kept | `true` for a studio with `"audience": "kids"` |
|
|
38
|
+
| `chat` | the Lounge's chat rules before you change them in the office (the fields of game.json `chat`) | below |
|
|
39
|
+
|
|
40
|
+
Then `npm run build` and `npm run deploy` (it applies migration `0009_studio_lounge.sql`). A game already called
|
|
41
|
+
`lounge` keeps its page, and the build says the Lounge is off.
|
|
42
|
+
|
|
43
|
+
## What it does, with no work
|
|
44
|
+
|
|
45
|
+
- **The talk.** Reactions and quick lines for anyone; typing for players signed in with a passkey (no password, no
|
|
46
|
+
email). Every typed line passes the word list and your Workers AI review first. Slow mode is 3 s by default.
|
|
47
|
+
- **Sign in in place.** "Sign in" and "Make a passkey" are on the Lounge page itself; the account is the same one your
|
|
48
|
+
games and `/account/` use.
|
|
49
|
+
- **Show what you made.** A signed-in person pastes a link to a game. If it is a Homie studio's game (yours, or any
|
|
50
|
+
site answering `/.well-known/homie-studio.json`), it becomes a card with the game's own title, pitch and picture, and
|
|
51
|
+
a Play button. Its words pass the word list and the review like a typed line. Three cards an hour each. Plain links
|
|
52
|
+
are never allowed in typed lines, so a card is the only way a link gets in.
|
|
53
|
+
- **Play nights.** You set them in the office (or with `homie-studio lounge night`). Everyone sees the time in their
|
|
54
|
+
own zone, a countdown, "On now", the game's link, and Add to calendar (a small `.ics` the browser makes; nothing
|
|
55
|
+
else is contacted).
|
|
56
|
+
- **Live now.** Your live rooms, and with a directory the busiest rooms across it, each with Watch and Join.
|
|
57
|
+
- **On a phone** it is one column of talk with "What's on" a tap away; on a computer, the talk and a sidebar.
|
|
58
|
+
- **On homie.rocks** (when your rules let it, `hub`), a visitor's own browser opens the Lounge's socket and shows it
|
|
59
|
+
live, like a room's card there. Those visitors react and send quick lines; typing stays on your site, where they can
|
|
60
|
+
sign in. homie.rocks keeps none of it.
|
|
61
|
+
|
|
62
|
+
## Keeping it kind
|
|
63
|
+
|
|
64
|
+
| Who | Can |
|
|
65
|
+
|---|---|
|
|
66
|
+
| Anyone | react, send quick lines, report a line (the studio sees the line and the reason, never who reported it), take their own line down |
|
|
67
|
+
| Signed in | type, show what they made, take down their own lines, kept ones too |
|
|
68
|
+
| A moderator | take any line down, mute or kick its sender for up to an hour (their lines come down with them), set slow mode; never on your lines or another moderator's |
|
|
69
|
+
| You, the owner | all of that, holds of up to a day, every rule, history, play nights, moderators, from the Lounge itself or the office |
|
|
70
|
+
|
|
71
|
+
Make someone a moderator from one of their lines in the office ("Make moderator"), or with
|
|
72
|
+
`homie-studio lounge mod <player id>`. A moderator needs an account with a passkey.
|
|
73
|
+
|
|
74
|
+
**Kids.** A kids Lounge keeps chat to emoji and quick lines and keeps nothing, whatever else it says. Nobody in the
|
|
75
|
+
Lounge is ever asked their age, where they live or for photos; the page says so, and the review holds it.
|
|
76
|
+
|
|
77
|
+
## History: what is kept, and only if you say so
|
|
78
|
+
|
|
79
|
+
By default the Lounge keeps what a room keeps: the last 50 lines of the last few minutes, in memory, and nothing
|
|
80
|
+
else. You can choose to keep what is said for 1 to 90 days (the office, or `homie-studio lounge history <days>`).
|
|
81
|
+
Then, in your D1 (`chat_history`):
|
|
82
|
+
|
|
83
|
+
- typed lines, quick lines, cards and your own studio lines; **never a reaction, an address or a browser key**;
|
|
84
|
+
- the name shown, when, and for a signed-in sender their account id (so they can take their lines down, and deleting
|
|
85
|
+
their account deletes them);
|
|
86
|
+
- deleted after that many days. Keeping fewer days (or none) deletes the rest at once.
|
|
87
|
+
|
|
88
|
+
A person sees what is kept on the page ("What's said is kept for 14 days"), takes their own lines down any time,
|
|
89
|
+
downloads theirs with everything else at `/account/`, and deletes them with their account. Reports stay as before:
|
|
90
|
+
one line, 30 days.
|
|
91
|
+
|
|
92
|
+
History is a room chat rule (`history`, in days), so a game can keep its chat too, but it is **off for every game**
|
|
93
|
+
and stays off unless you turn it on in the office for that game. Turning it on is the owner's one tap when your AI
|
|
94
|
+
asks for it.
|
|
95
|
+
|
|
96
|
+
## From the studio folder
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
npx --no-install homie-studio lounge # rules, play nights, moderators, last lines, reports
|
|
100
|
+
npx --no-install homie-studio lounge night "Night Rush night" --at 2026-10-09T19:00:00-07:00 --minutes 120 --game night-rush
|
|
101
|
+
npx --no-install homie-studio lounge night remove pn_0123456789ab
|
|
102
|
+
npx --no-install homie-studio lounge history 14 # asked: the owner confirms with one tap
|
|
103
|
+
npx --no-install homie-studio lounge rules --slow 10
|
|
104
|
+
npx --no-install homie-studio lounge mod pl_… [--remove] # asked
|
|
105
|
+
npx --no-install homie-studio lounge remove <line id>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The Lounge's public facts are at `/lounge/api/now` (its rules, play nights and live rooms; homie.rocks reads it).
|
|
109
|
+
|
|
110
|
+
## What it costs
|
|
111
|
+
|
|
112
|
+
A line or a reaction is one message on the Lounge's room (Durable Objects, billed 20:1); the fan-out is free. Typed
|
|
113
|
+
lines and cards use the review's daily budget, shared with your rooms (2,000 neurons a day by default, inside
|
|
114
|
+
Workers AI's free 10,000). History is a few D1 rows a line.
|
package/chat/OWNERS.md
CHANGED
|
@@ -41,7 +41,9 @@ What that means in practice:
|
|
|
41
41
|
|
|
42
42
|
| What | Where | How long |
|
|
43
43
|
|---|---|---|
|
|
44
|
-
| The chat itself (every message and reaction) | Only in the room's memory, on your Cloudflare account | The last 50 messages of the last 15 minutes, for someone who just opened the room. **Never written to storage
|
|
44
|
+
| The chat itself (every message and reaction) | Only in the room's memory, on your Cloudflare account | The last 50 messages of the last 15 minutes, for someone who just opened the room. **Never written to storage** unless you turn history on (below). An empty room forgets them a minute after the last person leaves. |
|
|
45
|
+
| **Kept chat**, only where you turn `history` on (off for every game and for the Lounge until you choose; never on a kids server) | Your D1 (`chat_history`) | Typed lines, quick lines, cards and your own lines (never a reaction, an address or a browser key): the words, the name shown, when, and for a signed-in sender their account id. For the number of days you chose (1 to 90), then deleted; choosing fewer days deletes the rest at once. A person takes their own lines down, downloads them at `/account/`, and deleting their account deletes them. |
|
|
46
|
+
| The Lounge's play nights and moderators | Your D1 (`lounge_nights`, `lounge_mods`) | A night until a day after it ends; a moderator (their account id) until you remove them. |
|
|
45
47
|
| Who said what | The same memory, for your office's Mute and Kick | As long as the message is in that memory. Never an IP address. |
|
|
46
48
|
| A **report** | Your D1 (`chat_reports`) | The one message reported (its words, its sender's name and account id if they had one, the room, when, the reason picked), for **30 days** or until you dismiss it. Never who reported it. |
|
|
47
49
|
| Your chat rules and your words | Your D1 (`chat_rules`) | Until you change them. |
|
|
@@ -63,7 +65,9 @@ or that are directed at children. A typed message can contain personal informati
|
|
|
63
65
|
child types anything, and there is nothing personal in your chat to keep or lose.
|
|
64
66
|
- **Typing for signed-in players only** (the default) means a person behind each typed line has an
|
|
65
67
|
account you can act on.
|
|
66
|
-
- **Little is stored**, and only briefly (see above). Reports are the exception, kept 30 days
|
|
68
|
+
- **Little is stored**, and only briefly (see above). Reports are the exception, kept 30 days, and kept chat when
|
|
69
|
+
you turn history on (never on a kids server or a kids Lounge). If you keep chat, say so where people talk (the
|
|
70
|
+
Lounge does, on its page) and keep it as short as is useful.
|
|
67
71
|
- **You can delete**: a report with Dismiss, a message with Remove, a player's whole account in
|
|
68
72
|
their own account page (or `players` in the office).
|
|
69
73
|
|
package/lib/build.mjs
CHANGED
|
@@ -53,6 +53,7 @@ import { screenChatProblems } from '../worker/chat-page.mjs';
|
|
|
53
53
|
import { vocabularyOf } from '../worker/brain.mjs';
|
|
54
54
|
import { shopForBuild } from './shop.mjs';
|
|
55
55
|
import { audienceOf } from '../worker/shop-rules.mjs';
|
|
56
|
+
import { loungeConfig, loungeProblems } from '../worker/lounge-store.mjs';
|
|
56
57
|
|
|
57
58
|
const SOURCE_SKIP = new Set(['node_modules', 'dist', '.git', '.wrangler', '.port']);
|
|
58
59
|
/** Never copied into a static game's served folder. */
|
|
@@ -456,6 +457,9 @@ export async function build(root, { only = null, log = () => {}, deploy = proces
|
|
|
456
457
|
writeFileSync(join(dist, '_site', 'posts.json'), `${JSON.stringify({ v: 1, posts })}\n`);
|
|
457
458
|
const s = studio.site && typeof studio.site === 'object' ? studio.site : {};
|
|
458
459
|
const studioExtras = schemaExtras(s.schema, { where: 'studio.json site', types: 'Organization', log });
|
|
460
|
+
// The Lounge (0.29.0): studio.json "lounge", checked; off when a game already has /lounge/.
|
|
461
|
+
for (const p of loungeProblems(studio, rows, chatProblems)) log(`warning: studio.json: ${p}`);
|
|
462
|
+
const lounge = loungeConfig(studio, rows, { audience: audienceOf(studio) });
|
|
459
463
|
const catalogue = {
|
|
460
464
|
studio: {
|
|
461
465
|
name: studio.name, slug: studio.slug, version: STUDIO_VERSION,
|
|
@@ -481,6 +485,7 @@ export async function build(root, { only = null, log = () => {}, deploy = proces
|
|
|
481
485
|
// (this studio takes no referral statements as a referrer).
|
|
482
486
|
...(audienceOf(studio) !== 'general' ? { audience: audienceOf(studio) } : {}),
|
|
483
487
|
...(studio.referrals === false ? { referrals: false } : {}),
|
|
488
|
+
...(lounge ? { lounge } : {}),
|
|
484
489
|
build: buildInfo(root),
|
|
485
490
|
},
|
|
486
491
|
games: rows,
|
package/lib/feedback.mjs
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TELL HOMIE (0.28.0): a short note from a creator to the people who make Homie, drafted by Claude in plain words,
|
|
3
|
+
* shown to the person exactly as it would go, and sent ONLY after they say yes. One module for every road a note
|
|
4
|
+
* takes from this side: the local MCP's `homie_feedback` (lib/mcp-tools.mjs), its card (mcp/ui/feedback.js), and
|
|
5
|
+
* the rules the Homie mod and the remote Homie MCP keep the same (homie.rocks has its own copy of these rules and
|
|
6
|
+
* applies them again when a note arrives).
|
|
7
|
+
*
|
|
8
|
+
* What a note is, and nothing more: its kind (stuck, confusing, idea, praise, bug), the words, the step or skill it
|
|
9
|
+
* is about, the studio and plugin versions, which app it came from, whether Claude offered it or the person asked,
|
|
10
|
+
* and a reply address only when the person typed one. No file, no log, no code, no key, no studio name, no path.
|
|
11
|
+
*
|
|
12
|
+
* Before anything is shown, the words go through the mod's own redaction (lib/redact.mjs, the same rules the mod
|
|
13
|
+
* uses on tool output: keys, tokens, private keys, owner links) and then a note's own: fenced code, home folders
|
|
14
|
+
* (a user's home becomes ~), email addresses, a workers.dev address's account name, network addresses and long
|
|
15
|
+
* opaque strings. What was taken out is listed with the draft, so the person sees it too.
|
|
16
|
+
*
|
|
17
|
+
* THE DRAFT IS THE NOTE. A draft's id is a hash of everything that would be sent; a send carries the id and the same
|
|
18
|
+
* fields, and a send whose fields do not hash to its id is refused. So what goes out is exactly what was shown.
|
|
19
|
+
*/
|
|
20
|
+
import { redactText } from './redact.mjs';
|
|
21
|
+
|
|
22
|
+
export const FEEDBACK_KINDS = Object.freeze(['stuck', 'confusing', 'idea', 'praise', 'bug']);
|
|
23
|
+
export const FEEDBACK_APPS = Object.freeze(['claude-code', 'codex', 'claude-desktop', 'claude-ai', 'other']);
|
|
24
|
+
export const FEEDBACK_LIMITS = Object.freeze({ text: 1500, raw: 6000, lines: 30, step: 80, email: 254, version: 32, perSession: 5, offers: 3 });
|
|
25
|
+
export const KIND_LABEL = Object.freeze({ stuck: 'Stuck', confusing: 'Confusing', idea: 'Idea', praise: 'Praise', bug: 'Bug' });
|
|
26
|
+
export const APP_LABEL = Object.freeze({ 'claude-code': 'Claude Code', codex: 'Codex', 'claude-desktop': 'the Claude desktop app', 'claude-ai': 'Claude on the web or a phone', other: 'another app' });
|
|
27
|
+
|
|
28
|
+
/** Where a note goes on a Homie directory (homie.rocks, or a local one for tests). */
|
|
29
|
+
export const feedbackUrl = (directory = 'https://homie.rocks') => `${String(directory || 'https://homie.rocks').replace(/\/+$/, '')}/api/feedback/tell`;
|
|
30
|
+
|
|
31
|
+
const EMAIL = /^[^\s@]{1,64}@[^\s@]{1,255}\.[^\s@]{2,63}$/;
|
|
32
|
+
const VERSION = /^[0-9A-Za-z][0-9A-Za-z.+-]{0,31}$/;
|
|
33
|
+
const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u2028\u2029\u200b-\u200f\u202a-\u202e\u2060-\u206f\ufeff]/g;
|
|
34
|
+
const HIDDEN = (what) => `[${what} hidden by Homie]`;
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* A note's own rules, after the mod's. Each: what it is (said to the person), the pattern, and its replacement.
|
|
38
|
+
* Order matters: code first (whatever is inside a fence goes whole), then links and addresses.
|
|
39
|
+
*/
|
|
40
|
+
const NOTE_RULES = [
|
|
41
|
+
{ kind: 'code', re: /```[\s\S]*?(?:```|$)/g, to: () => '[code left out by Homie]' },
|
|
42
|
+
// A workers.dev address names the Cloudflare account, often after its owner: the account part goes.
|
|
43
|
+
// (Labels are bounded, as DNS bounds them: an unbounded one makes this rule quadratic on a long run of hyphens.)
|
|
44
|
+
{ kind: 'a workers.dev account name', re: /\b([a-z0-9-]{1,63}\.)?([a-z0-9-]{1,63})(\.workers\.dev)\b/gi, to: (m, sub, account, tail) => `${sub ?? ''}[account]${tail}` },
|
|
45
|
+
{ kind: 'a home folder', re: /(?:\/Users\/|\/home\/)([^/\s"'`]+)/g, to: () => '~' },
|
|
46
|
+
{ kind: 'a home folder', re: /\b[A-Za-z]:\\Users\\([^\\\s"'`]+)/g, to: () => '~' },
|
|
47
|
+
{ kind: 'an email address', re: /\b[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,253}\.[A-Za-z]{2,63}\b/g, to: () => HIDDEN('an email address') },
|
|
48
|
+
// A network address that is not this computer's own.
|
|
49
|
+
{ kind: 'a network address', re: /\b(?!127\.0\.0\.1\b)(?!0\.0\.0\.0\b)(?:25[0-5]|2[0-4]\d|1?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}\b/g, to: () => HIDDEN('a network address') },
|
|
50
|
+
// A signed token (three dotted parts, the first two JSON in base64): whole, before the rule below takes one part.
|
|
51
|
+
{ kind: 'a token', re: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g, to: () => HIDDEN('a token') },
|
|
52
|
+
// Anything long and opaque that a rule above did not name (a token of a kind nobody listed, a hash, a blob), after
|
|
53
|
+
// a dot too.
|
|
54
|
+
{ kind: 'a long code', re: /(?<![A-Za-z0-9_\-+/=])(?=[A-Za-z0-9_\-+/=]*[0-9])(?=[A-Za-z0-9_\-+/=]*[A-Za-z])[A-Za-z0-9_\-+/=]{32,}(?![A-Za-z0-9_\-+/=])/g, to: () => HIDDEN('a long code') },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
/** The words of a note as they may go: redacted, plain, and the list of what was taken out. */
|
|
58
|
+
export function redactNote(value) {
|
|
59
|
+
let text = String(value ?? '').replace(/\r\n?/g, '\n').replace(CONTROL, '');
|
|
60
|
+
const taken = [];
|
|
61
|
+
for (const rule of NOTE_RULES.slice(0, 1)) text = applyRule(text, rule, taken);
|
|
62
|
+
const r = redactText(text);
|
|
63
|
+
if (r.hits.length) {
|
|
64
|
+
taken.push(...r.hits.map((h) => (h === 'owner link' ? 'a private link' : `a ${h}`.replace(/^a ([aeiou])/i, 'an $1'))));
|
|
65
|
+
// The mod's words for a link it showed in its pane are not true of a note: here the link is simply gone.
|
|
66
|
+
text = r.text.split('[one-time owner link: the Homie mod showed it to the person in its Studio pane; Claude never sees it]').join(HIDDEN('a private link'));
|
|
67
|
+
}
|
|
68
|
+
for (const rule of NOTE_RULES.slice(1)) text = applyRule(text, rule, taken);
|
|
69
|
+
text = text.replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
70
|
+
return { text, taken: [...new Set(taken)] };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function applyRule(text, rule, taken) {
|
|
74
|
+
rule.re.lastIndex = 0;
|
|
75
|
+
return text.replace(rule.re, (...m) => {
|
|
76
|
+
const out = rule.to(...m);
|
|
77
|
+
if (out !== m[0]) taken.push(rule.kind);
|
|
78
|
+
return out;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const oneLine = (value, max) => String(value ?? '').replace(CONTROL, ' ').replace(/\s+/g, ' ').trim().slice(0, max);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A note as it may be shown and sent, or why not: { ok: true, note, taken } | { ok: false, why }.
|
|
86
|
+
* `input`: { kind, text, step?, studioVersion?, pluginVersion?, app?, email?, offered? }.
|
|
87
|
+
*/
|
|
88
|
+
export function cleanNote(input = {}) {
|
|
89
|
+
const kind = String(input.kind ?? '').trim().toLowerCase();
|
|
90
|
+
if (!FEEDBACK_KINDS.includes(kind)) return { ok: false, why: `kind is one of ${FEEDBACK_KINDS.join(', ')}` };
|
|
91
|
+
const raw = String(input.text ?? '');
|
|
92
|
+
// Before any rule reads it: a note is short, and a rule's cost grows with what it is given.
|
|
93
|
+
if (raw.length > FEEDBACK_LIMITS.raw) return { ok: false, why: `the note is ${raw.length.toLocaleString('en-US')} characters: keep it under ${FEEDBACK_LIMITS.text.toLocaleString('en-US')} (a short note, never a log or a file)` };
|
|
94
|
+
const { text, taken } = redactNote(raw);
|
|
95
|
+
if (!text) return { ok: false, why: 'the note is empty: write what happened in a sentence or two, in plain words' };
|
|
96
|
+
if (text.length > FEEDBACK_LIMITS.text) return { ok: false, why: `the note is ${text.length} characters: keep it under ${FEEDBACK_LIMITS.text.toLocaleString('en-US')} (a short note, never a log or a file)` };
|
|
97
|
+
if (text.split('\n').length > FEEDBACK_LIMITS.lines) return { ok: false, why: `the note has more than ${FEEDBACK_LIMITS.lines} lines: a short note, never a log or a file` };
|
|
98
|
+
const stepRaw = oneLine(input.step, 400);
|
|
99
|
+
const step = stepRaw ? oneLine(redactNote(stepRaw).text, FEEDBACK_LIMITS.step) || null : null;
|
|
100
|
+
const version = (v) => { const s = String(v ?? '').trim().replace(/^v/, ''); return VERSION.test(s) ? s : null; };
|
|
101
|
+
const app = FEEDBACK_APPS.includes(String(input.app ?? '')) ? String(input.app) : 'other';
|
|
102
|
+
const emailRaw = String(input.email ?? '').trim();
|
|
103
|
+
if (emailRaw && (emailRaw.length > FEEDBACK_LIMITS.email || !EMAIL.test(emailRaw))) return { ok: false, why: 'the reply address is not a whole email address: leave it out, or ask the person for theirs' };
|
|
104
|
+
const note = {
|
|
105
|
+
kind, text, step,
|
|
106
|
+
studioVersion: version(input.studioVersion), pluginVersion: version(input.pluginVersion),
|
|
107
|
+
app, email: emailRaw || null, offered: input.offered === true,
|
|
108
|
+
};
|
|
109
|
+
return { ok: true, note, taken };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** A draft's id: what would be sent, hashed. The same note always has the same id; any change gives another. */
|
|
113
|
+
export async function draftId(note) {
|
|
114
|
+
const canonical = JSON.stringify([note.kind, note.text, note.step, note.studioVersion, note.pluginVersion, note.app, note.email, note.offered]);
|
|
115
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(canonical));
|
|
116
|
+
return `fd_${[...new Uint8Array(digest)].slice(0, 12).map((b) => b.toString(16).padStart(2, '0')).join('')}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** What goes with the words, in a line the person reads. */
|
|
120
|
+
export function withLine(note) {
|
|
121
|
+
const parts = [
|
|
122
|
+
note.step ? `the step (${note.step})` : null,
|
|
123
|
+
note.studioVersion ? `studio ${note.studioVersion}` : null,
|
|
124
|
+
note.pluginVersion ? `plugin ${note.pluginVersion}` : null,
|
|
125
|
+
APP_LABEL[note.app] ?? null,
|
|
126
|
+
note.offered ? 'that Claude offered it' : 'that you asked to send it',
|
|
127
|
+
].filter(Boolean);
|
|
128
|
+
return `${parts.join(' · ')}. ${note.email ? `A reply address: ${note.email}.` : 'No reply address.'}`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The note, exactly as it would go, as the text a chat shows (for an app with no card). */
|
|
132
|
+
export function noteBlock(note, taken = []) {
|
|
133
|
+
return [
|
|
134
|
+
` Kind: ${KIND_LABEL[note.kind]}`,
|
|
135
|
+
...note.text.split('\n').map((l, i, all) => ` ${i === 0 ? '"' : ' '}${l}${i === all.length - 1 ? '"' : ''}`),
|
|
136
|
+
` Sent with it: ${withLine(note)}`,
|
|
137
|
+
...(taken.length ? [` Homie took out: ${taken.join(', ')}.`] : []),
|
|
138
|
+
].join('\n');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The body a Homie directory takes at /api/feedback/tell. `source`: 'plugin' (this toolkit) or 'mod'. */
|
|
142
|
+
export function noteBody(note, { source, consent }) {
|
|
143
|
+
const body = { kind: note.kind, text: note.text, source, consent, offered: note.offered, app: note.app };
|
|
144
|
+
for (const k of ['step', 'studioVersion', 'pluginVersion', 'email']) if (note[k]) body[k] = note[k];
|
|
145
|
+
return body;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Send a note the person said yes to: { ok, reference, repeat } | { ok: false, why, status }. Never retried here:
|
|
150
|
+
* a second press is the person's to make, and the directory answers a repeat with the same reference.
|
|
151
|
+
*/
|
|
152
|
+
export async function sendNote(note, { directory, source = 'plugin', consent = 'chat', fetchImpl = fetch, timeoutMs = 15_000 } = {}) {
|
|
153
|
+
let res;
|
|
154
|
+
try {
|
|
155
|
+
res = await fetchImpl(feedbackUrl(directory), {
|
|
156
|
+
method: 'POST',
|
|
157
|
+
headers: { 'content-type': 'application/json', accept: 'application/json', 'user-agent': `homie-studio-feedback (${source})` },
|
|
158
|
+
body: JSON.stringify(noteBody(note, { source, consent })),
|
|
159
|
+
redirect: 'manual',
|
|
160
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
161
|
+
});
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return { ok: false, status: 0, why: `Homie could not be reached (${error?.name === 'TimeoutError' ? 'no answer in 15 s' : error?.cause?.code ?? error?.message ?? 'no connection'}). Nothing was sent; the person can try again later.` };
|
|
164
|
+
}
|
|
165
|
+
let body = null;
|
|
166
|
+
try { body = JSON.parse(await res.text()); } catch { body = null; }
|
|
167
|
+
if (res.ok && body?.ok === true && typeof body.reference === 'string') return { ok: true, reference: body.reference, repeat: body.repeat === true };
|
|
168
|
+
const said = typeof body?.message === 'string' ? oneLine(body.message, 300) : null;
|
|
169
|
+
if (res.status === 429) return { ok: false, status: 429, why: said ?? 'Homie has had enough notes from this network today. Nothing was sent; try again tomorrow.' };
|
|
170
|
+
if (res.status === 404) return { ok: false, status: 404, why: 'This Homie directory does not take notes yet. Nothing was sent.' };
|
|
171
|
+
return { ok: false, status: res.status, why: `${said ?? `Homie answered ${res.status}`}. Nothing was sent.` };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Which app a client is, from its MCP initialize clientInfo. */
|
|
175
|
+
export function appOf(clientInfo) {
|
|
176
|
+
const name = String(clientInfo?.name ?? '').toLowerCase();
|
|
177
|
+
if (/codex/.test(name)) return 'codex';
|
|
178
|
+
if (/claude[-_ ]?code/.test(name)) return 'claude-code';
|
|
179
|
+
if (/claude/.test(name)) return 'claude-desktop';
|
|
180
|
+
return 'other';
|
|
181
|
+
}
|