|
| 1 | +# 心屿 Xinyu Island (`xinyu-daily`) |
| 2 | + |
| 3 | +English | [简体中文](README.zh-CN.md) |
| 4 | + |
| 5 | +A cozy daily-mood Mini App that plays like a small indie game. A floating island grows as you tell |
| 6 | +its keeper, a cloud named Xiaoyu, more about yourself. Each day you can draw an inspiration card, |
| 7 | +stick a mood sticker, drop small joys into a jar, settle indecision with a slot machine, and hunt |
| 8 | +for 20 hidden secrets guarded by Hengheng, a grumpy crab who calls himself the island bully. If you |
| 9 | +turn on Xiaoyu's companionship, Xiaoyu also writes you a letter every day, chats with you, and keeps |
| 10 | +a notebook of what you asked it to remember. |
| 11 | + |
| 12 | +The app makes no network requests of its own. Xiaoyu's letters and chat stay off until you turn |
| 13 | +them on; only then does the app run Agent turns, which send the related records to the model you |
| 14 | +use in MiniMax Code. The interface is in Chinese. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +*Preview uses synthetic data.* |
| 19 | + |
| 20 | +## What you can do |
| 21 | + |
| 22 | +- **Today's inspiration card**: answer three light questions, then flip a collectible card with a |
| 23 | + keyword, an energy score, four small stats, a colour, a number, things that suit today and things |
| 24 | + to set aside. Your answers, your birthday, and what Xiaoyu knows about you change the card. Rare |
| 25 | + cards are holographic. Content is generated by rules and is for fun and self-reflection only; it |
| 26 | + makes no predictions and gives no advice. |
| 27 | +- **Mood stickers and journal**: one sticker per day, a sticker calendar, a 30-day mood curve, |
| 28 | + streak medals, a card collection album, and a wall of small joys. |
| 29 | +- **Decision crusher**: a slot machine with a pullable lever, and a Book of Answers that gives the |
| 30 | + same answer to the same question on the same day. |
| 31 | +- **Self-exploration**: twelve "about you" questions that grow the island (flowers, a tree, a |
| 32 | + house, a lighthouse, a windmill, a rainbow) and change its weather, season, and weekend props; |
| 33 | + a birthday-flower portrait; an eight-question energy-style quiz. |
| 34 | +- **Xiaoyu's mailbox (optional, uses your model)**: the first tap on the mailbox opens Xiaoyu's |
| 35 | + invitation, which says what it would read and where that goes; nothing is sent until you accept. |
| 36 | + Once it is on, Xiaoyu writes one letter a day from your recent moods and notes, small joys, |
| 37 | + about-you answers, Book of Answers questions, and recent chats, so each letter follows what you |
| 38 | + have shared lately. You can reply and chat (up to 20 messages a day), say "记住…" to have Xiaoyu |
| 39 | + note something, review or forget every note in Xiaoyu's notebook, and get a one-line reply under |
| 40 | + your mood sticker. Read letters stay in a letter box. If you decline, or the model is |
| 41 | + unavailable, Xiaoyu leaves a rule-generated handwritten note instead. |
| 42 | +- **Care message**: when a mood note or a chat message suggests self-harm, the app shows a fixed |
| 43 | + message pointing to the national mental-health hotline 12356 (and 110 / 120 for immediate |
| 44 | + danger). This text is part of the app; it is not generated by the model. |
| 45 | +- **Exploration**: a wake-up opening, region banners, a daily journey checklist, and 20 secrets |
| 46 | + hidden around the island (poke the cloud, tap the moon, squeeze a cloud, catch a shooting star, |
| 47 | + and more). Each find makes Hengheng hand over a shell, tracked in a secrets log. |
| 48 | +- Optional synthesized sound effects (Web Audio, no audio files), day/night sky that follows the |
| 49 | + clock, and `prefers-reduced-motion` support. |
| 50 | + |
| 51 | +## Install |
| 52 | + |
| 53 | +Requires MiniMax Code 3.1.2 or later, because the package declares `agentAccess`; earlier versions |
| 54 | +cannot install it. |
| 55 | + |
| 56 | +Copy this directory, including the hidden `.minimax-plugin/`, into the MiniMax Code plugins |
| 57 | +directory as `xinyu-daily/` (`~/.minimax/plugins/xinyu-daily/` by default; see the root README's |
| 58 | +Install section). Restart MiniMax Code, then open 心屿 from the Mini App entry in the right panel or |
| 59 | +ask the Agent to "打开心屿". |
| 60 | + |
| 61 | +## Tested environment |
| 62 | + |
| 63 | +- MiniMax Code 3.1.1-preview.4651 on macOS, an internal preview build that already ships the 3.1.2 |
| 64 | + Mini App Agent API (`context.agent`). Installed through the Host publish flow, opened in the |
| 65 | + right panel. Exercised: the opening, Xiaoyu's introduction, the about-you dialogue and island |
| 66 | + unlocks, daily questions and card flip, mood stickers and the 3-day streak celebration, the joy |
| 67 | + jar (add and shake), the slot machine, the Book of Answers, the journal, the energy quiz, |
| 68 | + discovering secrets and the secrets log, light and dark sky, and that the companion setting |
| 69 | + appears when the Host provides an Agent. No console errors or failed requests. |
| 70 | +- Xiaoyu's companionship was exercised against a mock Agent with the same `run` contract: the |
| 71 | + invitation (accept, decline, and the offline version when no Agent is available), writing and |
| 72 | + opening letters, the letter box, chat with typing replies, "记住…" and forgetting notes, mood |
| 73 | + replies, turning the companion off and on, a failed letter falling back to a note and "请小屿重写", |
| 74 | + cancelling a turn that starts a tool, timeouts, daily limits, session reuse and replacement, and |
| 75 | + the care message. |
| 76 | +- Not exercised end to end: Xiaoyu's companionship has not yet been run against a real model on a |
| 77 | + device. Shooting stars and hot-air balloons appear at random times, the birthday cake only on the |
| 78 | + user's birthday, and holographic cards only by chance. Sound output was not checked by ear. |
| 79 | + Narrow layouts and reduced motion were checked by reading the CSS, not on a device. |
| 80 | +- The loopback checks and state recovery were exercised with a Node 22 script: requests with a |
| 81 | + forged `Host` or a cross-site `Origin` get `403`, a `text/plain` write gets `415`, and no data |
| 82 | + changes; a truncated, `null`, or array state file is renamed aside and the app starts empty, and |
| 83 | + fields of the wrong type fall back to defaults; when a disk write fails, the in-memory state |
| 84 | + stays as it was. The page's own writes, including those without a body, pass these checks in |
| 85 | + headless Chrome. |
| 86 | + |
| 87 | +## Data & access |
| 88 | + |
| 89 | +- Files: reads its own files under `miniapp/client/`. Writes one file, `xinyu-state.json`, inside |
| 90 | + the Host-provided `context.dataDir` (atomic write through a temporary file). If that file is |
| 91 | + corrupt and cannot be read, it is renamed to `xinyu-state.broken-<time>.json` in the same |
| 92 | + directory and the app starts with empty state. Nothing else. |
| 93 | +- Network: none from the app itself. The page only calls the app's own same-origin routes under |
| 94 | + `/api/`. The server answers only requests from the local page: `Host` must be `127.0.0.1`, |
| 95 | + `localhost`, or `[::1]`, and a browser `Origin`, when sent, must be this app's own address; |
| 96 | + anything else gets `403`. Writes accept only `application/json`. |
| 97 | +- Processes: none. |
| 98 | +- Agent turns: declares `agentAccess: ["session.run"]` with `agentConcurrency: 1`, and runs turns |
| 99 | + from the Node entry (`context.agent`) only after you turn on 小屿陪伴, in the mailbox invitation or |
| 100 | + in Settings. It asks the Agent for plain text only, in three cases: today's letter (plus up to |
| 101 | + eight short notes Xiaoyu keeps about you), a reply in the chat, and one line about today's mood |
| 102 | + sticker. Each prompt holds the app's instructions plus your records, marked as data: today's |
| 103 | + date, nickname, streak, days until your birthday (not the date itself), recent moods and notes, |
| 104 | + small joys, about-you answers, energy style, today's card keyword, recent Book of Answers |
| 105 | + questions, recent chat lines, the notebook, and the previous letter. Notes you forgot are never |
| 106 | + sent again. Turns run in one session per day, hidden from your session list. |
| 107 | +- No tools, no approvals: if a turn starts a tool, asks for a permission, or asks a question, the |
| 108 | + app cancels the turn and never answers `allowOnce`; Xiaoyu falls back to a handwritten note or |
| 109 | + an apology line. The cancel is sent when the `tool.started` event arrives, so a very fast |
| 110 | + read-only tool may already have finished by then. |
| 111 | +- Limits: 240 s for a letter, 120 s for a chat reply, 90 s for a mood reply; up to 20 chat |
| 112 | + messages and 3 mood replies a day; one turn at a time. Agent output is checked for length and |
| 113 | + format, and stripped of markup, before it is shown. |
| 114 | +- Turning the companion off stops new turns; a reply that was still running is discarded, and a |
| 115 | + letter that was still being written is replaced by a handwritten note. |
| 116 | +- State stored in `xinyu-state.json`: nickname, birthday, daily mood check-ins and notes, drawn |
| 117 | + cards and favourites, small joys, Book of Answers history, quiz result, about-you answers, |
| 118 | + discovered secrets, one-time onboarding flags, and for the companion: the on/off choice, letters |
| 119 | + (up to 60), chat lines of the last 3 days, Xiaoyu's notes, the list of forgotten notes, and |
| 120 | + today's session id. The browser's `localStorage` keeps only view preferences (current tab, sky |
| 121 | + mode, sound on/off, whether the opening has played). |
| 122 | +- Reset: Settings → 清空所有数据 deletes all stored state and cancels running Agent turns. |
| 123 | + |
| 124 | +## Files |
| 125 | + |
| 126 | +```text |
| 127 | +.minimax-plugin/plugin.json Plugin manifest |
| 128 | +package.json Mini App declaration |
| 129 | +miniapp/miniapp.json Payload roots, Node entry, page route, Agent access |
| 130 | +miniapp/client/index.html Page shell served at /dashboard |
| 131 | +miniapp/client/app.css Styles and animations |
| 132 | +miniapp/client/app.js Page logic (no dependencies) |
| 133 | +miniapp/node/server.mjs Node entry: start(context) → { dispose }, routes, SSE, Agent turns |
| 134 | +miniapp/node/domain.mjs Validated state changes, persistence, card generation |
| 135 | +miniapp/node/companion.mjs Companion prompts, output checks, handwritten notes, care message |
| 136 | +miniapp/node/content.mjs Content pools: cards, answers, questions, quiz, birth flowers |
| 137 | +miniapp/node/miniapp-api.ts Type declarations for the runtime context |
| 138 | +icon.png Plugin icon |
| 139 | +docs/preview.jpg README preview (synthetic data) |
| 140 | +``` |
| 141 | + |
| 142 | +## License |
| 143 | + |
| 144 | +[MIT](./LICENSE) |
0 commit comments