$ show PocketRisu/PocketRisu
PocketRisu is a self-hosted AI roleplay chat platform, forked from RisuAI. It runs as a Node.js server with a Svelte 5 frontend, accessed via browser. The system supports multiple AI providers (OpenAI, Anthropic, Google Gemini, etc.) through a pluggable adapter pattern, and includes character management, lorebooks, plugins, MCP (Model Context Protocol) tools, translation, TTS, image generation, and a comprehensive data-driven settings system. Data is stored in SQLite with content-defined chunking for large values, and the architecture is a monolith with a client-server split: the server handles persistence, backup, asset manifests, and model job processing; the client handles UI, state management, and direct AI API calls (with optional server-side proxy). Key entry points include src/main.ts (client bootstrap), server/node/server.cjs (server), src/ts/storage/database.svelte.ts (central store), and src/ts/process/request/ (AI request handling). External dependencies include Node.js, SQLite, various AI provider APIs, MCP servers, and browser APIs (File System Access, IndexedDB). The codebase is well-tested with unit and integration tests, and features a sophisticated plugin system with sandboxed execution, a model preset registry with remote sync, and a chat delta sync mechanism for efficient data transfer.
The LLM identified 4 files worth highlighting for reuse:
Schema-driven request builder that maps user values to HTTP request components (body, headers, query, auth) for AI provider APIs. Supports nested paths, endpoint overrides, and multiple auth kinds. Isolated and reusable for any API client that needs dynamic request construction from a schema definition.
Prefix-fingerprint based delta synchronization for chat messages. Verifies server-side prefix hash before transferring only new messages, with fallback to full fetch on mismatch. Reusable for any client-server data synchronization where minimizing transfer size is critical.
Sandboxed iframe execution host for third-party plugins. Uses strict CSP, postMessage RPC bridge with callback/stream serialization, and abort signals. Isolated and reusable for securely executing untrusted JavaScript in a web application.
Model Context Protocol (MCP) client library supporting SSE transport, OAuth flow, and JSON-RPC for tool/prompt listing and calling. Reusable for any application that needs to integrate with MCP-compatible servers for tool use.