@rolexjs/mcp-server 0.6.0 → 0.8.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.js CHANGED
@@ -21,6 +21,12 @@ import {
21
21
  DESC_FINISH,
22
22
  renderFeatures,
23
23
  renderFeature,
24
+ renderStatusBar,
25
+ renderError,
26
+ next,
27
+ NEXT,
28
+ nextHire,
29
+ nextFinish,
24
30
  bootstrap
25
31
  } from "rolexjs";
26
32
  import { LocalPlatform } from "@rolexjs/local-platform";
@@ -32,6 +38,7 @@ var platform = new LocalPlatform(rolexDir);
32
38
  bootstrap(platform);
33
39
  var rolex = new Rolex(platform);
34
40
  var currentRole = null;
41
+ var currentRoleName = "";
35
42
  var server = new FastMCP({
36
43
  name: "Rolex MCP Server",
37
44
  version: "0.1.0",
@@ -43,6 +50,15 @@ function requireRole() {
43
50
  }
44
51
  return currentRole;
45
52
  }
53
+ function safeTool(toolName, fn) {
54
+ return async (args) => {
55
+ try {
56
+ return await fn(args);
57
+ } catch (error) {
58
+ throw new Error(renderError(toolName, error));
59
+ }
60
+ };
61
+ }
46
62
  server.addTool({
47
63
  name: "society",
48
64
  description: DESC_SOCIETY,
@@ -54,30 +70,40 @@ server.addTool({
54
70
  type: z.enum(["knowledge", "experience", "voice"]).optional().describe("Growth dimension for teach operation"),
55
71
  dimensionName: z.string().optional().describe("Name for the knowledge being taught (e.g. 'distributed-systems')")
56
72
  }),
57
- execute: async ({ operation, name, source, roleId, type, dimensionName }) => {
73
+ execute: safeTool("society", async ({ operation, name, source, roleId, type, dimensionName }) => {
58
74
  switch (operation) {
59
75
  case "born": {
60
76
  if (!name || !source) throw new Error("born requires: name, source");
61
77
  const feature = rolex.born(name, source);
62
- return `Role born: ${feature.name}`;
78
+ return next(`Role born: ${feature.name}`, NEXT.born);
63
79
  }
64
80
  case "found": {
65
81
  if (!name) throw new Error("found requires: name");
66
82
  rolex.found(name);
67
- return `Organization founded: ${name}`;
83
+ return next(`Organization founded: ${name}`, NEXT.found);
68
84
  }
69
85
  case "directory": {
70
86
  const dir = rolex.directory();
71
87
  const lines = [];
72
- for (const entry of dir.organizations) {
73
- const orgInstance = rolex.find(entry.name);
74
- const info = orgInstance.info();
75
- lines.push(`Organization: ${info.name}`);
76
- for (const role of info.roles) {
77
- lines.push(` - ${role.name} (team: ${role.team})`);
88
+ if (dir.organizations.length > 0) {
89
+ for (const entry of dir.organizations) {
90
+ const orgInstance = rolex.find(entry.name);
91
+ const info = orgInstance.info();
92
+ lines.push(`Organization: ${info.name}`);
93
+ for (const role of info.roles) {
94
+ lines.push(` - ${role.name} (team: ${role.team})`);
95
+ }
78
96
  }
79
97
  }
80
- return lines.join("\n") || "No organizations found.";
98
+ const unaffiliated = dir.roles.filter((r) => !r.team);
99
+ if (unaffiliated.length > 0) {
100
+ if (lines.length > 0) lines.push("");
101
+ lines.push("Roles:");
102
+ for (const role of unaffiliated) {
103
+ lines.push(` - ${role.name}`);
104
+ }
105
+ }
106
+ return lines.join("\n") || "No roles or organizations found.";
81
107
  }
82
108
  case "find": {
83
109
  if (!name) throw new Error("find requires: name");
@@ -93,12 +119,12 @@ server.addTool({
93
119
  if (!roleId || !type || !dimensionName || !source)
94
120
  throw new Error("teach requires: roleId, type, dimensionName, source");
95
121
  const feature = rolex.teach(roleId, type, dimensionName, source);
96
- return `Taught ${type}: ${feature.name}`;
122
+ return next(`Taught ${type}: ${feature.name}`, NEXT.teach);
97
123
  }
98
124
  default:
99
125
  throw new Error(`Unknown society operation: ${operation}`);
100
126
  }
101
- }
127
+ })
102
128
  });
103
129
  server.addTool({
104
130
  name: "organization",
@@ -107,22 +133,25 @@ server.addTool({
107
133
  operation: z.enum(["hire", "fire"]).describe("The organization operation to perform"),
108
134
  name: z.string().describe("Role name to hire or fire")
109
135
  }),
110
- execute: async ({ operation, name }) => {
136
+ execute: safeTool("organization", async ({ operation, name }) => {
111
137
  const dir = rolex.directory();
138
+ if (dir.organizations.length === 0) {
139
+ throw new Error("No organization found. Call found() first.");
140
+ }
112
141
  const org = rolex.find(dir.organizations[0].name);
113
142
  switch (operation) {
114
143
  case "hire": {
115
144
  org.hire(name);
116
- return `Role hired: ${name}`;
145
+ return next(`Role hired: ${name}`, nextHire(name));
117
146
  }
118
147
  case "fire": {
119
148
  org.fire(name);
120
- return `Role fired: ${name}`;
149
+ return next(`Role fired: ${name}`, NEXT.fire);
121
150
  }
122
151
  default:
123
152
  throw new Error(`Unknown organization operation: ${operation}`);
124
153
  }
125
- }
154
+ })
126
155
  });
127
156
  server.addTool({
128
157
  name: "identity",
@@ -130,11 +159,16 @@ server.addTool({
130
159
  parameters: z.object({
131
160
  roleId: z.string().describe("Role name (e.g. 'sean')")
132
161
  }),
133
- execute: async ({ roleId }) => {
162
+ execute: safeTool("identity", async ({ roleId }) => {
134
163
  currentRole = rolex.role(roleId);
164
+ currentRoleName = roleId;
135
165
  const features = currentRole.identity();
136
- return renderFeatures(features);
137
- }
166
+ const { current } = currentRole.focus();
167
+ const statusBar = renderStatusBar(roleId, current);
168
+ return `${statusBar}
169
+
170
+ ${renderFeatures(features)}`;
171
+ })
138
172
  });
139
173
  server.addTool({
140
174
  name: "growup",
@@ -146,11 +180,11 @@ server.addTool({
146
180
  name: z.string().describe("Name for this growth (used as filename, e.g. 'distributed-systems')"),
147
181
  source: z.string().describe("Gherkin feature source text")
148
182
  }),
149
- execute: async ({ type, name, source }) => {
183
+ execute: safeTool("growup", async ({ type, name, source }) => {
150
184
  const role = requireRole();
151
185
  const feature = role.growup(type, name, source);
152
- return `Growth added (${type}): ${feature.name}`;
153
- }
186
+ return next(`Growth added (${type}): ${feature.name}`, NEXT.growup);
187
+ })
154
188
  });
155
189
  server.addTool({
156
190
  name: "focus",
@@ -158,11 +192,15 @@ server.addTool({
158
192
  parameters: z.object({
159
193
  name: z.string().optional().describe("Optional goal name to switch focus to")
160
194
  }),
161
- execute: async ({ name }) => {
195
+ execute: safeTool("focus", async ({ name }) => {
162
196
  const role = requireRole();
163
197
  const { current, otherGoals } = role.focus(name);
164
- if (!current && otherGoals.length === 0) return "No active goal. Use want() to set a new goal.";
165
- const parts = [];
198
+ const statusBar = renderStatusBar(currentRoleName, current);
199
+ if (!current && otherGoals.length === 0)
200
+ return `${statusBar}
201
+
202
+ No active goal. Use want() to set a new goal.`;
203
+ const parts = [statusBar];
166
204
  if (current) {
167
205
  parts.push(renderFeature(current));
168
206
  if (current.plan) {
@@ -179,7 +217,7 @@ server.addTool({
179
217
  }
180
218
  }
181
219
  return parts.join("\n\n");
182
- }
220
+ })
183
221
  });
184
222
  server.addTool({
185
223
  name: "want",
@@ -189,11 +227,11 @@ server.addTool({
189
227
  source: z.string().describe("Gherkin feature source text for the goal"),
190
228
  testable: z.boolean().optional().default(false).describe("Whether this goal's scenarios should become persistent automated verification")
191
229
  }),
192
- execute: async ({ name, source, testable }) => {
230
+ execute: safeTool("want", async ({ name, source, testable }) => {
193
231
  const role = requireRole();
194
232
  const goal = role.want(name, source, testable);
195
- return `Goal created: ${goal.name}`;
196
- }
233
+ return next(`Goal created: ${goal.name}`, NEXT.want);
234
+ })
197
235
  });
198
236
  server.addTool({
199
237
  name: "plan",
@@ -201,11 +239,11 @@ server.addTool({
201
239
  parameters: z.object({
202
240
  source: z.string().describe("Gherkin feature source text for the plan")
203
241
  }),
204
- execute: async ({ source }) => {
242
+ execute: safeTool("plan", async ({ source }) => {
205
243
  const role = requireRole();
206
244
  const p = role.plan(source);
207
- return `Plan created: ${p.name}`;
208
- }
245
+ return next(`Plan created: ${p.name}`, NEXT.plan);
246
+ })
209
247
  });
210
248
  server.addTool({
211
249
  name: "todo",
@@ -215,11 +253,11 @@ server.addTool({
215
253
  source: z.string().describe("Gherkin feature source text for the task"),
216
254
  testable: z.boolean().optional().default(false).describe("Whether this task's scenarios should become unit or integration tests")
217
255
  }),
218
- execute: async ({ name, source, testable }) => {
256
+ execute: safeTool("todo", async ({ name, source, testable }) => {
219
257
  const role = requireRole();
220
258
  const task = role.todo(name, source, testable);
221
- return `Task created: ${task.name}`;
222
- }
259
+ return next(`Task created: ${task.name}`, NEXT.todo);
260
+ })
223
261
  });
224
262
  server.addTool({
225
263
  name: "achieve",
@@ -229,11 +267,12 @@ server.addTool({
229
267
  "Optional Gherkin feature source capturing what was learned \u2014 auto-saved as experience growup"
230
268
  )
231
269
  }),
232
- execute: async ({ experience }) => {
270
+ execute: safeTool("achieve", async ({ experience }) => {
233
271
  const role = requireRole();
234
272
  role.achieve(experience);
235
- return experience ? "Goal achieved. Experience captured." : "Goal achieved.";
236
- }
273
+ const msg = experience ? "Goal achieved. Experience captured." : "Goal achieved.";
274
+ return next(msg, NEXT.achieve);
275
+ })
237
276
  });
238
277
  server.addTool({
239
278
  name: "abandon",
@@ -243,11 +282,12 @@ server.addTool({
243
282
  "Optional Gherkin feature source capturing what was learned \u2014 auto-saved as experience growup"
244
283
  )
245
284
  }),
246
- execute: async ({ experience }) => {
285
+ execute: safeTool("abandon", async ({ experience }) => {
247
286
  const role = requireRole();
248
287
  role.abandon(experience);
249
- return experience ? "Goal abandoned. Experience captured." : "Goal abandoned.";
250
- }
288
+ const msg = experience ? "Goal abandoned. Experience captured." : "Goal abandoned.";
289
+ return next(msg, NEXT.abandon);
290
+ })
251
291
  });
252
292
  server.addTool({
253
293
  name: "reflect",
@@ -261,11 +301,14 @@ server.addTool({
261
301
  ),
262
302
  knowledgeSource: z.string().describe("Gherkin feature source text for the knowledge")
263
303
  }),
264
- execute: async ({ experienceNames, knowledgeName, knowledgeSource }) => {
304
+ execute: safeTool("reflect", async ({ experienceNames, knowledgeName, knowledgeSource }) => {
265
305
  const role = requireRole();
266
306
  const feature = role.reflect(experienceNames, knowledgeName, knowledgeSource);
267
- return `Reflected: ${experienceNames.length} experience(s) \u2192 knowledge "${feature.name}"`;
268
- }
307
+ return next(
308
+ `Reflected: ${experienceNames.length} experience(s) \u2192 knowledge "${feature.name}"`,
309
+ NEXT.reflect
310
+ );
311
+ })
269
312
  });
270
313
  server.addTool({
271
314
  name: "finish",
@@ -273,11 +316,13 @@ server.addTool({
273
316
  parameters: z.object({
274
317
  name: z.string().describe("Task name to mark as done")
275
318
  }),
276
- execute: async ({ name }) => {
319
+ execute: safeTool("finish", async ({ name }) => {
277
320
  const role = requireRole();
278
321
  role.finish(name);
279
- return `Task finished: ${name}`;
280
- }
322
+ const { current } = role.focus();
323
+ const remaining = current ? current.tasks.filter((t) => !t.tags?.some((tag) => tag.name === "@done")).length : -1;
324
+ return next(`Task finished: ${name}`, remaining >= 0 ? nextFinish(remaining) : NEXT.achieve);
325
+ })
281
326
  });
282
327
  server.start({
283
328
  transportType: "stdio"
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @rolexjs/mcp-server\n *\n * MCP server for Rolex — Role-Driven Development.\n *\n * Tools:\n * society — Admin: born, found, directory, find, teach\n * organization — Admin: hire, fire\n * identity — Activate a role\n * growup/focus/want/plan/todo/achieve/abandon/finish — Role lifecycle\n *\n * Usage:\n * rolex-mcp [.rolex-dir]\n */\n\nimport { FastMCP } from \"fastmcp\";\nimport { z } from \"zod\";\nimport {\n Rolex,\n Organization,\n Role,\n INSTRUCTIONS,\n DESC_SOCIETY,\n DESC_ORGANIZATION,\n DESC_GROWUP,\n DESC_IDENTITY,\n DESC_FOCUS,\n DESC_WANT,\n DESC_PLAN,\n DESC_TODO,\n DESC_ACHIEVE,\n DESC_ABANDON,\n DESC_REFLECT,\n DESC_FINISH,\n renderFeatures,\n renderFeature,\n bootstrap,\n} from \"rolexjs\";\nimport { LocalPlatform } from \"@rolexjs/local-platform\";\n\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nconst DEFAULT_ROLEX_DIR = join(homedir(), \".rolex\");\nconst rolexDir = process.argv[2] || process.env.ROLEX_DIR || DEFAULT_ROLEX_DIR;\nconst platform = new LocalPlatform(rolexDir);\nbootstrap(platform);\nconst rolex = new Rolex(platform);\nlet currentRole: Role | null = null;\n\nconst server = new FastMCP({\n name: \"Rolex MCP Server\",\n version: \"0.1.0\",\n instructions: INSTRUCTIONS,\n});\n\n// ========== Helpers ==========\n\nfunction requireRole(): Role {\n if (!currentRole) {\n throw new Error(\"No active role. Call identity(roleId) first to activate a role.\");\n }\n return currentRole;\n}\n\n// ========== Society (folded) ==========\n\nserver.addTool({\n name: \"society\",\n description: DESC_SOCIETY,\n parameters: z.object({\n operation: z\n .enum([\"born\", \"found\", \"directory\", \"find\", \"teach\"])\n .describe(\"The society operation to perform\"),\n name: z\n .string()\n .optional()\n .describe(\"Role name (born/find/teach) or organization name (found)\"),\n source: z\n .string()\n .optional()\n .describe(\"Gherkin feature source (born: persona, teach: knowledge)\"),\n roleId: z.string().optional().describe(\"Target role name for teach operation\"),\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .optional()\n .describe(\"Growth dimension for teach operation\"),\n dimensionName: z\n .string()\n .optional()\n .describe(\"Name for the knowledge being taught (e.g. 'distributed-systems')\"),\n }),\n execute: async ({ operation, name, source, roleId, type, dimensionName }) => {\n switch (operation) {\n case \"born\": {\n if (!name || !source) throw new Error(\"born requires: name, source\");\n const feature = rolex.born(name, source);\n return `Role born: ${feature.name}`;\n }\n case \"found\": {\n if (!name) throw new Error(\"found requires: name\");\n rolex.found(name);\n return `Organization founded: ${name}`;\n }\n case \"directory\": {\n const dir = rolex.directory();\n const lines: string[] = [];\n for (const entry of dir.organizations) {\n const orgInstance = rolex.find(entry.name) as Organization;\n const info = orgInstance.info();\n lines.push(`Organization: ${info.name}`);\n for (const role of info.roles) {\n lines.push(` - ${role.name} (team: ${role.team})`);\n }\n }\n return lines.join(\"\\n\") || \"No organizations found.\";\n }\n case \"find\": {\n if (!name) throw new Error(\"find requires: name\");\n const result = rolex.find(name);\n if (result instanceof Organization) {\n const info = result.info();\n return `Organization: ${info.name} (${info.roles.length} roles)`;\n }\n const features = (result as Role).identity();\n return renderFeatures(features);\n }\n case \"teach\": {\n if (!roleId || !type || !dimensionName || !source)\n throw new Error(\"teach requires: roleId, type, dimensionName, source\");\n const feature = rolex.teach(roleId, type, dimensionName, source);\n return `Taught ${type}: ${feature.name}`;\n }\n default:\n throw new Error(`Unknown society operation: ${operation}`);\n }\n },\n});\n\n// ========== Organization (folded) ==========\n\nserver.addTool({\n name: \"organization\",\n description: DESC_ORGANIZATION,\n parameters: z.object({\n operation: z.enum([\"hire\", \"fire\"]).describe(\"The organization operation to perform\"),\n name: z.string().describe(\"Role name to hire or fire\"),\n }),\n execute: async ({ operation, name }) => {\n const dir = rolex.directory();\n const org = rolex.find(dir.organizations[0].name) as Organization;\n\n switch (operation) {\n case \"hire\": {\n org.hire(name);\n return `Role hired: ${name}`;\n }\n case \"fire\": {\n org.fire(name);\n return `Role fired: ${name}`;\n }\n default:\n throw new Error(`Unknown organization operation: ${operation}`);\n }\n },\n});\n\n// ========== Role Activation ==========\n\nserver.addTool({\n name: \"identity\",\n description: DESC_IDENTITY,\n parameters: z.object({\n roleId: z.string().describe(\"Role name (e.g. 'sean')\"),\n }),\n execute: async ({ roleId }) => {\n currentRole = rolex.role(roleId);\n const features = currentRole.identity();\n return renderFeatures(features);\n },\n});\n\n// ========== Role Tools ==========\n\nserver.addTool({\n name: \"growup\",\n description: DESC_GROWUP,\n parameters: z.object({\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .describe(\n \"Growth dimension: knowledge (what I know), experience (what I've lived), voice (how I'm perceived)\"\n ),\n name: z\n .string()\n .describe(\"Name for this growth (used as filename, e.g. 'distributed-systems')\"),\n source: z.string().describe(\"Gherkin feature source text\"),\n }),\n execute: async ({ type, name, source }) => {\n const role = requireRole();\n const feature = role.growup(type, name, source);\n return `Growth added (${type}): ${feature.name}`;\n },\n});\n\nserver.addTool({\n name: \"focus\",\n description: DESC_FOCUS,\n parameters: z.object({\n name: z.string().optional().describe(\"Optional goal name to switch focus to\"),\n }),\n execute: async ({ name }) => {\n const role = requireRole();\n const { current, otherGoals } = role.focus(name);\n if (!current && otherGoals.length === 0) return \"No active goal. Use want() to set a new goal.\";\n\n const parts: string[] = [];\n\n if (current) {\n parts.push(renderFeature(current));\n if (current.plan) {\n parts.push(renderFeature(current.plan));\n }\n for (const task of current.tasks) {\n parts.push(renderFeature(task));\n }\n }\n\n if (otherGoals.length > 0) {\n parts.push(\"Other active goals:\");\n for (const g of otherGoals) {\n parts.push(` - ${g.name}`);\n }\n }\n\n return parts.join(\"\\n\\n\");\n },\n});\n\nserver.addTool({\n name: \"want\",\n description: DESC_WANT,\n parameters: z.object({\n name: z.string().describe(\"Goal name (used as directory name, e.g. 'local-platform')\"),\n source: z.string().describe(\"Gherkin feature source text for the goal\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this goal's scenarios should become persistent automated verification\"),\n }),\n execute: async ({ name, source, testable }) => {\n const role = requireRole();\n const goal = role.want(name, source, testable);\n return `Goal created: ${goal.name}`;\n },\n});\n\nserver.addTool({\n name: \"plan\",\n description: DESC_PLAN,\n parameters: z.object({\n source: z.string().describe(\"Gherkin feature source text for the plan\"),\n }),\n execute: async ({ source }) => {\n const role = requireRole();\n const p = role.plan(source);\n return `Plan created: ${p.name}`;\n },\n});\n\nserver.addTool({\n name: \"todo\",\n description: DESC_TODO,\n parameters: z.object({\n name: z.string().describe(\"Task name (used as filename, e.g. 'implement-loader')\"),\n source: z.string().describe(\"Gherkin feature source text for the task\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this task's scenarios should become unit or integration tests\"),\n }),\n execute: async ({ name, source, testable }) => {\n const role = requireRole();\n const task = role.todo(name, source, testable);\n return `Task created: ${task.name}`;\n },\n});\n\nserver.addTool({\n name: \"achieve\",\n description: DESC_ACHIEVE,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: async ({ experience }) => {\n const role = requireRole();\n role.achieve(experience);\n return experience ? \"Goal achieved. Experience captured.\" : \"Goal achieved.\";\n },\n});\n\nserver.addTool({\n name: \"abandon\",\n description: DESC_ABANDON,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: async ({ experience }) => {\n const role = requireRole();\n role.abandon(experience);\n return experience ? \"Goal abandoned. Experience captured.\" : \"Goal abandoned.\";\n },\n});\n\nserver.addTool({\n name: \"reflect\",\n description: DESC_REFLECT,\n parameters: z.object({\n experienceNames: z\n .array(z.string())\n .describe(\n \"Names of experience files to distill (without .experience.identity.feature suffix)\"\n ),\n knowledgeName: z\n .string()\n .describe(\n \"Name for the resulting knowledge (used as filename, e.g. 'authentication-principles')\"\n ),\n knowledgeSource: z.string().describe(\"Gherkin feature source text for the knowledge\"),\n }),\n execute: async ({ experienceNames, knowledgeName, knowledgeSource }) => {\n const role = requireRole();\n const feature = role.reflect(experienceNames, knowledgeName, knowledgeSource);\n return `Reflected: ${experienceNames.length} experience(s) → knowledge \"${feature.name}\"`;\n },\n});\n\nserver.addTool({\n name: \"finish\",\n description: DESC_FINISH,\n parameters: z.object({\n name: z.string().describe(\"Task name to mark as done\"),\n }),\n execute: async ({ name }) => {\n const role = requireRole();\n role.finish(name);\n return `Task finished: ${name}`;\n },\n});\n\nserver.start({\n transportType: \"stdio\",\n});\n"],"mappings":";;;AAeA,SAAS,eAAe;AACxB,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAE9B,SAAS,YAAY;AACrB,SAAS,eAAe;AAExB,IAAM,oBAAoB,KAAK,QAAQ,GAAG,QAAQ;AAClD,IAAM,WAAW,QAAQ,KAAK,CAAC,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O,EACP,SAAS,EACT;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AAAA,EACD,SAAS,OAAO,EAAE,WAAW,MAAM;AACjC,UAAM,OAAO,YAAY;AACzB,SAAK,QAAQ,UAAU;AACvB,WAAO,aAAa,yCAAyC;AAAA,EAC/D;AACF,CAAC;AAED,OAAO,QAAQ;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY,EAAE,OAAO;AAAA,IACnB,iBAAiB,EACd,MAAM,EAAE,OAAO,CAAC,EAChB;AAAA,MACC;AAAA,IACF;AAAA,IACF,eAAe,EACZ,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,iBAAiB,EAAE,OAAO,EAAE,SAAS,+CAA+C;AAAA,EACtF,CAAC;AAAA,EACD,SAAS,OAAO,EAAE,iBAAiB,eAAe,gBAAgB,MAAM;AACtE,UAAM,OAAO,YAAY;AACzB,UAAM,UAAU,KAAK,QAAQ,iBAAiB,eAAe,eAAe;AAC5E,WAAO,cAAc,gBAAgB,MAAM,oCAA+B,QAAQ,IAAI;AAAA,EACxF;AACF,CAAC;AAED,OAAO,QAAQ;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY,EAAE,OAAO;AAAA,IACnB,MAAM,EAAE,OAAO,EAAE,SAAS,2BAA2B;AAAA,EACvD,CAAC;AAAA,EACD,SAAS,OAAO,EAAE,KAAK,MAAM;AAC3B,UAAM,OAAO,YAAY;AACzB,SAAK,OAAO,IAAI;AAChB,WAAO,kBAAkB,IAAI;AAAA,EAC/B;AACF,CAAC;AAED,OAAO,MAAM;AAAA,EACX,eAAe;AACjB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @rolexjs/mcp-server\n *\n * MCP server for Rolex — Role-Driven Development.\n *\n * Tools:\n * society — Admin: born, found, directory, find, teach\n * organization — Admin: hire, fire\n * identity — Activate a role\n * growup/focus/want/plan/todo/achieve/abandon/finish — Role lifecycle\n *\n * Usage:\n * rolex-mcp [.rolex-dir]\n */\n\nimport { FastMCP } from \"fastmcp\";\nimport { z } from \"zod\";\nimport {\n Rolex,\n Organization,\n Role,\n INSTRUCTIONS,\n DESC_SOCIETY,\n DESC_ORGANIZATION,\n DESC_GROWUP,\n DESC_IDENTITY,\n DESC_FOCUS,\n DESC_WANT,\n DESC_PLAN,\n DESC_TODO,\n DESC_ACHIEVE,\n DESC_ABANDON,\n DESC_REFLECT,\n DESC_FINISH,\n renderFeatures,\n renderFeature,\n renderStatusBar,\n renderError,\n next,\n NEXT,\n nextHire,\n nextFinish,\n bootstrap,\n} from \"rolexjs\";\nimport { LocalPlatform } from \"@rolexjs/local-platform\";\n\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nconst DEFAULT_ROLEX_DIR = join(homedir(), \".rolex\");\nconst rolexDir = process.argv[2] || process.env.ROLEX_DIR || DEFAULT_ROLEX_DIR;\nconst platform = new LocalPlatform(rolexDir);\nbootstrap(platform);\nconst rolex = new Rolex(platform);\n\nlet currentRole: Role | null = null;\nlet currentRoleName: string = \"\";\n\nconst server = new FastMCP({\n name: \"Rolex MCP Server\",\n version: \"0.1.0\",\n instructions: INSTRUCTIONS,\n});\n\n// ========== Helpers ==========\n\nfunction requireRole(): Role {\n if (!currentRole) {\n throw new Error(\"No active role. Call identity(roleId) first to activate a role.\");\n }\n return currentRole;\n}\n\n/**\n * Wrap a tool execute function with unified error handling.\n * Catches errors and renders them as formatted markdown.\n */\nfunction safeTool<T>(\n toolName: string,\n fn: (args: T) => Promise<string>\n): (args: T) => Promise<string> {\n return async (args: T) => {\n try {\n return await fn(args);\n } catch (error) {\n throw new Error(renderError(toolName, error));\n }\n };\n}\n\n// ========== Society (folded) ==========\n\nserver.addTool({\n name: \"society\",\n description: DESC_SOCIETY,\n parameters: z.object({\n operation: z\n .enum([\"born\", \"found\", \"directory\", \"find\", \"teach\"])\n .describe(\"The society operation to perform\"),\n name: z\n .string()\n .optional()\n .describe(\"Role name (born/find/teach) or organization name (found)\"),\n source: z\n .string()\n .optional()\n .describe(\"Gherkin feature source (born: persona, teach: knowledge)\"),\n roleId: z.string().optional().describe(\"Target role name for teach operation\"),\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .optional()\n .describe(\"Growth dimension for teach operation\"),\n dimensionName: z\n .string()\n .optional()\n .describe(\"Name for the knowledge being taught (e.g. 'distributed-systems')\"),\n }),\n execute: safeTool(\"society\", async ({ operation, name, source, roleId, type, dimensionName }) => {\n switch (operation) {\n case \"born\": {\n if (!name || !source) throw new Error(\"born requires: name, source\");\n const feature = rolex.born(name, source);\n return next(`Role born: ${feature.name}`, NEXT.born);\n }\n case \"found\": {\n if (!name) throw new Error(\"found requires: name\");\n rolex.found(name);\n return next(`Organization founded: ${name}`, NEXT.found);\n }\n case \"directory\": {\n const dir = rolex.directory();\n const lines: string[] = [];\n\n // Organizations and their hired roles\n if (dir.organizations.length > 0) {\n for (const entry of dir.organizations) {\n const orgInstance = rolex.find(entry.name) as Organization;\n const info = orgInstance.info();\n lines.push(`Organization: ${info.name}`);\n for (const role of info.roles) {\n lines.push(` - ${role.name} (team: ${role.team})`);\n }\n }\n }\n\n // Unaffiliated roles (born but not hired)\n const unaffiliated = dir.roles.filter((r) => !r.team);\n if (unaffiliated.length > 0) {\n if (lines.length > 0) lines.push(\"\");\n lines.push(\"Roles:\");\n for (const role of unaffiliated) {\n lines.push(` - ${role.name}`);\n }\n }\n\n return lines.join(\"\\n\") || \"No roles or organizations found.\";\n }\n case \"find\": {\n if (!name) throw new Error(\"find requires: name\");\n const result = rolex.find(name);\n if (result instanceof Organization) {\n const info = result.info();\n return `Organization: ${info.name} (${info.roles.length} roles)`;\n }\n const features = (result as Role).identity();\n return renderFeatures(features);\n }\n case \"teach\": {\n if (!roleId || !type || !dimensionName || !source)\n throw new Error(\"teach requires: roleId, type, dimensionName, source\");\n const feature = rolex.teach(roleId, type, dimensionName, source);\n return next(`Taught ${type}: ${feature.name}`, NEXT.teach);\n }\n default:\n throw new Error(`Unknown society operation: ${operation}`);\n }\n }),\n});\n\n// ========== Organization (folded) ==========\n\nserver.addTool({\n name: \"organization\",\n description: DESC_ORGANIZATION,\n parameters: z.object({\n operation: z.enum([\"hire\", \"fire\"]).describe(\"The organization operation to perform\"),\n name: z.string().describe(\"Role name to hire or fire\"),\n }),\n execute: safeTool(\"organization\", async ({ operation, name }) => {\n const dir = rolex.directory();\n if (dir.organizations.length === 0) {\n throw new Error(\"No organization found. Call found() first.\");\n }\n const org = rolex.find(dir.organizations[0].name) as Organization;\n\n switch (operation) {\n case \"hire\": {\n org.hire(name);\n return next(`Role hired: ${name}`, nextHire(name));\n }\n case \"fire\": {\n org.fire(name);\n return next(`Role fired: ${name}`, NEXT.fire);\n }\n default:\n throw new Error(`Unknown organization operation: ${operation}`);\n }\n }),\n});\n\n// ========== Role Activation ==========\n\nserver.addTool({\n name: \"identity\",\n description: DESC_IDENTITY,\n parameters: z.object({\n roleId: z.string().describe(\"Role name (e.g. 'sean')\"),\n }),\n execute: safeTool(\"identity\", async ({ roleId }) => {\n currentRole = rolex.role(roleId);\n currentRoleName = roleId;\n const features = currentRole.identity();\n const { current } = currentRole.focus();\n const statusBar = renderStatusBar(roleId, current);\n return `${statusBar}\\n\\n${renderFeatures(features)}`;\n }),\n});\n\n// ========== Role Tools ==========\n\nserver.addTool({\n name: \"growup\",\n description: DESC_GROWUP,\n parameters: z.object({\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .describe(\n \"Growth dimension: knowledge (what I know), experience (what I've lived), voice (how I'm perceived)\"\n ),\n name: z\n .string()\n .describe(\"Name for this growth (used as filename, e.g. 'distributed-systems')\"),\n source: z.string().describe(\"Gherkin feature source text\"),\n }),\n execute: safeTool(\"growup\", async ({ type, name, source }) => {\n const role = requireRole();\n const feature = role.growup(type, name, source);\n return next(`Growth added (${type}): ${feature.name}`, NEXT.growup);\n }),\n});\n\nserver.addTool({\n name: \"focus\",\n description: DESC_FOCUS,\n parameters: z.object({\n name: z.string().optional().describe(\"Optional goal name to switch focus to\"),\n }),\n execute: safeTool(\"focus\", async ({ name }) => {\n const role = requireRole();\n const { current, otherGoals } = role.focus(name);\n\n const statusBar = renderStatusBar(currentRoleName, current);\n\n if (!current && otherGoals.length === 0)\n return `${statusBar}\\n\\nNo active goal. Use want() to set a new goal.`;\n\n const parts: string[] = [statusBar];\n\n if (current) {\n parts.push(renderFeature(current));\n if (current.plan) {\n parts.push(renderFeature(current.plan));\n }\n for (const task of current.tasks) {\n parts.push(renderFeature(task));\n }\n }\n\n if (otherGoals.length > 0) {\n parts.push(\"Other active goals:\");\n for (const g of otherGoals) {\n parts.push(` - ${g.name}`);\n }\n }\n\n return parts.join(\"\\n\\n\");\n }),\n});\n\nserver.addTool({\n name: \"want\",\n description: DESC_WANT,\n parameters: z.object({\n name: z.string().describe(\"Goal name (used as directory name, e.g. 'local-platform')\"),\n source: z.string().describe(\"Gherkin feature source text for the goal\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this goal's scenarios should become persistent automated verification\"),\n }),\n execute: safeTool(\"want\", async ({ name, source, testable }) => {\n const role = requireRole();\n const goal = role.want(name, source, testable);\n return next(`Goal created: ${goal.name}`, NEXT.want);\n }),\n});\n\nserver.addTool({\n name: \"plan\",\n description: DESC_PLAN,\n parameters: z.object({\n source: z.string().describe(\"Gherkin feature source text for the plan\"),\n }),\n execute: safeTool(\"plan\", async ({ source }) => {\n const role = requireRole();\n const p = role.plan(source);\n return next(`Plan created: ${p.name}`, NEXT.plan);\n }),\n});\n\nserver.addTool({\n name: \"todo\",\n description: DESC_TODO,\n parameters: z.object({\n name: z.string().describe(\"Task name (used as filename, e.g. 'implement-loader')\"),\n source: z.string().describe(\"Gherkin feature source text for the task\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this task's scenarios should become unit or integration tests\"),\n }),\n execute: safeTool(\"todo\", async ({ name, source, testable }) => {\n const role = requireRole();\n const task = role.todo(name, source, testable);\n return next(`Task created: ${task.name}`, NEXT.todo);\n }),\n});\n\nserver.addTool({\n name: \"achieve\",\n description: DESC_ACHIEVE,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: safeTool(\"achieve\", async ({ experience }) => {\n const role = requireRole();\n role.achieve(experience);\n const msg = experience ? \"Goal achieved. Experience captured.\" : \"Goal achieved.\";\n return next(msg, NEXT.achieve);\n }),\n});\n\nserver.addTool({\n name: \"abandon\",\n description: DESC_ABANDON,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: safeTool(\"abandon\", async ({ experience }) => {\n const role = requireRole();\n role.abandon(experience);\n const msg = experience ? \"Goal abandoned. Experience captured.\" : \"Goal abandoned.\";\n return next(msg, NEXT.abandon);\n }),\n});\n\nserver.addTool({\n name: \"reflect\",\n description: DESC_REFLECT,\n parameters: z.object({\n experienceNames: z\n .array(z.string())\n .describe(\n \"Names of experience files to distill (without .experience.identity.feature suffix)\"\n ),\n knowledgeName: z\n .string()\n .describe(\n \"Name for the resulting knowledge (used as filename, e.g. 'authentication-principles')\"\n ),\n knowledgeSource: z.string().describe(\"Gherkin feature source text for the knowledge\"),\n }),\n execute: safeTool(\"reflect\", async ({ experienceNames, knowledgeName, knowledgeSource }) => {\n const role = requireRole();\n const feature = role.reflect(experienceNames, knowledgeName, knowledgeSource);\n return next(\n `Reflected: ${experienceNames.length} experience(s) → knowledge \"${feature.name}\"`,\n NEXT.reflect\n );\n }),\n});\n\nserver.addTool({\n name: \"finish\",\n description: DESC_FINISH,\n parameters: z.object({\n name: z.string().describe(\"Task name to mark as done\"),\n }),\n execute: safeTool(\"finish\", async ({ name }) => {\n const role = requireRole();\n role.finish(name);\n\n // Dynamic hint: check remaining tasks\n const { current } = role.focus();\n const remaining = current\n ? current.tasks.filter((t) => !t.tags?.some((tag) => tag.name === \"@done\")).length\n : -1;\n return next(`Task finished: ${name}`, remaining >= 0 ? nextFinish(remaining) : NEXT.achieve);\n }),\n});\n\nserver.start({\n transportType: \"stdio\",\n});\n"],"mappings":";;;AAeA,SAAS,eAAe;AACxB,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAE9B,SAAS,YAAY;AACrB,SAAS,eAAe;AAExB,IAAM,oBAAoB,KAAK,QAAQ,GAAG,QAAQ;AAClD,IAAM,WAAW,QAAQ,KAAK,CAAC,KAAK,QAAQ,IAAI,aAAa;AAC7D,IAAM,WAAW,IAAI,cAAc,QAAQ;AAC3C,UAAU,QAAQ;AAClB,IAAM,QAAQ,IAAI,MAAM,QAAQ;AAEhC,IAAI,cAA2B;AAC/B,IAAI,kBAA0B;AAE9B,IAAM,SAAS,IAAI,QAAQ;AAAA,EACzB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,cAAc;AAChB,CAAC;AAID,SAAS,cAAoB;AAC3B,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AACA,SAAO;AACT;AAMA,SAAS,SACP,UACA,IAC8B;AAC9B,SAAO,OAAO,SAAY;AACxB,QAAI;AACF,aAAO,MAAM,GAAG,IAAI;AAAA,IACtB,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,YAAY,UAAU,KAAK,CAAC;AAAA,IAC9C;AAAA,EACF;AACF;AAIA,OAAO,QAAQ;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YA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MAAM;AAC1F,UAAM,OAAO,YAAY;AACzB,UAAM,UAAU,KAAK,QAAQ,iBAAiB,eAAe,eAAe;AAC5E,WAAO;AAAA,MACL,cAAc,gBAAgB,MAAM,oCAA+B,QAAQ,IAAI;AAAA,MAC/E,KAAK;AAAA,IACP;AAAA,EACF,CAAC;AACH,CAAC;AAED,OAAO,QAAQ;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY,EAAE,OAAO;AAAA,IACnB,MAAM,EAAE,OAAO,EAAE,SAAS,2BAA2B;AAAA,EACvD,CAAC;AAAA,EACD,SAAS,SAAS,UAAU,OAAO,EAAE,KAAK,MAAM;AAC9C,UAAM,OAAO,YAAY;AACzB,SAAK,OAAO,IAAI;AAGhB,UAAM,EAAE,QAAQ,IAAI,KAAK,MAAM;AAC/B,UAAM,YAAY,UACd,QAAQ,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,QAAQ,IAAI,SAAS,OAAO,CAAC,EAAE,SAC1E;AACJ,WAAO,KAAK,kBAAkB,IAAI,IAAI,aAAa,IAAI,WAAW,SAAS,IAAI,KAAK,OAAO;AAAA,EAC7F,CAAC;AACH,CAAC;AAED,OAAO,MAAM;AAAA,EACX,eAAe;AACjB,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolexjs/mcp-server",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "MCP server for Rolex — expose RDD role management as MCP tools",
5
5
  "keywords": [
6
6
  "rolex",
@@ -41,8 +41,8 @@
41
41
  "clean": "rm -rf dist"
42
42
  },
43
43
  "dependencies": {
44
- "rolexjs": "^0.6.0",
45
- "@rolexjs/local-platform": "^0.6.0",
44
+ "rolexjs": "^0.8.0",
45
+ "@rolexjs/local-platform": "^0.8.0",
46
46
  "fastmcp": "^3.0.0",
47
47
  "zod": "^3.25.0"
48
48
  },