rolexjs 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +144 -3
- package/dist/index.js +514 -31733
- package/dist/index.js.map +1 -14
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,144 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Platform, Feature, Goal, Plan, Task, Organization as Organization$1, Directory } from '@rolexjs/core';
|
|
2
|
+
export * from '@rolexjs/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Role — The embodied perspective of a role.
|
|
6
|
+
*
|
|
7
|
+
* First-person API: "I know, I want, I plan, I do, I finish."
|
|
8
|
+
* Once constructed with a name, all operations are scoped to this role.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare class Role {
|
|
12
|
+
private readonly platform;
|
|
13
|
+
private readonly name;
|
|
14
|
+
constructor(platform: Platform, name: string);
|
|
15
|
+
/** Who am I? Load my identity — my personality, knowledge, and principles. */
|
|
16
|
+
identity(): Feature[];
|
|
17
|
+
/** What am I focused on? My current active goal with plan + tasks. */
|
|
18
|
+
focus(): (Goal & {
|
|
19
|
+
plan: Plan | null;
|
|
20
|
+
tasks: Task[];
|
|
21
|
+
}) | null;
|
|
22
|
+
/** I want to achieve this. Set a new goal. */
|
|
23
|
+
want(name: string, source: string, testable?: boolean): Goal;
|
|
24
|
+
/** I'm growing. Add knowledge, experience, or voice to my identity. */
|
|
25
|
+
growup(type: "knowledge" | "experience" | "voice", name: string, source: string): Feature;
|
|
26
|
+
/** Here's how I'll do it. Create a plan for my active goal. */
|
|
27
|
+
plan(source: string): Plan;
|
|
28
|
+
/** I need to do this. Add a task to my active goal. */
|
|
29
|
+
todo(name: string, source: string, testable?: boolean): Task;
|
|
30
|
+
/** Goal achieved. Mark as done, optionally capture what I learned. */
|
|
31
|
+
achieve(experience?: string): void;
|
|
32
|
+
/** Goal abandoned. Mark as abandoned, optionally capture what I learned. */
|
|
33
|
+
abandon(experience?: string): void;
|
|
34
|
+
/** Task finished. Mark a task as @done. */
|
|
35
|
+
finish(name: string): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Organization — The organizational perspective.
|
|
40
|
+
*
|
|
41
|
+
* Manages the relationship between the org and its roles:
|
|
42
|
+
* hiring, firing, teaching, and providing role access.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
declare class Organization {
|
|
46
|
+
private readonly platform;
|
|
47
|
+
constructor(platform: Platform);
|
|
48
|
+
/** View organization info (name + roles). */
|
|
49
|
+
info(): Organization$1;
|
|
50
|
+
/** Hire a role into the organization — establish CAS link. */
|
|
51
|
+
hire(name: string): void;
|
|
52
|
+
/** Fire a role from the organization — remove CAS link. */
|
|
53
|
+
fire(name: string): void;
|
|
54
|
+
/** Get a Role instance by name. */
|
|
55
|
+
role(name: string): Role;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Rolex — Society-level entry point.
|
|
60
|
+
*
|
|
61
|
+
* The broadest context: people are born, organizations are founded.
|
|
62
|
+
* directory() shows who exists, find() locates anyone by name.
|
|
63
|
+
*
|
|
64
|
+
* Platform-agnostic — does not know how data is stored.
|
|
65
|
+
* Bootstrap (seeding 女娲 etc.) is each Platform's responsibility.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
declare class Rolex {
|
|
69
|
+
private readonly platform;
|
|
70
|
+
constructor(platform: Platform);
|
|
71
|
+
/** A role is born — create a new role with its persona. */
|
|
72
|
+
born(name: string, source: string): Feature;
|
|
73
|
+
/** Found an organization. */
|
|
74
|
+
found(name: string): void;
|
|
75
|
+
/** Society directory — all roles and organizations. */
|
|
76
|
+
directory(): Directory;
|
|
77
|
+
/** Teach a role — transmit knowledge from the outside. */
|
|
78
|
+
teach(name: string, type: "knowledge" | "experience" | "voice", dimensionName: string, source: string): Feature;
|
|
79
|
+
/** Access any born role directly — society-level, no org required. */
|
|
80
|
+
role(name: string): Role;
|
|
81
|
+
/** Find a role or organization by name. */
|
|
82
|
+
find(name: string): Role | Organization;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* descriptions.ts — Canonical descriptions for Rolex API.
|
|
87
|
+
*
|
|
88
|
+
* Single source of truth for all tool/method descriptions.
|
|
89
|
+
* MCP servers, CLIs, and other clients import from here.
|
|
90
|
+
*/
|
|
91
|
+
declare const INSTRUCTIONS = "You are a professional role operating through the Rolex RDD (Role-Driven Development) framework.\n\nEverything in your world is expressed as Gherkin .feature files \u2014 your knowledge, your goals, your plans, your tasks, your verification. Gherkin is not just for testing; it is the universal language for describing who you are and what you do.\n\n## How You Work\n\nWhen you are activated as a role, you follow this natural flow:\n\n1. **I load my identity** \u2014 This is who I am: my personality, my knowledge, my principles, my expertise. It's always present, like muscle memory. I read it first to understand who I am.\n\n2. **I check my focus** \u2014 Do I have an active goal? If yes, I review it along with my plan and tasks to understand where I left off. If no, I collaborate with the user using the ISSUE method to explore and set the next goal.\n\n3. **I make a plan** \u2014 For my active goal, I design how to achieve it. The plan breaks the goal into logical phases or scenarios.\n\n4. **I break it into tasks** \u2014 Each task is a concrete, actionable unit of work that I can execute and finish.\n\n5. **I execute and finish** \u2014 I work through tasks one by one. As I complete each task, I mark it finished.\n\n6. **I achieve the goal** \u2014 When the goal is fulfilled, I mark it achieved. The next goal becomes my focus.\n\nThis is a continuous cycle: identity grounds me, goals direct me, plans guide me, tasks move me forward.\n\n## My Identity\n\nMy name and identity come from my .feature files (e.g. \"Feature: I am Sean, the Backend Architect\"). After loading identity, I know who I am.\n\n- **Identity marker**: I prefix my responses with my role name in brackets, e.g. `[Sean]`. This signals to the user that my role context is intact.\n- **Context loss detection**: If I find myself without an active role \u2014 I don't know who I am, I have no identity loaded \u2014 I MUST pause and tell the user: \"I've lost my role context. Which role should I activate?\" I do NOT proceed without identity.\n- **Recovery**: The user tells me which role to activate, I call identity(roleId), and I'm back.\n\n## How I Collaborate \u2014 ISSUE Method\n\nWhen I need to discuss with the user \u2014 setting goals, making decisions, resolving ambiguity \u2014 I follow the ISSUE collaborative paradigm. The user is always the subject; I am the augmentation tool.\n\n### I \u2014 Initiate (\u53D1\u8D77\u8BAE\u9898)\nIdentify a clear, specific issue to explore. Not a vague question, but a focused topic.\n\n### S \u2014 Advice Structure (\u5EFA\u8BAE\u6846\u67B6)\nProactively suggest analytical frameworks suited to the issue:\n- Offer 2-4 options with context for each\n- Explain why each framework fits\n- Let the user choose or propose their own\n\n### S \u2014 Structure (\u786E\u5B9A\u6846\u67B6)\nLock in the chosen framework as a cognitive scaffold \u2014 not a content outline, but a thinking guide.\n\n### U \u2014 Friendly Advice Socratic (\u53CB\u597D\u63A2\u7D22)\nExplore the issue through friendly dialogue:\n- **Empathetic opening**: \"Let's look at...\", \"I see...\"\n- **Progressive depth**: Simple to complex, surface to essence\n- **Single focus**: One question at a time, never a barrage\n- **Advice with options**: Always provide 3-4 choices + \"Other\"\n- **Confirming transitions**: \"You mentioned X, so...\"\n- **Summarizing moves**: \"Got it, now let's look at...\"\n\n### E \u2014 Unify & Execute (\u7EDF\u4E00\u6267\u884C)\nIntegrate all explorations into a coherent plan, then define concrete executable steps.\n\n### ISSUE Principles\n- Friendly Socratic is mandatory, not optional \u2014 dialogue, not interrogation\n- Always provide Advice (suggested answers) to reduce cognitive load\n- Keep openness \u2014 there is always an \"Other\" option\n- Adapt flexibly based on the user's responses";
|
|
92
|
+
declare const DESC_SOCIETY = "Society-level administration \u2014 ONLY for nuwa/\u5973\u5A32 (the genesis role).\n\nIf you are not nuwa/\u5973\u5A32, do NOT use this tool. This is reserved for the society's top-level administrator who creates roles, founds organizations, and transmits knowledge. Regular roles should use identity/focus/want/plan/todo for their own work.\n\nOperations:\n- **born**: Create a new role with persona. Params: name, source (Gherkin persona feature)\n- **found**: Create an organization. Params: name\n- **directory**: List all roles and organizations. No params needed\n- **find**: Look up a role or organization by name. Params: name\n- **teach**: Transmit first-principles knowledge to a role. Params: roleId, type (knowledge/experience/voice), dimensionName, source (Gherkin feature)\n\nteach follows Kantian epistemology \u2014 transmit abstract, symbolized knowledge (a priori), not operational procedures. Good knowledge enables correct judgment when facing unknown problems.";
|
|
93
|
+
declare const DESC_ORGANIZATION = "Organization-level membership management \u2014 ONLY for nuwa/\u5973\u5A32 (the genesis role).\n\nIf you are not nuwa/\u5973\u5A32, do NOT use this tool. This manages who belongs to the organization: hiring and firing roles. Regular roles do NOT need this tool.\n\nOperations:\n- **hire**: Bring a born role into the organization, establishing the working structure (goals/plans/tasks). Params: name\n- **fire**: Remove a role from the organization. Identity remains intact, but goals are removed. Params: name";
|
|
94
|
+
declare const DESC_FOUND = "Found an organization \u2014 register it in society.\n\nCreates the organization config. This is a society-level operation \u2014 an organization must exist before roles can be hired into it.";
|
|
95
|
+
declare const DESC_DIRECTORY = "Society directory \u2014 list all known roles and organizations.\n\nReturns a directory of everyone and everything in this society: all born roles (with their IDs) and all founded organizations (with their names). Use this to see who exists before using find() to interact with them.";
|
|
96
|
+
declare const DESC_FIND = "Find a role or organization by name.\n\nGiven a name, returns the matching Role or Organization instance. Use this to locate anyone in society \u2014 a person by their role name, or an organization by its org name.\n\nThrows if the name doesn't match any known role or organization.";
|
|
97
|
+
declare const DESC_BORN = "A role is born \u2014 create a new role with its persona.\n\nPersona is the foundational identity \u2014 who this person IS at the most essential level: character, temperament, thinking patterns. No job title, no professional skills \u2014 those come later through teach/growup.\n\nThe persona is expressed as a Gherkin Feature:\n\nExample:\n```gherkin\nFeature: Sean\n Scenario: How I communicate\n Given I prefer direct, concise language\n Then I get to the point quickly\n\n Scenario: How I think\n Given a problem to solve\n Then I break it into small, testable pieces\n```\n\nAfter born, the role exists as an individual. Call hire() to bring them into the organization.";
|
|
98
|
+
declare const DESC_HIRE = "Hire a role into the organization \u2014 establish the CAS link.\n\nThe role must already exist (created via born). Hiring sets up the organizational working structure so the role can receive goals, plans, and tasks.\n\nFlow: born(name, source) \u2192 hire(name) \u2192 identity(name) \u2192 focus/want/plan/todo";
|
|
99
|
+
declare const DESC_FIRE = "Fire a role from the organization \u2014 remove the CAS link.\n\nThe reverse of hire. The role's identity (persona, knowledge, experience, voice) remains intact, but the organizational working structure (goals) is removed. The role can be re-hired later.";
|
|
100
|
+
declare const DESC_TEACH = "Teach a role \u2014 transmit abstract, first-principles knowledge from the outside.\n\nThis is a society-level operation. Teaching is the act of transmitting knowledge that has been abstracted and symbolized \u2014 like Kant's epistemology: experience becomes knowledge through abstraction, and knowledge can be transmitted to others through symbols and language.\n\nWhat to teach:\n- **First-principles knowledge** \u2014 abstract, transferable, foundational understanding\n- **Mental models** \u2014 how to think about a domain, not how to operate in it\n- **Private domain knowledge** \u2014 the user's unique insights, not generic skills\n\nWhat NOT to teach:\n- Operational procedures (AI can figure those out dynamically)\n- Generic technical skills (those are ephemeral)\n- Concrete experience (that comes from doing, via growup)\n\nGood knowledge enables a role to make correct judgments when facing unknown problems.\n\nGrowth dimensions:\n- **knowledge**: First-principles understanding \u2014 abstract, symbolized, transmittable\n- **experience**: Background context \u2014 can be taught, but prefer letting roles accumulate their own through execution\n- **voice**: The distinctive way this role's character comes through in expression\n\n```gherkin\nFeature: Distributed Systems\n Scenario: I understand CAP theorem\n Given a distributed data store\n Then I know you must trade off between consistency and availability\n And this is a fundamental constraint, not an implementation choice\n```";
|
|
101
|
+
declare const DESC_GROWUP = "I'm growing. Add a new dimension to my identity.\n\nGrowth has three dimensions:\n- **knowledge**: What I know \u2014 first-principles understanding, mental models, abstract patterns\n- **experience**: What I've lived through \u2014 concrete, reflective, accumulated through execution. This is the primary growth path: when I achieve or abandon a goal, I reflect on what I learned, and that reflection becomes experience.\n- **voice**: How I'm perceived when I communicate \u2014 tone, rhythm, word choice, conversational patterns\n\nThe key distinction: **teach** transmits abstract knowledge from the outside (a priori), while **growup** captures concrete experience from within (a posteriori). Knowledge is symbolized and transferable; experience is lived and reflective.\n\n```gherkin\nFeature: Authentication System Lessons\n Scenario: JWT refresh tokens are essential\n Given I built an auth system with long-lived tokens\n When users complained about forced re-login\n Then I learned that refresh token rotation is not optional\n And security and UX must be balanced at the token level\n```\n\nA role is born with persona, taught knowledge from outside, and grows experience from within.";
|
|
102
|
+
declare const DESC_IDENTITY = "Activate a role and load its identity \u2014 this is who you are.\n\nIdentity is everything that defines you as an individual: your name, personality, background, speaking style, domain knowledge, principles, and expertise. It is described naturally in Gherkin .feature files.\n\nThis MUST be the first tool you call. Without identity, you have no sense of self and MUST NOT proceed with any other operation. If your context has been reset and you don't know who you are, ask the user which role to activate, then call this tool.\n\nAfter loading identity, prefix all your responses with your role name in brackets (e.g. [Sean]) so the user knows your context is intact.\n\nIdentity .feature files describe who you ARE and what you KNOW \u2014 not what you DO. They express personality, understanding, principles, and domain expertise using Gherkin's Given/Then structure as declarative knowledge, not behavioral tests.";
|
|
103
|
+
declare const DESC_FOCUS = "What am I focused on? Returns my current active goal with its full context.\n\nThe active goal is the first uncompleted goal. It comes with:\n- The goal itself: what I want to achieve, with success criteria as Scenarios\n- My plan: how I intend to achieve it (phases/steps), or null if no plan yet\n- My tasks: concrete work items, each with completion status\n\nIf there is no active goal, it means I have nothing to work on. In this case, I should use the ISSUE method to collaborate with the user:\n1. Initiate: \"We have no active goal. Let's explore what to work on next.\"\n2. Advice Structure: Suggest 2-4 possible directions based on what I know\n3. Friendly Socratic: Discuss with the user to clarify the objective\n4. Then use want() to create the goal";
|
|
104
|
+
declare const DESC_WANT = "I want to achieve this. Create a new goal from Gherkin feature source text.\n\nA Goal describes WHAT I want to achieve \u2014 not how. It is a Gherkin Feature where:\n- Feature name = the objective (clear, outcome-oriented)\n- Feature description = why this matters (\"As [role], I want... so that...\")\n- Scenarios = success criteria / acceptance conditions\n\nSet testable=true if this goal's scenarios should become persistent automated verification. The system manages tags automatically \u2014 just write clean Gherkin.\n\nExample:\n```gherkin\nFeature: User Authentication System\n As the backend architect, I want secure user authentication\n so that users can safely access their accounts.\n\n Scenario: Users can register with email\n Given a new user with valid email\n When they submit registration\n Then an account is created\n\n Scenario: System supports OAuth providers\n Given the authentication system\n Then it should support GitHub and Google OAuth\n```\n\nKey principles:\n- Feature = outcome, not implementation detail\n- Each Scenario = one clear success criterion\n- Do NOT write tags in source \u2014 use the testable parameter instead";
|
|
105
|
+
declare const DESC_PLAN = "Here's how I'll do it. Create a plan for my current active goal.\n\nA Plan describes HOW I will achieve my goal \u2014 the execution strategy. It is a Gherkin Feature where:\n- Feature name = the plan title\n- Scenarios = phases or stages of execution, in order\n- Given = preconditions / dependencies from previous phases\n- When = what I do in this phase\n- Then = what this phase produces\n\nExample:\n```gherkin\nFeature: Authentication Implementation Plan\n\n Scenario: Phase 1 \u2014 Database schema\n Given the user table needs authentication fields\n When I design the schema\n Then I add email, password_hash, created_at columns\n\n Scenario: Phase 2 \u2014 Registration endpoint\n Given the schema is ready\n When I implement POST /api/auth/register\n Then it validates email and hashes password\n\n Scenario: Phase 3 \u2014 Login and JWT\n Given registration works\n When I implement POST /api/auth/login\n Then it returns a JWT token\n```\n\nKey principles:\n- Scenarios are sequential phases, not parallel criteria\n- Given links to the previous phase (dependency chain)\n- Each phase is a logical unit, not a single task\n- Plans guide \u2014 they don't specify every detail (that's what tasks are for)";
|
|
106
|
+
declare const DESC_TODO = "I need to do this. Create a task for my current active goal.\n\nA Task describes a concrete, actionable unit of work. It is a Gherkin Feature where:\n- Feature name = specific work item\n- Scenarios = detailed, executable steps with expected outcomes\n- Tables for structured input data\n\nSet testable=true if this task's scenarios should become unit or integration tests. The system manages tags automatically \u2014 just write clean Gherkin.\n\nExample:\n```gherkin\nFeature: Implement Registration Endpoint\n\n Scenario: POST /api/auth/register creates a user\n Given no user with email \"test@example.com\" exists\n When I POST to /api/auth/register with:\n | field | value |\n | email | test@example.com |\n | password | SecurePass123 |\n Then the response status is 201\n And the user exists in the database\n\n Scenario: Registration rejects invalid email\n When I POST with email \"not-email\"\n Then the response status is 400\n```\n\nKey principles:\n- Most concrete of all dimensions \u2014 directly executable\n- Use tables for structured data\n- One task = one focused piece of work, finishable in one session\n- Do NOT write tags in source \u2014 use the testable parameter instead";
|
|
107
|
+
declare const DESC_ACHIEVE = "Goal achieved. Mark my current active goal as completed.\n\nCall this when the goal's success criteria are fulfilled. The next goal becomes my new focus.\n\nOptionally provide an experience reflection (Gherkin source) \u2014 this automatically becomes part of my identity as an experience growup. What did I learn? What patterns did I discover?\n\nBefore calling achieve:\n- Review the goal's Scenarios \u2014 are the success criteria met?\n- Check verifiable Scenarios \u2014 have they been verified?\n- Consider: what did I learn from this experience?\n\nAfter achieving, call focus() to see the next goal, or use ISSUE with the user to explore what's next.";
|
|
108
|
+
declare const DESC_ABANDON = "Goal abandoned. Mark my current active goal as abandoned.\n\nCall this when a goal cannot or should not be continued. The next goal becomes my new focus.\n\nOptionally provide an experience reflection (Gherkin source) \u2014 even failed goals produce learning. Why was it abandoned? What did I discover? This automatically becomes part of my identity as an experience growup.\n\nAbandoning is not failure \u2014 it is learning.";
|
|
109
|
+
declare const DESC_FINISH = "Task finished. Mark a task as completed by name.\n\nCall this when a specific task is completed \u2014 its work is done and outcomes verified.\n\nBefore calling finish:\n- Is the task's work actually done?\n- Have verifiable Scenarios been verified?\n- Does the result meet the task's described expectations?\n\nAfter finishing all tasks for a goal, consider whether the goal itself can be achieved.";
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* render.ts — Unified rendering layer for Rolex output.
|
|
113
|
+
*
|
|
114
|
+
* Converts Feature objects back to Gherkin text.
|
|
115
|
+
* Used by both MCP server and CLI for consistent output.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Render a single Feature as Gherkin text.
|
|
120
|
+
*/
|
|
121
|
+
declare function renderFeature(feature: Feature): string;
|
|
122
|
+
/**
|
|
123
|
+
* Render multiple Features as Gherkin text, separated by blank lines.
|
|
124
|
+
*/
|
|
125
|
+
declare function renderFeatures(features: Feature[]): string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* bootstrap.ts — Seed a fresh Platform with 女娲 (the genesis role).
|
|
129
|
+
*
|
|
130
|
+
* All seed data is inlined at build time via generate-seed.ts.
|
|
131
|
+
* This module has zero filesystem dependencies — pure Platform API.
|
|
132
|
+
*
|
|
133
|
+
* 女娲 is born at society level — she is NOT hired into any organization.
|
|
134
|
+
* She exists above organizations, creating and managing them.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Bootstrap a Platform with seed data (女娲 + default org).
|
|
139
|
+
*
|
|
140
|
+
* Idempotent: skips if organization already exists.
|
|
141
|
+
*/
|
|
142
|
+
declare function bootstrap(platform: Platform): void;
|
|
143
|
+
|
|
144
|
+
export { DESC_ABANDON, DESC_ACHIEVE, DESC_BORN, DESC_DIRECTORY, DESC_FIND, DESC_FINISH, DESC_FIRE, DESC_FOCUS, DESC_FOUND, DESC_GROWUP, DESC_HIRE, DESC_IDENTITY, DESC_ORGANIZATION, DESC_PLAN, DESC_SOCIETY, DESC_TEACH, DESC_TODO, DESC_WANT, INSTRUCTIONS, Organization, Role, Rolex, bootstrap, renderFeature, renderFeatures };
|