# Add to your Claude Code skills
git clone https://github.com/weidu12123/LiyuanLiyuan is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by weidu12123. 梨园 Liyuan — 以 rp agent为主体的ai角色扮演应用. It has 299 GitHub stars.
Liyuan's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/weidu12123/Liyuan" and add it to your Claude Code skills directory (see the Installation section above).
Liyuan is primarily written in TypeScript. It is open-source under weidu12123 on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh Liyuan against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
English · 简体中文
An RP Agent built on pi, bringing coding agent superpowers to role-playing.
📖 Documentation · 🚀 Releases · 🌐 Website

Liyuan (梨园) is a next-generation Role-Play Agent built on top of pi. By reimagining coding agent primitives for creative storytelling and roleplay, Liyuan tackles the chronic limitations of traditional RP frontends—such as context bloat, setting drift, ungrounded hallucination, prompt clutter, and vendor lock-in—delivering an immersive, transparent, and deterministic role-playing experience.
Liyuan's core architecture translates proven software engineering agent paradigms directly into roleplay mechanics:
| Coding Agent Primitive | Liyuan RP Equivalent | Description |
|---|---|---|
| Workspace / cwd | Isolated Card Space | One directory per character card, isolating assets, sessions, memory, and state |
| Code | Story Prose | The narrative text treated as living creative output |
| Edit / Patch | In-Place Targeted Revisions | Surgical prose edits and adjustments without regenerating entire paragraphs |
| Grep / Search | Text & Lore Retrieval | On-demand search across lorebooks and past chapters without bloating context |
| Rewind / Checkpoint | Branch Rollback & Revision | Non-destructive story branching and checkpoint restore for alternate storylines |
| Context Compaction | Narrative Compaction (Story Recap) | Summarizing past chapters into faithful story recaps while keeping recent prose pristine |
| Cross-Session Memory | Card-Level Memory & Forgetting | Per-card consolidation across sessions with synchronized physical forgetting |
| Permission Gate | Narrative Fork Decision Cards | Interactive decision prompts (ask tool) at crucial plot junctures for user choice |
| SYSTEM.md / AGENTS.md | Engine Protocols & World Laws | Fully transparent, file-based prompt layers with modular toggles |

SYSTEM.md (engine protocol) and AGENTS.md (world rules and character lore) for transparent, file-level editing with entry-by-entry toggles.
ask tool to present branching choices and free-form inputs, co-authoring the story with you.For complete visual guides and interface walkthroughs, see the Liyuan Documentation (docs.liyuan.pro).
# Copy example configuration files
cp liyuan.agent.example.json liyuan.agent.json
cp liyuan.config.example.json liyuan.config.json
# Edit liyuan.agent.json to set your apiKey, baseURL, and model ID
# Install dependencies and start
npm install
npm run web:build # Build frontend (can be skipped if web/dist already exists)
npm run web # Launch server
start.batchmod +x start.sh && ./start.shhttp://127.0.0.1:7620 in your browser.Security Note: Port 7620 does not enforce authentication by default. Do not expose it directly to the public internet without a reverse proxy and authentication layer.
git clone --depth 1 https://github.com/weidu12123/Liyuan.git && cd Liyuan
docker compose up -d --build
Data and configurations persist in local mapped volumes.
You can also use prebuilt multi-arch images directly from GHCR without building from source:
mkdir -p liyuan && cd liyuan
curl -fsSL -o docker-compose.yml https://raw.githubusercontent.com/weidu12123/Liyuan/master/deploy/compose.ghcr.yml
docker compose up -d
Domain Layer src/ Character cards, lorebooks, staging, memory, timelines
Wiring Layer .liyuan/extensions/roleplay.ts pi extension hooks and tool registrations
Web Layer server/ + web/ Backend orchestration, WebSocket/REST protocols, and Web UI
Core Layer packages/@liyuan/* Locally maintained pi agent core framework
Running unit tests:
node --test test/*.test.ts