AI Agent Role Management Framework
RoleX is a framework for defining, composing, and loading AI agent roles. Built on top of ResourceX, it provides type-safe role resource handling with version management and remote distribution.
- Declarative Role Definition - Define roles with personality, principle, and knowledge sections
- Modular Composition - Reuse modules via
@!thought://,@!execution://,@!knowledge://references - ResourceX Integration - First-class
roletype for ResourceX with versioning and remote distribution - Stateless Design -
roleTypeis a pure static object with no external dependencies
bun add rolexjs resourcexjsimport { createRegistry } from "resourcexjs";
import { roleType } from "rolexjs";
// Create registry and register role type
const registry = createRegistry({
type: "git",
url: "https://github.com/Deepractice/Registry.git",
domain: "deepractice.dev",
});
registry.supportType(roleType);// Resolve role resource
const resolved = await registry.resolve("deepractice.dev/nuwa.role@1.0.0");
// Execute to get rendered role
const role = await resolved.execute();
console.log(role.prompt); // Full system prompt
console.log(role.personality); // Personality section
console.log(role.principle); // Principle section
console.log(role.knowledge); // Knowledge sectionRoles are defined in .role.md files with three core sections:
# Role Name
<role>
<personality>
I am an AI assistant.
Core principles:
- First principles thinking
- Dialogue-driven exploration
@!thought://first-principles
@!thought://dialogue-exploration
</personality>
<principle>
@!execution://workflow
@!execution://constraints
</principle>
<knowledge>
@!knowledge://domain-knowledge
@!knowledge://best-practices
</knowledge>
</role>@!thought://name→thought/name.thought.md@!execution://name→execution/name.execution.md@!knowledge://name→knowledge/name.knowledge.md
my-role/
├── my-role.role.md # Main file
├── thought/
│ ├── first-principles.thought.md
│ └── dialogue-exploration.thought.md
├── execution/
│ └── workflow.execution.md
└── knowledge/
└── domain-knowledge.knowledge.md
import { roleType } from "rolexjs";
// ResourceX resource type definition
roleType: ResourceType<void, RenderedRole>;| Property | Value |
|---|---|
| name | "role" |
| aliases | ["ai-role", "agent-role"] |
| description | "AI Agent Role" |
interface RenderedRole {
prompt: string; // Full rendered prompt
personality: string; // Personality section
principle: string; // Principle section
knowledge: string; // Knowledge section
}The deepractice.dev Registry provides the following roles:
| Role | Description |
|---|---|
deepractice.dev/nuwa.role@1.0.0 |
AI Role Creation Expert |
deepractice.dev/luban.role@1.0.0 |
AI Tool Integration Expert |
deepractice.dev/jiangziya.role@1.0.0 |
Strategic Planning Expert |
deepractice.dev/sean.role@1.0.0 |
Sean's Personal Assistant |
deepractice.dev/shaqing.role@1.0.0 |
Shaqing Writing Assistant |
deepractice.dev/teacheryo.role@1.0.0 |
English Teaching Expert |
deepractice.dev/writer.role@1.0.0 |
Writing Assistant |
RoleX is part of the ResourceX ecosystem:
ResourceX (Resource Protocol Layer)
↓
RoleX (role type implementation)
↓
Role Resources (nuwa.role, luban.role, ...)
- ResourceX provides the resource management protocol (RXL, RXM, RXC, Registry)
- RoleX implements serialization and parsing logic for the
roletype - Role Resources are stored in ResourceX registries
# Install dependencies
bun install
# Build
bun run build
# Test
bun run test
# BDD tests
bun run test:bdd
# Type check
bun run typecheck
# Format
bun run formatpackages/
├── core/ # @rolexjs/core - Core implementation
└── rolexjs/ # rolexjs - Main package (re-exports core)
MIT