pet-mochi Svelte Themes

Pet Mochi

Local-first AI digital pet for your desktop. Mochi moves, remembers, and chats โ€” fully offline by default, optional Ollama for personality. Built with Tauri 2 + Svelte 5 + Rust + SQLite.

๐Ÿก Pet Mochi

A local-first AI digital pet that lives on your desktop.

Mochi moves on her own, remembers what matters, and chats briefly through an optional local LLM. Works fully offline. No accounts. No cloud. No telemetry.

Mochi celebrating
idle
idle
walk
walk
jump
jump
sit
sit
look
look
sleep
sleep
eat
eat
yawn
yawn
roll
roll
blush
blush
hide
hide
celebrate
celebrate

14 hand-drawn poses + per-mood color tint + 4 distinguishing glyphs
(๐Ÿก hungry ยท โ€ฆ bored ยท โ™ก lonely ยท ? curious)


Why Pet Mochi

Most AI companions are chatbots wearing a mascot. Most virtual pets are cute shells with no memory. Mochi is a deliberate middle path:

  • Alive without the LLM. A deterministic local simulation drives mood, needs, movement, sleep, and idle behavior โ€” every 3 seconds, all day, no network calls.
  • LLM only at salience moments. Short greetings, daily reflections, and memory extraction. Hard cooldowns prevent spam and bills.
  • Memory you can read and delete. SQLite + FTS5, ranked by importance ร— recency ร— confidence. Export to Markdown anytime.
  • Sandbox by default. Mochi can read files you drop into her inbox only after explicit per-file consent โ€” never your filesystem at large.

"The pet must feel alive even when the LLM is off." โ€” Project North Star


Install & Run

git clone https://github.com/cskwork/pet-mochi.git
cd pet-mochi
npm install
npm run tauri:dev          # launches the desktop pet

Requirements

  • Node โ‰ฅ 20 ยท Rust โ‰ฅ 1.77
  • Windows / macOS / Linux (Tauri 2 supported platforms)
  • Optional: Ollama for chat replies

That's it. Mochi happily runs in silent mode โ€” no setup needed for the core experience.


What Mochi Can Do Today

  • Lives as a transparent always-on-top overlay โ€” drag her anywhere on the desktop, click-through hit-testing keeps the rest of your screen usable.
  • Animates 14 sprite states โ€” idle / walk / run / sleep / jump / sit / look-cursor / hide / celebrate / eat / yawn / roll / blush โ€” driven by a pure-function state machine.
  • Mood you can read at a glance โ€” color tints + glyphs (๐Ÿก hungry, โ€ฆ bored, โ™ก lonely, ? curious) so similar mood tones stay distinguishable.
  • Tamagotchi-style actions โ€” Feed ยท Play ยท Pat ยท Rest ยท Report, each with multi-frame animation sequences.
  • Right-click โ†’ Close Mochi โ€” a tiny context menu since the overlay window is frameless.
  • Persistent memories โ€” durable preferences and recurring context survive restarts. Review, export, or delete from Settings.
  • Daily reflections โ€” once a day Mochi writes a short "dream" file summarizing what she learned and noticed.
  • File summaries with consent โ€” drop a .txt / .md / .json into the inbox; Mochi asks before reading it.
  • Optional Ollama chat โ€” short, mood-aware in-character replies. Hard cooldown, graceful fallback when the model is offline.

Coming next (roadmap)

  • Behavior choreography (ยง9.11, REQ-094โ€ฆ099) โ€” LLM expresses emotion through named animation presets, never free text. Closed-vocabulary bubbles only.
  • 12h idle-triggered status report (ยง9.8, REQ-070โ€ฆ076) โ€” replaces the fixed daily cadence. Fires only when the host is idle and โ‰ฅ12h has elapsed; missed windows are dropped (no catch-up).
  • Expressive sprite set (REQ-015) โ€” stretch ยท peek ยท tilt_head ยท shake ยท nuzzle ยท wiggle ยท dizzy ยท surprise.

Further out: Voice ยท Custom skins ยท Live2D / VRM ยท Git/test-runner watcher ยท Local embedding memory search ยท Multiple pets. See PRD.md ยง24.


Talking to Mochi (Optional)

Pet Mochi is happy in silent mode. To enable chat, install Ollama and pull a small lightweight model:

ollama pull gemma4:e2b

Open Settings โ†’ set provider to ollama, point endpoint at http://localhost:11434 and choose a model (defaults to gemma4:e2b). Mochi retrieves relevant memories, sends a compressed prompt, and stores the interaction. A best-effort memory extraction job runs in the background after each LLM-backed reply.


Architecture

Layer Tech Notes
Desktop shell Tauri 2 Transparent, always-on-top, draggable overlay.
UI Svelte 5 + TypeScript PNG sprite + CSS animation, no extra renderer.
Simulation engine TypeScript pure functions Mood/decay/movement; testable, no LLM required.
Memory engine Rust + rusqlite + FTS5 Durable memories, prefix search, weighted ranking.
LLM adapter Rust + reqwest Pluggable LlmProvider trait. Ollama is the first impl.
Sandbox Rust Inbox watcher (notify), path-jail safe IO, declarative skills.
src/                       Svelte + TypeScript frontend
โ”œโ”€ App.svelte              Routes pet (default) and settings (#/settings)
โ”œโ”€ lib/
โ”‚  โ”œโ”€ sim/                 Pure simulation engine (testable)
โ”‚  โ”œโ”€ events/bus.ts        In-process event bus + salience-driven LLM gating
โ”‚  โ”œโ”€ bridge/              Tauri invoke wrapper + typed API
โ”‚  โ””โ”€ components/          Pet, MochiSprite, ChatBubble, PetActions, Settings
src-tauri/                 Rust backend
โ”œโ”€ src/
โ”‚  โ”œโ”€ db.rs                SQLite schema, FTS5 search, CRUD
โ”‚  โ”œโ”€ llm/                 Provider trait, Ollama, prompts, cooldowns
โ”‚  โ”œโ”€ sandbox.rs           Pet home, safe file IO, skill manifests
โ”‚  โ”œโ”€ watcher.rs           notify-based inbox watcher
โ”‚  โ”œโ”€ commands.rs          Every #[tauri::command]
โ”‚  โ”œโ”€ state.rs             Shared AppState (Arc<Db>, LLM, cooldowns)
โ”‚  โ””โ”€ lib.rs               Tauri builder, plugin wiring, setup

Design choices worth knowing

  • Simulation first. A runTick(state, ctx, elapsed) pure function decides the pet's behavior every 3s. The LLM is consulted only when an event's salience clears 70 and a 90-second autonomous cooldown has passed.
  • Memory ranking. FTS5 prefix search retrieves candidates; we re-rank by 0.4 ร— importance + 0.3 ร— recency + 0.3 ร— confidence so old-but-important memories beat fresh trivia.
  • Failure first. The pet keeps animating when the DB is unavailable, when Ollama is offline, when memory extraction returns garbage JSON. Failures log warnings instead of bubbling up to the UI.
  • Safety. No eval, no shell, no remote skill loading. File paths are canonicalized and verified to live under the sandbox before any read/write.

Sandbox

Mochi's home folder lives at:

OS Path
Windows %LOCALAPPDATA%\pet-mochi\
macOS ~/Library/Application Support/pet-mochi/
Linux ~/.local/share/pet-mochi/

Override with the MOCHI_HOME env var.

pet-mochi/
โ”œโ”€ inbox/      โ† drop .txt / .md / .json files here
โ”œโ”€ notes/      โ† Mochi writes summaries
โ”œโ”€ dreams/     โ† daily reflections
โ”œโ”€ exports/    โ† memory exports (Markdown / JSON)
โ””โ”€ mochi.db    โ† SQLite memory + state

Mochi never reads files outside inbox/, never writes outside notes/, dreams/, or exports/, never executes shell commands, and refuses paths containing .., absolute escapes, or symlinks that resolve outside the sandbox.


Development

Run tests

npm test                                 # 99 frontend simulation tests (vitest)
cd src-tauri && cargo test --lib         # 41 backend tests (db, sandbox, llm, prompts)

Type-check & build

npm run check          # svelte-check
npm run build          # vite frontend bundle
npm run tauri:build    # full desktop installer (icons already generated)

Project decisions

See DECISIONS.md for the rationale behind recent UX/a11y improvements, and BACKLOG.md for deferred items.


PRD coverage

Every numbered requirement (REQ-001 โ€ฆ REQ-099) from PRD.md is either implemented, in active development (REQ-015, REQ-070โ€ฆ076, REQ-094โ€ฆ099), or explicitly out-of-scope for the MVP. Highlights:

  • โœ… Transparent always-on-top draggable overlay (REQ-001โ€ฆ005)
  • โœ… Idle / walk / sleep / jump / sit / look_cursor / celebrate / hide / run animations (REQ-010)
  • โœ… Deterministic simulation, LLM-free movement (REQ-011โ€ฆ013)
  • โœ… Hidden stats with decay & recovery (REQ-020โ€ฆ024)
  • โœ… Event bus with salience scoring & LLM cooldown (REQ-030โ€ฆ033, ยง14.1)
  • โœ… Provider trait (LlmProvider) โ€” Ollama default, swappable (REQ-040โ€ฆ044)
  • โœ… Short, mood-aware chat replies with graceful fallback (REQ-050โ€ฆ054)
  • โœ… SQLite + FTS5 memory store, recency ร— importance ร— confidence ranking (REQ-060โ€ฆ066)
  • โœ… Daily reflection (LLM optional; deterministic fallback) โ†’ dreams/ (REQ-070โ€ฆ073)
  • โœ… Pet home folder with inbox/, notes/, dreams/, exports/ (REQ-080โ€ฆ084)
  • โœ… Declarative skill manifests, no remote skill installation (REQ-090โ€ฆ093)

Out of scope for MVP (per PRD ยง4.2): voice, 3D/Live2D, browser automation, shell execution, cloud sync, marketplace plugins.


Contributing

Issues and PRs welcome. Before opening a PR:

  • Run npm test and cd src-tauri && cargo test --lib โ€” both must pass.
  • Run npm run check โ€” must be 0 errors / 0 warnings.
  • For UI changes, smoke-test in npm run tauri:dev and describe what you saw in the PR description.
  • Match the existing simulation-first principle: the pet must feel alive even when the LLM is off.

License

MIT โ€” do whatever you want, no warranty.

If Pet Mochi made your day a little nicer, โญ the repo. That's all.

Top categories

Loading Svelte Themes