RoleX
Provides AI agents with persistent identity, social organization, and experience-based growth, modeled on human societies, via MCP tools for goal management, learning, and resource sharing.
README
<div align="center"> <h1>RoleX</h1> <p> <strong>Social Framework for AI Agents</strong> </p> <p>AI 智能体社会化框架</p> <p><em>Give AI agents persistent identity, social structure, and growth through experience — modeled on how human societies work.</em></p>
<p> <a href="https://github.com/Deepractice/RoleX"><img src="https://img.shields.io/github/stars/Deepractice/RoleX?style=social" alt="Stars"/></a> <img src="https://visitor-badge.laobi.icu/badge?page_id=Deepractice.RoleX" alt="Views"/> <a href="LICENSE"><img src="https://img.shields.io/github/license/Deepractice/RoleX?color=blue" alt="License"/></a> <a href="https://www.npmjs.com/package/rolexjs"><img src="https://img.shields.io/npm/v/rolexjs?color=cb3837&logo=npm" alt="npm"/></a> </p>
<p> <a href="README.md"><strong>English</strong></a> | <a href="README.zh-CN.md">简体中文</a> </p> </div>
Why Social?
Human societies solve a problem AI agents haven't: how to organize, grow, and persist.
In a society, people have identities, join organizations, hold positions, accumulate experience, and pass on knowledge. RoleX brings this same model to AI agents:
- Identity — An agent knows who it is across sessions, not just within one
- Organization — Agents belong to groups, hold positions, carry duties
- Growth — Experience accumulates into principles and reusable skills
- Persistence — Goals, plans, and knowledge survive beyond a single conversation
Everything is expressed in Gherkin .feature format — human-readable, structured, versionable.
Quick Start
Install the MCP server, connect it to your AI client, and say "activate nuwa" — she will guide you from there.
<details> <summary><b>Claude Code</b></summary>
claude mcp add rolex -- npx -y @rolexjs/mcp-server
</details>
<details> <summary><b>Claude Desktop</b></summary>
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"rolex": {
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
</details>
<details> <summary><b>Cursor</b></summary>
Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
{
"mcpServers": {
"rolex": {
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
</details>
<details> <summary><b>VS Code</b></summary>
Add to .vscode/mcp.json:
{
"servers": {
"rolex": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
</details>
<details> <summary><b>Windsurf</b></summary>
Edit ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"rolex": {
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
</details>
<details> <summary><b>JetBrains IDEs</b></summary>
Go to Settings > Tools > AI Assistant > Model Context Protocol (MCP), click + and paste:
{
"mcpServers": {
"rolex": {
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
</details>
<details> <summary><b>Zed</b></summary>
Add to Zed's settings.json:
{
"context_servers": {
"rolex": {
"command": {
"path": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
}
</details>
How It Works
You don't need to learn any commands. Just install the MCP server and talk to your AI naturally — "create an organization", "set a goal", "what have I learned?". The AI knows which tools to call.
Everything below is what happens under the hood. RoleX provides MCP tools that the AI calls autonomously. Understanding the mechanism helps you get more out of it, but operating it is the AI's job, not yours.
The tools fall into two categories:
- Direct tools — the AI calls them by name (e.g.
activate,want,plan). These are daily operations. - The
usetool — a unified dispatch for world management, written as!namespace.method(e.g.!org.found,!census.list). This is the admin layer.
The following sections walk through each system in the order an agent encounters them.
1. The World — Society Structure
Before an agent can act, a world must exist. RoleX models a society with four entity types:
Society
├── Individual # An agent with identity, goals, and knowledge
├── Organization # Groups individuals via membership
├── Position # Defines roles with duties and required skills
└── Past # Archive for retired/dissolved entities
All world management goes through the use tool:
Individual — agent lifecycle
| Command | What it does |
|---|---|
!individual.born |
Create an individual |
!individual.teach |
Inject a principle (knowledge) |
!individual.train |
Inject a procedure (skill) |
!individual.retire |
Archive an individual |
Organization — group structure
| Command | What it does |
|---|---|
!org.found |
Create an organization |
!org.charter |
Define mission and governance |
!org.hire / !org.fire |
Add or remove members |
!org.dissolve |
Archive an organization |
Position — roles and responsibilities
| Command | What it does |
|---|---|
!position.establish |
Create a position |
!position.charge |
Assign a duty |
!position.require |
Declare a required skill — auto-trained on appointment |
!position.appoint / !position.dismiss |
Assign or remove an individual |
!position.abolish |
Archive a position |
Census — query the world
| Command | What it does |
|---|---|
!census.list |
List all individuals, organizations, positions |
!census.list { type: "..." } |
Filter by type: individual, organization, position, past |
2. Execution — The Doing Cycle
Once activated, an agent pursues goals through a structured lifecycle. These are direct tools the agent calls by name:
activate → want → plan → todo → finish → complete / abandon
| Tool | What it does |
|---|---|
activate |
Enter a role — load identity, goals, knowledge |
focus |
View or switch the current goal |
want |
Declare a goal with success criteria |
plan |
Break a goal into phases (supports sequential and fallback strategies) |
todo |
Create a concrete task under a plan |
finish |
Mark a task done, optionally record what happened |
complete |
Mark a plan done — strategy succeeded |
abandon |
Drop a plan — strategy failed, but learning is captured |
3. Cognition — The Learning Cycle
Execution produces encounters — raw records of what happened. The cognition system transforms these into structured knowledge. These are also direct tools:
encounter → reflect → experience → realize / master → principle / procedure
| Tool | What it does |
|---|---|
reflect |
Digest encounters into experience — pattern recognition |
realize |
Distill experience into a principle — a transferable truth |
master |
Distill experience into a procedure — a reusable skill |
forget |
Remove outdated knowledge |
This is how an agent grows. A principle learned from one project applies to the next. A procedure mastered once can be reused forever.
4. Skills — Progressive Disclosure
An agent can't load every skill into context at once. RoleX uses a three-layer progressive disclosure model:
| Layer | Loaded when | What it contains |
|---|---|---|
| Procedure | Always (at activate) | Metadata — what the skill is, when to use it |
| Skill | On demand via skill(locator) |
Full instructions — step-by-step how to do it |
| Resource | On demand via use(locator) |
External content — templates, data, tools |
The skill and use tools are direct tools for loading content. When use receives a locator without the ! prefix, it loads a resource from ResourceX instead of dispatching a command.
5. Resources — Agent Capital
Resources are the means of production for AI agents — skills, prototypes, and knowledge packages that can be accumulated, shared, and reused across agents and teams.
Powered by ResourceX, the resource system covers the full lifecycle through the use tool:
Production — create and package
| Command | What it does |
|---|---|
!resource.add |
Register a local resource |
!prototype.summon |
Pull and register a prototype from source |
!prototype.banish |
Unregister a prototype |
Distribution — share and consume
| Command | What it does |
|---|---|
!resource.push |
Publish a resource to a registry |
!resource.pull |
Download a resource from a registry |
!resource.search |
Search available resources |
Inspection
| Command | What it does |
|---|---|
!resource.info |
View resource metadata |
This is how agent knowledge scales beyond a single individual — skills authored once can be distributed to any agent through prototypes and registries.
Gherkin — The Universal Language
Everything in RoleX is expressed as Gherkin Features:
Feature: Sean
A backend architect who builds AI agent frameworks.
Scenario: Background
Given I am a software engineer
And I specialize in systems design
Goals, plans, tasks, principles, procedures, encounters, experiences — all Gherkin. This means:
- Human-readable — anyone can understand an agent's state
- Structured — parseable, diffable, versionable
- Composable — Features compose naturally into larger systems
Storage
RoleX persists everything in SQLite at ~/.deepractice/rolex/:
~/.deepractice/rolex/
├── rolex.db # SQLite — single source of truth
├── prototype.json # Prototype registry
└── context/ # Role context (focused goal/plan per role)
Packages
| Package | Description |
|---|---|
rolexjs |
Core API — Rolex class, namespaces, rendering |
@rolexjs/mcp-server |
MCP server for AI clients |
@rolexjs/core |
Core types, structures, platform interface |
@rolexjs/system |
Runtime interface, state merging, prototype |
@rolexjs/parser |
Gherkin parser |
@rolexjs/local-platform |
SQLite-backed runtime implementation |
@rolexjs/cli |
Command-line interface |
<div align="center"> <h3>Ecosystem</h3> <p>Part of the <a href="https://github.com/Deepractice">Deepractice</a> AI Agent infrastructure:</p> <p> <a href="https://github.com/Deepractice/ResourceX"><strong>ResourceX</strong></a> · <a href="https://github.com/Deepractice/RoleX"><strong>RoleX</strong></a> · <a href="https://github.com/Deepractice/CommonX"><strong>CommonX</strong></a> </p> </div>
<div align="center"> <p>MIT License © <a href="https://github.com/Deepractice">Deepractice</a></p> </div>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。