Skip to content

Repository files navigation

RoleX

Social Framework for AI Agents

AI 智能体社会化框架

Give AI agents persistent identity, social structure, and growth through experience — modeled on how human societies work.

StarsViewsLicensenpm

English | 简体中文


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.

Claude Code
claude mcp add rolex -- npx -y @rolexjs/mcp-server
Claude Desktop

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"]
}
}
}
Cursor

Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):

{
"mcpServers": {
"rolex": {
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
VS Code

Add to .vscode/mcp.json:

{
"servers": {
"rolex": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
Windsurf

Edit ~/.codeium/windsurf/mcp_config.json:

{
"mcpServers": {
"rolex": {
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
JetBrains IDEs

Go to Settings > Tools > AI Assistant > Model Context Protocol (MCP), click + and paste:

{
"mcpServers": {
"rolex": {
"command": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
Zed

Add to Zed's settings.json:

{
"context_servers": {
"rolex": {
"command": {
"path": "npx",
"args": ["-y", "@rolexjs/mcp-server"]
}
}
}
}

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 use tool — 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

CommandWhat it does
!individual.bornCreate an individual
!individual.teachInject a principle (knowledge)
!individual.trainInject a procedure (skill)
!individual.retireArchive an individual

Organization — group structure

CommandWhat it does
!org.foundCreate an organization
!org.charterDefine mission and governance
!org.hire / !org.fireAdd or remove members
!org.dissolveArchive an organization

Position — roles and responsibilities

CommandWhat it does
!position.establishCreate a position
!position.chargeAssign a duty
!position.requireDeclare a required skill — auto-trained on appointment
!position.appoint / !position.dismissAssign or remove an individual
!position.abolishArchive a position

Census — query the world

CommandWhat it does
!census.listList 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
ToolWhat it does
activateEnter a role — load identity, goals, knowledge
focusView or switch the current goal
wantDeclare a goal with success criteria
planBreak a goal into phases (supports sequential and fallback strategies)
todoCreate a concrete task under a plan
finishMark a task done, optionally record what happened
completeMark a plan done — strategy succeeded
abandonDrop 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
ToolWhat it does
reflectDigest encounters into experience — pattern recognition
realizeDistill experience into a principle — a transferable truth
masterDistill experience into a procedure — a reusable skill
forgetRemove 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:

LayerLoaded whenWhat it contains
ProcedureAlways (at activate)Metadata — what the skill is, when to use it
SkillOn demand via skill(locator)Full instructions — step-by-step how to do it
ResourceOn 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

CommandWhat it does
!resource.addRegister a local resource
!prototype.summonPull and register a prototype from source
!prototype.banishUnregister a prototype

Distribution — share and consume

CommandWhat it does
!resource.pushPublish a resource to a registry
!resource.pullDownload a resource from a registry
!resource.searchSearch available resources

Inspection

CommandWhat it does
!resource.infoView 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: SeanA backend architect who builds AI agent frameworks.
Scenario: BackgroundGiven 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

PackageDescription
rolexjsCore API — Rolex class, namespaces, rendering
@rolexjs/mcp-serverMCP server for AI clients
@rolexjs/coreCore types, structures, platform interface
@rolexjs/systemRuntime interface, state merging, prototype
@rolexjs/parserGherkin parser
@rolexjs/local-platformSQLite-backed runtime implementation
@rolexjs/cliCommand-line interface

Ecosystem

Part of the Deepractice AI Agent infrastructure:

ResourceX · RoleX · CommonX


MIT License © Deepractice

About

Deepractice Role System

Resources

Contributing

Stars

35 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages