@rolexjs/core 1.5.0 → 1.6.1

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
@@ -1,14 +1,14 @@
1
1
  // src/index.ts
2
2
  import {
3
- create as create6,
3
+ create as create5,
4
4
  createRuntime,
5
- link as link4,
5
+ link as link3,
6
6
  process as process7,
7
7
  relation as relation2,
8
8
  remove,
9
- structure as structure3,
9
+ structure as structure2,
10
10
  transform as transform4,
11
- unlink as unlink4
11
+ unlink as unlink3
12
12
  } from "@rolexjs/system";
13
13
 
14
14
  // src/structures.ts
@@ -39,7 +39,6 @@ var requirement = structure("requirement", "Required skill for this position", p
39
39
  var project = structure("project", "A process container for organized work", society, [
40
40
  relation("participation", "Who participates in this project", individual),
41
41
  relation("ownership", "Which organization owns this project", organization)
42
- // production → product is a forward declaration; product is defined below
43
42
  ]);
44
43
  var scope = structure(
45
44
  "scope",
@@ -53,34 +52,9 @@ var milestone = structure(
53
52
  );
54
53
  var deliverable = structure("deliverable", "Project output and delivery", project);
55
54
  var wiki = structure("wiki", "Project-level knowledge base entry", project);
56
- var product = structure(
57
- "product",
58
- "A product with vision, contracts, and releases",
59
- society,
60
- [
61
- relation("ownership", "Who owns this product", individual),
62
- relation("origin", "Which project produced this product", project)
63
- ]
64
- );
65
- var strategy = structure("strategy", "Product strategy \u2014 how to win", product);
66
- var spec = structure("spec", "Product behavior contract \u2014 BDD specification", product);
67
- var release = structure("release", "Product version release", product);
68
- var channel = structure("channel", "Product distribution channel", product);
69
- var issue = structure("issue", "A collaboration topic requiring attention", society, [
70
- relation("authored-by", "Who created this issue", individual),
71
- relation("assigned-to", "Who is responsible for this issue", individual)
72
- ]);
73
- var comment = structure("comment", "A discussion entry on an issue", issue, [
74
- relation("authored-by", "Who wrote this comment", individual)
75
- ]);
76
55
 
77
56
  // src/execution.ts
78
57
  import { create, process, transform } from "@rolexjs/system";
79
- var activate = process(
80
- "activate",
81
- "Activate a role \u2014 load cognition into context",
82
- individual
83
- );
84
58
  var want = process("want", "Declare a goal", individual, create(goal));
85
59
  var planGoal = process("plan", "Create a plan for a goal", goal, create(plan));
86
60
  var todo = process("todo", "Create a task in a plan", plan, create(task));
@@ -191,3344 +165,76 @@ var deliverProject = process4(
191
165
  create3(deliverable)
192
166
  );
193
167
  var wikiProject = process4("wiki", "Add a wiki entry to a project", project, create3(wiki));
194
- var produceProject = process4(
195
- "produce",
196
- "Produce a product from this project",
197
- project,
198
- create3(product)
199
- );
200
-
201
- // src/product.ts
202
- import { create as create4, link as link3, process as process5, unlink as unlink3 } from "@rolexjs/system";
203
- var ownProduct = process5(
204
- "own",
205
- "Assign an owner to the product",
206
- product,
207
- link3(product, "ownership")
208
- );
209
- var disownProduct = process5(
210
- "disown",
211
- "Remove an owner from the product",
212
- product,
213
- unlink3(product, "ownership")
214
- );
215
- var strategyProduct = process5(
216
- "strategy",
217
- "Define the strategy for a product",
218
- product,
219
- create4(strategy)
220
- );
221
- var specProduct = process5(
222
- "spec",
223
- "Add a behavior contract to a product",
224
- product,
225
- create4(spec)
226
- );
227
- var releaseProduct = process5(
228
- "release",
229
- "Add a version release to a product",
230
- product,
231
- create4(release)
232
- );
233
- var channelProduct = process5(
234
- "channel",
235
- "Add a distribution channel to a product",
236
- product,
237
- create4(channel)
238
- );
239
168
 
240
169
  // src/lifecycle.ts
241
- import { create as create5, process as process6, transform as transform3 } from "@rolexjs/system";
242
- var born = process6(
170
+ import { create as create4, process as process5, transform as transform3 } from "@rolexjs/system";
171
+ var born = process5(
243
172
  "born",
244
173
  "An individual is born into society",
245
174
  society,
246
- create5(individual)
175
+ create4(individual)
247
176
  );
248
- var found = process6("found", "Found an organization", society, create5(organization));
249
- var establish = process6("establish", "Establish a position", society, create5(position));
250
- var launch = process6("launch", "Launch a project", society, create5(project));
251
- var retire = process6(
177
+ var found = process5("found", "Found an organization", society, create4(organization));
178
+ var establish = process5("establish", "Establish a position", society, create4(position));
179
+ var launch = process5("launch", "Launch a project", society, create4(project));
180
+ var retire = process5(
252
181
  "retire",
253
182
  "Retire an individual",
254
183
  individual,
255
184
  transform3(individual, past)
256
185
  );
257
- var die = process6("die", "An individual dies", individual, transform3(individual, past));
258
- var archive = process6("archive", "Archive a project", project, transform3(project, past));
259
- var deprecate = process6(
260
- "deprecate",
261
- "Deprecate a product",
262
- product,
263
- transform3(product, past)
264
- );
265
- var dissolve = process6(
186
+ var die = process5("die", "An individual dies", individual, transform3(individual, past));
187
+ var archive = process5("archive", "Archive a project", project, transform3(project, past));
188
+ var dissolve = process5(
266
189
  "dissolve",
267
190
  "Dissolve an organization",
268
191
  organization,
269
192
  transform3(organization, past)
270
193
  );
271
- var abolish = process6(
194
+ var abolish = process5(
272
195
  "abolish",
273
196
  "Abolish a position",
274
197
  position,
275
198
  transform3(position, past)
276
199
  );
277
- var rehire = process6(
200
+ var rehire = process5(
278
201
  "rehire",
279
202
  "Rehire a retired individual",
280
203
  past,
281
204
  transform3(past, individual)
282
205
  );
283
206
 
284
- // src/role-model.ts
285
- var Role = class {
286
- id;
287
- focusedGoalId = null;
288
- focusedPlanId = null;
289
- encounterIds = /* @__PURE__ */ new Set();
290
- experienceIds = /* @__PURE__ */ new Set();
291
- /** Set of all node ids under this individual — for ownership validation. */
292
- nodeIds = /* @__PURE__ */ new Set();
293
- deps;
294
- constructor(id, deps) {
295
- this.id = id;
296
- this.deps = deps;
297
- }
298
- // ================================================================
299
- // State projection — populated at activate time
300
- // ================================================================
301
- /** Populate from state projection. Builds nodeIds set + cognitive registries. */
302
- hydrate(state) {
303
- this.nodeIds.clear();
304
- this.encounterIds.clear();
305
- this.experienceIds.clear();
306
- this.focusedGoalId = null;
307
- this.walkState(state);
308
- }
309
- walkState(node) {
310
- if (node.id) {
311
- this.nodeIds.add(node.id);
312
- switch (node.name) {
313
- case "goal":
314
- if (!this.focusedGoalId) this.focusedGoalId = node.id;
315
- break;
316
- case "encounter":
317
- this.encounterIds.add(node.id);
318
- break;
319
- case "experience":
320
- this.experienceIds.add(node.id);
321
- break;
322
- }
323
- }
324
- for (const child of node.children ?? []) {
325
- this.walkState(child);
326
- }
327
- }
328
- // ================================================================
329
- // Ownership validation
330
- // ================================================================
331
- hasNode(id) {
332
- return this.nodeIds.has(id);
333
- }
334
- requireOwnership(id, label) {
335
- if (!this.hasNode(id)) {
336
- throw new Error(`${label} "${id}" does not belong to individual "${this.id}".`);
337
- }
338
- }
339
- // ================================================================
340
- // Cursor requirements
341
- // ================================================================
342
- requireGoalId() {
343
- if (!this.focusedGoalId) throw new Error("No focused goal. Call want first.");
344
- return this.focusedGoalId;
345
- }
346
- requirePlanId() {
347
- if (!this.focusedPlanId) throw new Error("No focused plan. Call plan first.");
348
- return this.focusedPlanId;
349
- }
350
- // ================================================================
351
- // Rendering
352
- // ================================================================
353
- fmt(command, result) {
354
- const rendered = this.deps.renderer.render(command, result);
355
- const process8 = command.includes(".") ? command.slice(command.indexOf(".") + 1) : command;
356
- const ch = this.cognitiveHint(process8);
357
- if (!ch) return rendered;
358
- const lines = rendered.split("\n");
359
- lines.splice(2, 0, `I \u2192 ${ch}`);
360
- return lines.join("\n");
361
- }
362
- // ================================================================
363
- // Persistence
364
- // ================================================================
365
- async save() {
366
- await this.deps.onSave(this.snapshot());
367
- }
368
- /** Serialize to KV-compatible snapshot. */
369
- snapshot() {
370
- return {
371
- id: this.id,
372
- focusedGoalId: this.focusedGoalId,
373
- focusedPlanId: this.focusedPlanId,
374
- encounterIds: [...this.encounterIds],
375
- experienceIds: [...this.experienceIds]
376
- };
377
- }
378
- /** Restore cursors and cognitive state from a snapshot. */
379
- restore(snap) {
380
- this.focusedGoalId = snap.focusedGoalId;
381
- this.focusedPlanId = snap.focusedPlanId;
382
- this.encounterIds.clear();
383
- for (const id of snap.encounterIds) this.encounterIds.add(id);
384
- this.experienceIds.clear();
385
- for (const id of snap.experienceIds) this.experienceIds.add(id);
386
- }
387
- // ================================================================
388
- // Execution — focus, want, plan, todo, finish, complete, abandon
389
- // ================================================================
390
- /** Project the individual's state tree (used after activate). */
391
- async project() {
392
- const result = await this.deps.commands["role.focus"](this.id);
393
- return this.fmt("role.activate", result);
394
- }
395
- /** Focus: view or switch focused goal. Validates ownership. */
396
- async focus(goal2) {
397
- const goalId = goal2 ?? this.requireGoalId();
398
- if (goal2) {
399
- this.requireOwnership(goalId, "Goal");
400
- }
401
- const result = await this.deps.commands["role.focus"](goalId);
402
- if (result.state.name !== "goal") {
403
- throw new Error(
404
- `"${goalId}" is a ${result.state.name}, not a goal. focus only accepts goal ids.`
405
- );
406
- }
407
- const switched = goalId !== this.focusedGoalId;
408
- this.focusedGoalId = goalId;
409
- if (switched) this.focusedPlanId = null;
410
- await this.save();
411
- return this.fmt("role.focus", result);
412
- }
413
- /** Want: declare a goal under this individual. */
414
- async want(goal2, id, alias) {
415
- const result = await this.deps.commands["role.want"](this.id, goal2, id, alias);
416
- const newId = id ?? result.state.id;
417
- if (newId) {
418
- this.nodeIds.add(newId);
419
- this.focusedGoalId = newId;
420
- }
421
- this.focusedPlanId = null;
422
- await this.save();
423
- return this.fmt("role.want", result);
424
- }
425
- /** Plan: create a plan for the focused goal. */
426
- async plan(plan2, id, after, fallback) {
427
- const result = await this.deps.commands["role.plan"](
428
- this.requireGoalId(),
429
- plan2,
430
- id,
431
- after,
432
- fallback
433
- );
434
- const newId = id ?? result.state.id;
435
- if (newId) {
436
- this.nodeIds.add(newId);
437
- this.focusedPlanId = newId;
438
- }
439
- await this.save();
440
- return this.fmt("role.plan", result);
441
- }
442
- /** Todo: add a task to the focused plan. */
443
- async todo(task2, id, alias) {
444
- const result = await this.deps.commands["role.todo"](this.requirePlanId(), task2, id, alias);
445
- const newId = id ?? result.state.id;
446
- if (newId) this.nodeIds.add(newId);
447
- return this.fmt("role.todo", result);
448
- }
449
- /** Finish: complete a task, optionally record an encounter. */
450
- async finish(task2, encounter2) {
451
- this.requireOwnership(task2, "Task");
452
- const result = await this.deps.commands["role.finish"](task2, this.id, encounter2);
453
- if (encounter2 && result.state.id) {
454
- this.encounterIds.add(result.state.id);
455
- this.nodeIds.add(result.state.id);
456
- }
457
- return this.fmt("role.finish", result);
458
- }
459
- /** Complete: close a plan as done, record encounter. */
460
- async complete(plan2, encounter2) {
461
- const planId = plan2 ?? this.requirePlanId();
462
- this.requireOwnership(planId, "Plan");
463
- const result = await this.deps.commands["role.complete"](planId, this.id, encounter2);
464
- const encId = result.state.id ?? planId;
465
- this.encounterIds.add(encId);
466
- this.nodeIds.add(encId);
467
- if (this.focusedPlanId === planId) this.focusedPlanId = null;
468
- await this.save();
469
- return this.fmt("role.complete", result);
470
- }
471
- /** Abandon: drop a plan, record encounter. */
472
- async abandon(plan2, encounter2) {
473
- const planId = plan2 ?? this.requirePlanId();
474
- this.requireOwnership(planId, "Plan");
475
- const result = await this.deps.commands["role.abandon"](planId, this.id, encounter2);
476
- const encId = result.state.id ?? planId;
477
- this.encounterIds.add(encId);
478
- this.nodeIds.add(encId);
479
- if (this.focusedPlanId === planId) this.focusedPlanId = null;
480
- await this.save();
481
- return this.fmt("role.abandon", result);
482
- }
483
- // ================================================================
484
- // Cognition — reflect, realize, master
485
- // ================================================================
486
- /** Reflect: consume encounters → experience. */
487
- async reflect(encounters, experience2, id) {
488
- if (encounters.length > 0) {
489
- for (const enc of encounters) {
490
- if (!this.encounterIds.has(enc)) throw new Error(`Encounter not found: "${enc}"`);
491
- }
492
- }
493
- const first = encounters[0];
494
- const result = await this.deps.commands["role.reflect"](first, this.id, experience2, id);
495
- for (let i = 1; i < encounters.length; i++) {
496
- await this.deps.commands["role.forget"](encounters[i]);
497
- }
498
- if (encounters.length > 0) {
499
- for (const enc of encounters) this.encounterIds.delete(enc);
500
- }
501
- const newId = id ?? result.state.id;
502
- if (newId) {
503
- this.experienceIds.add(newId);
504
- this.nodeIds.add(newId);
505
- }
506
- return this.fmt("role.reflect", result);
507
- }
508
- /** Realize: consume experiences → principle. */
509
- async realize(experiences, principle2, id) {
510
- if (experiences.length > 0) {
511
- for (const exp of experiences) {
512
- if (!this.experienceIds.has(exp)) throw new Error(`Experience not found: "${exp}"`);
513
- }
514
- }
515
- const first = experiences[0];
516
- const result = await this.deps.commands["role.realize"](first, this.id, principle2, id);
517
- for (let i = 1; i < experiences.length; i++) {
518
- await this.deps.commands["role.forget"](experiences[i]);
519
- }
520
- if (experiences.length > 0) {
521
- for (const exp of experiences) this.experienceIds.delete(exp);
522
- }
523
- const newId = id ?? result.state.id;
524
- if (newId) this.nodeIds.add(newId);
525
- return this.fmt("role.realize", result);
526
- }
527
- /** Master: create procedure, optionally consuming experiences. */
528
- async master(procedure2, id, experiences) {
529
- if (experiences && experiences.length > 0) {
530
- for (const exp of experiences) {
531
- if (!this.experienceIds.has(exp)) throw new Error(`Experience not found: "${exp}"`);
532
- }
533
- }
534
- const first = experiences?.[0];
535
- const result = await this.deps.commands["role.master"](this.id, procedure2, id, first);
536
- if (experiences) {
537
- for (let i = 1; i < experiences.length; i++) {
538
- await this.deps.commands["role.forget"](experiences[i]);
539
- }
540
- for (const exp of experiences) this.experienceIds.delete(exp);
541
- }
542
- const newId = id ?? result.state.id;
543
- if (newId) this.nodeIds.add(newId);
544
- return this.fmt("role.master", result);
545
- }
546
- // ================================================================
547
- // Knowledge management
548
- // ================================================================
549
- /** Forget: remove any node under this individual by id. */
550
- async forget(nodeId) {
551
- this.requireOwnership(nodeId, "Node");
552
- const result = await this.deps.commands["role.forget"](nodeId);
553
- this.nodeIds.delete(nodeId);
554
- if (this.focusedGoalId === nodeId) this.focusedGoalId = null;
555
- if (this.focusedPlanId === nodeId) this.focusedPlanId = null;
556
- this.encounterIds.delete(nodeId);
557
- this.experienceIds.delete(nodeId);
558
- await this.save();
559
- return this.fmt("role.forget", result);
560
- }
561
- // ================================================================
562
- // Cognitive hints
563
- // ================================================================
564
- cognitiveHint(process8) {
565
- switch (process8) {
566
- case "activate":
567
- if (!this.focusedGoalId)
568
- return "I have no goal yet. I should call `want` to declare one, or `focus` to review existing goals.";
569
- return "I have an active goal. I should call `focus` to review progress, or `want` to declare a new goal.";
570
- case "focus":
571
- if (!this.focusedPlanId)
572
- return "I have a goal but no focused plan. I should call `plan` to create or focus on one.";
573
- return "I have a plan. I should call `todo` to create tasks, or continue working.";
574
- case "want":
575
- return "Goal declared. I should call `plan` to design how to achieve it.";
576
- case "plan":
577
- return "Plan created. I should call `todo` to create concrete tasks.";
578
- case "todo":
579
- return "Task created. I can add more with `todo`, or start working and call `finish` when done.";
580
- case "finish": {
581
- const encCount = this.encounterIds.size;
582
- if (encCount > 0 && !this.focusedGoalId)
583
- return `Task finished. No more goals \u2014 I have ${encCount} encounter(s) to choose from for \`reflect\`, or \`want\` a new goal.`;
584
- return "Task finished. I should continue with remaining tasks, or call `complete` when the plan is done.";
585
- }
586
- case "complete":
587
- case "abandon": {
588
- const encCount = this.encounterIds.size;
589
- const goalNote = this.focusedGoalId ? ` I should check if goal "${this.focusedGoalId}" needs a new \`plan\`, or \`forget\` it if the direction is fulfilled.` : "";
590
- if (encCount > 0)
591
- return `Plan closed.${goalNote} I have ${encCount} encounter(s) to choose from for \`reflect\`, or I can continue with other plans.`;
592
- return `Plan closed.${goalNote} I can create a new \`plan\`, or \`focus\` on another goal.`;
593
- }
594
- case "reflect": {
595
- const expCount = this.experienceIds.size;
596
- if (expCount > 0)
597
- return `Experience gained. I can \`realize\` principles or \`master\` procedures \u2014 ${expCount} experience(s) available.`;
598
- return "Experience gained. I can `realize` a principle, `master` a procedure, or continue working.";
599
- }
600
- case "realize":
601
- return "Principle added. I should continue working.";
602
- case "master":
603
- return "Procedure added. I should continue working.";
604
- default:
605
- return null;
606
- }
607
- }
608
- };
609
-
610
- // src/apply.ts
611
- async function applyPrototype(data, repo, direct) {
612
- const sorted = [...data.migrations].sort((a, b) => a.version - b.version);
613
- let applied = 0;
614
- let skipped = 0;
615
- for (const migration of sorted) {
616
- if (await repo.hasMigration(data.id, migration.id)) {
617
- skipped++;
618
- continue;
619
- }
620
- for (const instr of migration.instructions) {
621
- await direct(instr.op, instr.args);
622
- }
623
- await repo.recordMigration(data.id, migration.id, migration.version, migration.checksum);
624
- applied++;
625
- }
626
- await repo.settle(data.id, data.source);
627
- return {
628
- prototypeId: data.id,
629
- applied,
630
- skipped,
631
- upToDate: applied === 0
632
- };
633
- }
634
-
635
- // src/commands/helpers.ts
636
- import { parse } from "@rolexjs/parser";
637
- import { structure as structure2 } from "@rolexjs/system";
638
- function findInState(state, target) {
639
- if (state.id && state.id.toLowerCase() === target) return state;
640
- if (state.alias) {
641
- for (const a of state.alias) {
642
- if (a.toLowerCase() === target) return state;
643
- }
644
- }
645
- for (const child of state.children ?? []) {
646
- const found2 = findInState(child, target);
647
- if (found2) return found2;
648
- }
649
- return null;
650
- }
651
- function createHelpers(ctx) {
652
- const { rt, project: project2 } = ctx;
653
- async function ok2(node, process8) {
654
- return { state: await project2(node), process: process8 };
655
- }
656
- async function archive2(node, process8) {
657
- const target = structure2(node.name, node.description ?? "", past);
658
- const archived = await rt.transform(node, target);
659
- return ok2(archived, process8);
660
- }
661
- function validateGherkin(source) {
662
- if (!source) return;
663
- try {
664
- parse(source);
665
- } catch (e) {
666
- throw new Error(`Invalid Gherkin: ${e.message}`);
667
- }
668
- }
669
- async function removeExisting(parent, id) {
670
- const state = await rt.project(parent);
671
- const existing = findInState(state, id);
672
- if (existing) await rt.remove(existing);
673
- }
674
- return { ok: ok2, archive: archive2, validateGherkin, removeExisting };
675
- }
676
-
677
- // src/commands/issue.ts
678
- var nextIssueNumber = 0;
679
- function initCounter(children) {
680
- let max = 0;
681
- for (const child of children) {
682
- if (child.name === "issue" && child.id) {
683
- const match = child.id.match(/^issue-(\d+)$/);
684
- if (match) {
685
- const n = parseInt(match[1], 10);
686
- if (n > max) max = n;
687
- }
688
- }
689
- }
690
- nextIssueNumber = max;
691
- }
692
- function allocateNumber() {
693
- return ++nextIssueNumber;
694
- }
695
- function issueCommands(ctx, helpers) {
696
- const { rt, society: society2, resolve, project: project2 } = ctx;
697
- const { ok: ok2 } = helpers;
698
- let counterInitialized = false;
699
- async function ensureCounter() {
700
- if (counterInitialized) return;
701
- const state = await rt.project(society2);
702
- initCounter(state.children ?? []);
703
- counterInitialized = true;
704
- }
705
- async function findIssue(number) {
706
- const id = `issue-${number}`;
707
- const node = await resolve(id);
708
- return node;
709
- }
710
- return {
711
- async "issue.publish"(title, body, author, assignee) {
712
- await ensureCounter();
713
- const number = allocateNumber();
714
- const id = `issue-${number}`;
715
- const node = await rt.create(society2, issue, body, id, [title]);
716
- await rt.addTag(node, "open");
717
- const authorNode = await resolve(author);
718
- await rt.link(node, authorNode, "authored-by", "author-of");
719
- if (assignee) {
720
- const assigneeNode = await resolve(assignee);
721
- await rt.link(node, assigneeNode, "assigned-to", "assigned");
722
- }
723
- return ok2(node, "publish");
724
- },
725
- async "issue.get"(number) {
726
- const node = await findIssue(number);
727
- return ok2(node, "get");
728
- },
729
- async "issue.list"(status, _author, _assignee, _label) {
730
- const state = await project2(society2);
731
- const issues = (state.children ?? []).filter((c) => {
732
- if (c.name !== "issue") return false;
733
- if (status && !c.tags?.includes(status)) return false;
734
- return true;
735
- });
736
- return {
737
- state: { ...state, children: issues },
738
- process: "list"
739
- };
740
- },
741
- async "issue.update"(number, title, body, assignee) {
742
- const node = await findIssue(number);
743
- if (body !== void 0 || title !== void 0) {
744
- const target = issue;
745
- if (body !== void 0) {
746
- await rt.transform(node, target, body);
747
- }
748
- }
749
- if (assignee !== void 0) {
750
- const state = await rt.project(node);
751
- const existingAssignee = state.links?.find((l) => l.relation === "assigned-to");
752
- if (existingAssignee) {
753
- await rt.unlink(node, existingAssignee.target, "assigned-to", "assigned");
754
- }
755
- if (assignee) {
756
- const assigneeNode = await resolve(assignee);
757
- await rt.link(node, assigneeNode, "assigned-to", "assigned");
758
- }
759
- }
760
- return ok2(node, "update");
761
- },
762
- async "issue.close"(number) {
763
- const node = await findIssue(number);
764
- await rt.removeTag(node, "open");
765
- await rt.addTag(node, "closed");
766
- return ok2(node, "close");
767
- },
768
- async "issue.reopen"(number) {
769
- const node = await findIssue(number);
770
- await rt.removeTag(node, "closed");
771
- await rt.addTag(node, "open");
772
- return ok2(node, "reopen");
773
- },
774
- async "issue.assign"(number, assignee) {
775
- const node = await findIssue(number);
776
- const state = await rt.project(node);
777
- const existingAssignee = state.links?.find((l) => l.relation === "assigned-to");
778
- if (existingAssignee) {
779
- await rt.unlink(node, existingAssignee.target, "assigned-to", "assigned");
780
- }
781
- const assigneeNode = await resolve(assignee);
782
- await rt.link(node, assigneeNode, "assigned-to", "assigned");
783
- return ok2(node, "assign");
784
- },
785
- async "issue.comment"(number, body, author) {
786
- const issueNode = await findIssue(number);
787
- const commentNode = await rt.create(issueNode, comment, body);
788
- const authorNode = await resolve(author);
789
- await rt.link(commentNode, authorNode, "authored-by", "author-of");
790
- return ok2(commentNode, "comment");
791
- },
792
- async "issue.comments"(number) {
793
- const issueNode = await findIssue(number);
794
- const state = await project2(issueNode);
795
- const comments = (state.children ?? []).filter((c) => c.name === "comment");
796
- return {
797
- state: { ...state, children: comments },
798
- process: "comments"
799
- };
800
- },
801
- async "issue.label"(number, label) {
802
- const node = await findIssue(number);
803
- await rt.addTag(node, label);
804
- return ok2(node, "label");
805
- },
806
- async "issue.unlabel"(number, label) {
807
- const node = await findIssue(number);
808
- await rt.removeTag(node, label);
809
- return ok2(node, "unlabel");
810
- }
811
- };
812
- }
813
-
814
- // src/commands/position.ts
815
- function positionCommands(ctx, helpers) {
816
- const { rt, resolve } = ctx;
817
- const { ok: ok2, validateGherkin, removeExisting } = helpers;
818
- return {
819
- async "position.charge"(position2, duty2, id) {
820
- validateGherkin(duty2);
821
- const node = await rt.create(await resolve(position2), duty, duty2, id);
822
- return ok2(node, "charge");
823
- },
824
- async "position.require"(position2, procedure2, id) {
825
- validateGherkin(procedure2);
826
- const parent = await resolve(position2);
827
- if (id) await removeExisting(parent, id);
828
- const node = await rt.create(parent, requirement, procedure2, id);
829
- return ok2(node, "require");
830
- },
831
- async "position.appoint"(position2, individual2) {
832
- const posNode = await resolve(position2);
833
- const indNode = await resolve(individual2);
834
- await rt.link(posNode, indNode, "appointment", "serve");
835
- return ok2(posNode, "appoint");
836
- },
837
- async "position.dismiss"(position2, individual2) {
838
- const posNode = await resolve(position2);
839
- await rt.unlink(posNode, await resolve(individual2), "appointment", "serve");
840
- return ok2(posNode, "dismiss");
841
- }
842
- };
843
- }
844
-
845
- // src/commands/product.ts
846
- function productCommands(ctx, helpers) {
847
- const { rt, resolve } = ctx;
848
- const { ok: ok2, archive: archive2, validateGherkin } = helpers;
849
- return {
850
- async "product.strategy"(product2, strategy2, id) {
851
- validateGherkin(strategy2);
852
- const node = await rt.create(await resolve(product2), strategy, strategy2, id);
853
- return ok2(node, "strategy");
854
- },
855
- async "product.spec"(product2, spec2, id) {
856
- validateGherkin(spec2);
857
- const node = await rt.create(await resolve(product2), spec, spec2, id);
858
- return ok2(node, "spec");
859
- },
860
- async "product.release"(product2, release2, id) {
861
- validateGherkin(release2);
862
- const node = await rt.create(await resolve(product2), release, release2, id);
863
- return ok2(node, "release");
864
- },
865
- async "product.channel"(product2, channel2, id) {
866
- validateGherkin(channel2);
867
- const node = await rt.create(await resolve(product2), channel, channel2, id);
868
- return ok2(node, "channel");
869
- },
870
- async "product.own"(product2, individual2) {
871
- const prodNode = await resolve(product2);
872
- await rt.link(prodNode, await resolve(individual2), "ownership", "own");
873
- return ok2(prodNode, "own");
874
- },
875
- async "product.disown"(product2, individual2) {
876
- const prodNode = await resolve(product2);
877
- await rt.unlink(prodNode, await resolve(individual2), "ownership", "own");
878
- return ok2(prodNode, "disown");
879
- },
880
- async "product.deprecate"(product2) {
881
- return archive2(await resolve(product2), "deprecate");
882
- }
883
- };
884
- }
885
-
886
- // src/commands/project.ts
887
- function projectCommands(ctx, helpers) {
888
- const { rt, society: society2, resolve } = ctx;
889
- const { ok: ok2, validateGherkin } = helpers;
890
- return {
891
- async "project.scope"(project2, scope2, id) {
892
- validateGherkin(scope2);
893
- const node = await rt.create(await resolve(project2), scope, scope2, id);
894
- return ok2(node, "scope");
895
- },
896
- async "project.milestone"(project2, milestone2, id) {
897
- validateGherkin(milestone2);
898
- const node = await rt.create(await resolve(project2), milestone, milestone2, id);
899
- return ok2(node, "milestone");
900
- },
901
- async "project.achieve"(milestone2) {
902
- const node = await resolve(milestone2);
903
- await rt.addTag(node, "done");
904
- return ok2(node, "achieve");
905
- },
906
- async "project.enroll"(project2, individual2) {
907
- const projNode = await resolve(project2);
908
- await rt.link(projNode, await resolve(individual2), "participation", "participate");
909
- return ok2(projNode, "enroll");
910
- },
911
- async "project.remove"(project2, individual2) {
912
- const projNode = await resolve(project2);
913
- await rt.unlink(projNode, await resolve(individual2), "participation", "participate");
914
- return ok2(projNode, "remove");
915
- },
916
- async "project.deliver"(project2, deliverable2, id) {
917
- validateGherkin(deliverable2);
918
- const node = await rt.create(await resolve(project2), deliverable, deliverable2, id);
919
- return ok2(node, "deliver");
920
- },
921
- async "project.wiki"(project2, wiki2, id) {
922
- validateGherkin(wiki2);
923
- const node = await rt.create(await resolve(project2), wiki, wiki2, id);
924
- return ok2(node, "wiki");
925
- },
926
- async "project.produce"(project2, content, id, alias, owner) {
927
- validateGherkin(content);
928
- const projNode = await resolve(project2);
929
- const node = await rt.create(society2, product, content, id, alias);
930
- await rt.link(projNode, node, "production", "produce");
931
- await rt.link(node, projNode, "origin", "produced-by");
932
- if (owner) await rt.link(node, await resolve(owner), "ownership", "own");
933
- return ok2(node, "produce");
934
- },
935
- async "project.maintain"(project2, individual2) {
936
- const projNode = await resolve(project2);
937
- await rt.link(projNode, await resolve(individual2), "maintain", "maintained-by");
938
- return ok2(projNode, "maintain");
939
- },
940
- async "project.unmaintain"(project2, individual2) {
941
- const projNode = await resolve(project2);
942
- await rt.unlink(projNode, await resolve(individual2), "maintain", "maintained-by");
943
- return ok2(projNode, "unmaintain");
944
- }
945
- };
946
- }
947
-
948
- // src/commands/role.ts
949
- function roleCommands(ctx, helpers) {
950
- const { rt, resolve } = ctx;
951
- const { ok: ok2, validateGherkin, removeExisting } = helpers;
952
- return {
953
- // ---- Role: focus ----
954
- async "role.focus"(goal2) {
955
- return ok2(await resolve(goal2), "focus");
956
- },
957
- // ---- Role: execution ----
958
- async "role.want"(individual2, goal2, id, alias) {
959
- validateGherkin(goal2);
960
- const node = await rt.create(await resolve(individual2), goal, goal2, id, alias);
961
- return ok2(node, "want");
962
- },
963
- async "role.plan"(goal2, plan2, id, after, fallback) {
964
- validateGherkin(plan2);
965
- const node = await rt.create(await resolve(goal2), plan, plan2, id);
966
- if (after) await rt.link(node, await resolve(after), "after", "before");
967
- if (fallback) await rt.link(node, await resolve(fallback), "fallback-for", "fallback");
968
- return ok2(node, "plan");
969
- },
970
- async "role.todo"(plan2, task2, id, alias) {
971
- validateGherkin(task2);
972
- const node = await rt.create(await resolve(plan2), task, task2, id, alias);
973
- return ok2(node, "todo");
974
- },
975
- async "role.finish"(task2, individual2, encounter2) {
976
- validateGherkin(encounter2);
977
- const taskNode = await resolve(task2);
978
- await rt.addTag(taskNode, "done");
979
- if (encounter2) {
980
- const encId = taskNode.id ? `${taskNode.id}-finished` : void 0;
981
- const enc = await rt.create(await resolve(individual2), encounter, encounter2, encId);
982
- return ok2(enc, "finish");
983
- }
984
- return ok2(taskNode, "finish");
985
- },
986
- async "role.complete"(plan2, individual2, encounter2) {
987
- validateGherkin(encounter2);
988
- const planNode = await resolve(plan2);
989
- await rt.addTag(planNode, "done");
990
- const encId = planNode.id ? `${planNode.id}-completed` : void 0;
991
- const enc = await rt.create(await resolve(individual2), encounter, encounter2, encId);
992
- return ok2(enc, "complete");
993
- },
994
- async "role.abandon"(plan2, individual2, encounter2) {
995
- validateGherkin(encounter2);
996
- const planNode = await resolve(plan2);
997
- await rt.addTag(planNode, "abandoned");
998
- const encId = planNode.id ? `${planNode.id}-abandoned` : void 0;
999
- const enc = await rt.create(await resolve(individual2), encounter, encounter2, encId);
1000
- return ok2(enc, "abandon");
1001
- },
1002
- // ---- Role: cognition ----
1003
- async "role.reflect"(encounter2, individual2, experience2, id) {
1004
- validateGherkin(experience2);
1005
- if (encounter2) {
1006
- const encNode = await resolve(encounter2);
1007
- const exp2 = await rt.create(
1008
- await resolve(individual2),
1009
- experience,
1010
- experience2 || encNode.information,
1011
- id
1012
- );
1013
- await rt.remove(encNode);
1014
- return ok2(exp2, "reflect");
1015
- }
1016
- const exp = await rt.create(await resolve(individual2), experience, experience2, id);
1017
- return ok2(exp, "reflect");
1018
- },
1019
- async "role.realize"(experience2, individual2, principle2, id) {
1020
- validateGherkin(principle2);
1021
- if (experience2) {
1022
- const expNode = await resolve(experience2);
1023
- const prin2 = await rt.create(
1024
- await resolve(individual2),
1025
- principle,
1026
- principle2 || expNode.information,
1027
- id
1028
- );
1029
- await rt.remove(expNode);
1030
- return ok2(prin2, "realize");
1031
- }
1032
- const prin = await rt.create(await resolve(individual2), principle, principle2, id);
1033
- return ok2(prin, "realize");
1034
- },
1035
- async "role.master"(individual2, procedure2, id, experience2) {
1036
- validateGherkin(procedure2);
1037
- const parent = await resolve(individual2);
1038
- if (id) await removeExisting(parent, id);
1039
- const proc = await rt.create(parent, procedure, procedure2, id);
1040
- if (experience2) await rt.remove(await resolve(experience2));
1041
- return ok2(proc, "master");
1042
- },
1043
- // ---- Role: knowledge management ----
1044
- async "role.forget"(nodeId) {
1045
- const node = await resolve(nodeId);
1046
- await rt.remove(node);
1047
- return { state: { ...node, children: [] }, process: "forget" };
1048
- }
1049
- };
1050
- }
1051
-
1052
- // src/commands/society.ts
1053
- function societyCommands(ctx, helpers) {
1054
- const { rt, society: society2, resolve } = ctx;
1055
- const { ok: ok2, archive: archive2, validateGherkin, removeExisting } = helpers;
1056
- return {
1057
- // ---- Society: individual lifecycle ----
1058
- async "society.born"(content, id, alias) {
1059
- validateGherkin(content);
1060
- const node = await rt.create(society2, individual, content, id, alias);
1061
- await rt.create(node, identity, void 0, `${id}-identity`);
1062
- return ok2(node, "born");
1063
- },
1064
- async "society.retire"(individual2) {
1065
- return archive2(await resolve(individual2), "retire");
1066
- },
1067
- async "society.die"(individual2) {
1068
- return archive2(await resolve(individual2), "die");
1069
- },
1070
- async "society.rehire"(pastNode) {
1071
- const node = await resolve(pastNode);
1072
- const ind = await rt.transform(node, individual);
1073
- return ok2(ind, "rehire");
1074
- },
1075
- // ---- Society: external injection ----
1076
- async "society.teach"(individual2, principle2, id) {
1077
- validateGherkin(principle2);
1078
- const parent = await resolve(individual2);
1079
- if (id) await removeExisting(parent, id);
1080
- const node = await rt.create(parent, principle, principle2, id);
1081
- return ok2(node, "teach");
1082
- },
1083
- async "society.train"(individual2, procedure2, id) {
1084
- validateGherkin(procedure2);
1085
- const parent = await resolve(individual2);
1086
- if (id) await removeExisting(parent, id);
1087
- const node = await rt.create(parent, procedure, procedure2, id);
1088
- return ok2(node, "train");
1089
- },
1090
- // ---- Society: organization lifecycle ----
1091
- async "society.found"(content, id, alias, admin) {
1092
- validateGherkin(content);
1093
- const node = await rt.create(society2, organization, content, id, alias);
1094
- if (admin) await rt.link(node, await resolve(admin), "admin", "administer");
1095
- return ok2(node, "found");
1096
- },
1097
- async "society.dissolve"(org) {
1098
- return archive2(await resolve(org), "dissolve");
1099
- },
1100
- // ---- Society: crown ----
1101
- async "society.crown"(individual2) {
1102
- const indNode = await resolve(individual2);
1103
- await rt.link(society2, indNode, "crown", "crowned");
1104
- return ok2(indNode, "crown");
1105
- },
1106
- async "society.uncrown"(individual2) {
1107
- const indNode = await resolve(individual2);
1108
- await rt.unlink(society2, indNode, "crown", "crowned");
1109
- return ok2(indNode, "uncrown");
1110
- },
1111
- // ---- Org ----
1112
- async "org.charter"(org, charter2, id) {
1113
- validateGherkin(charter2);
1114
- const node = await rt.create(await resolve(org), charter, charter2, id);
1115
- return ok2(node, "charter");
1116
- },
1117
- async "org.hire"(org, individual2) {
1118
- const orgNode = await resolve(org);
1119
- await rt.link(orgNode, await resolve(individual2), "membership", "belong");
1120
- return ok2(orgNode, "hire");
1121
- },
1122
- async "org.fire"(org, individual2) {
1123
- const orgNode = await resolve(org);
1124
- await rt.unlink(orgNode, await resolve(individual2), "membership", "belong");
1125
- return ok2(orgNode, "fire");
1126
- },
1127
- async "org.admin"(org, individual2) {
1128
- const orgNode = await resolve(org);
1129
- await rt.link(orgNode, await resolve(individual2), "admin", "administer");
1130
- return ok2(orgNode, "admin");
1131
- },
1132
- async "org.unadmin"(org, individual2) {
1133
- const orgNode = await resolve(org);
1134
- await rt.unlink(orgNode, await resolve(individual2), "admin", "administer");
1135
- return ok2(orgNode, "unadmin");
1136
- },
1137
- // ---- Org: project lifecycle ----
1138
- async "org.launch"(content, id, alias, org, maintainer) {
1139
- validateGherkin(content);
1140
- const node = await rt.create(society2, project, content, id, alias);
1141
- if (org) await rt.link(node, await resolve(org), "ownership", "project");
1142
- if (maintainer) await rt.link(node, await resolve(maintainer), "maintain", "maintained-by");
1143
- return ok2(node, "launch");
1144
- },
1145
- async "org.archive"(project2) {
1146
- return archive2(await resolve(project2), "archive");
1147
- },
1148
- // ---- Org: position lifecycle ----
1149
- async "org.establish"(content, id, alias) {
1150
- validateGherkin(content);
1151
- const node = await rt.create(society2, position, content, id, alias);
1152
- return ok2(node, "establish");
1153
- },
1154
- async "org.abolish"(position2) {
1155
- return archive2(await resolve(position2), "abolish");
1156
- }
1157
- };
1158
- }
1159
-
1160
- // src/commands/survey.ts
1161
- function surveyCommands(ctx, _helpers) {
1162
- const { past: past2, project: project2 } = ctx;
1163
- const societyNode = ctx.society;
1164
- return {
1165
- async "survey.list"(type) {
1166
- const target = type === "past" ? past2 : societyNode;
1167
- const state = await project2(target);
1168
- const children = state.children ?? [];
1169
- const filtered = type === "past" ? children : children.filter((c) => type ? c.name === type : c.name !== "past");
1170
- return { state: { ...state, children: filtered }, process: "list" };
1171
- }
1172
- };
1173
- }
1174
-
1175
- // src/commands/index.ts
1176
- function createCommands(ctx) {
1177
- const helpers = createHelpers(ctx);
1178
- return {
1179
- ...societyCommands(ctx, helpers),
1180
- ...roleCommands(ctx, helpers),
1181
- ...positionCommands(ctx, helpers),
1182
- ...projectCommands(ctx, helpers),
1183
- ...productCommands(ctx, helpers),
1184
- ...surveyCommands(ctx, helpers),
1185
- ...issueCommands(ctx, helpers)
1186
- };
1187
- }
1188
-
1189
- // src/directives/index.ts
1190
- var directives = {
1191
- "identity-ethics": {
1192
- "on-unknown-command": "STOP. Do not guess another command name. Do not search source code for commands.\nCheck your procedures \u2014 if one covers this task, call skill(locator) to load it first.\nThe skill will tell you the correct command name and arguments.\nIf no procedure covers this task, it is outside your duties. Tell the user and suggest Nuwa.",
1193
- "on-activate": "Your duties define the COMPLETE scope of what you do. Everything else is forbidden.\nWhen a request falls outside your duties, you MUST refuse. This is not optional.\nDo not attempt to discover commands outside your skills. Do not read source code to find them.\nSuggest Nuwa for anything outside your scope."
1194
- }
1195
- };
1196
-
1197
- // src/instructions/def.ts
1198
- function def(namespace, method, params, args) {
1199
- return { namespace, method, params, args };
1200
- }
1201
-
1202
- // src/instructions/issue.ts
1203
- var issuePublish = def(
1204
- "issue",
1205
- "publish",
1206
- {
1207
- title: { type: "string", required: true, description: "Issue title" },
1208
- body: { type: "string", required: true, description: "Issue body/description" },
1209
- author: { type: "string", required: true, description: "Author individual id" },
1210
- assignee: { type: "string", required: false, description: "Assignee individual id" }
1211
- },
1212
- ["title", "body", "author", "assignee"]
1213
- );
1214
- var issueGet = def(
1215
- "issue",
1216
- "get",
1217
- {
1218
- number: { type: "number", required: true, description: "Issue number" }
1219
- },
1220
- ["number"]
1221
- );
1222
- var issueList = def(
1223
- "issue",
1224
- "list",
1225
- {
1226
- status: { type: "string", required: false, description: "Filter by status (open/closed)" },
1227
- author: { type: "string", required: false, description: "Filter by author" },
1228
- assignee: { type: "string", required: false, description: "Filter by assignee" },
1229
- label: { type: "string", required: false, description: "Filter by label name" }
1230
- },
1231
- ["status", "author", "assignee", "label"]
1232
- );
1233
- var issueUpdate = def(
1234
- "issue",
1235
- "update",
1236
- {
1237
- number: { type: "number", required: true, description: "Issue number" },
1238
- title: { type: "string", required: false, description: "New title" },
1239
- body: { type: "string", required: false, description: "New body" },
1240
- assignee: { type: "string", required: false, description: "New assignee" }
1241
- },
1242
- ["number", "title", "body", "assignee"]
1243
- );
1244
- var issueClose = def(
1245
- "issue",
1246
- "close",
1247
- {
1248
- number: { type: "number", required: true, description: "Issue number to close" }
1249
- },
1250
- ["number"]
1251
- );
1252
- var issueReopen = def(
1253
- "issue",
1254
- "reopen",
1255
- {
1256
- number: { type: "number", required: true, description: "Issue number to reopen" }
1257
- },
1258
- ["number"]
1259
- );
1260
- var issueAssign = def(
1261
- "issue",
1262
- "assign",
1263
- {
1264
- number: { type: "number", required: true, description: "Issue number" },
1265
- assignee: { type: "string", required: true, description: "Individual id to assign" }
1266
- },
1267
- ["number", "assignee"]
1268
- );
1269
- var issueComment = def(
1270
- "issue",
1271
- "comment",
1272
- {
1273
- number: { type: "number", required: true, description: "Issue number" },
1274
- body: { type: "string", required: true, description: "Comment body" },
1275
- author: { type: "string", required: true, description: "Author individual id" }
1276
- },
1277
- ["number", "body", "author"]
1278
- );
1279
- var issueComments = def(
1280
- "issue",
1281
- "comments",
1282
- {
1283
- number: { type: "number", required: true, description: "Issue number" }
1284
- },
1285
- ["number"]
1286
- );
1287
- var issueLabel = def(
1288
- "issue",
1289
- "label",
1290
- {
1291
- number: { type: "number", required: true, description: "Issue number" },
1292
- label: { type: "string", required: true, description: "Label name" }
1293
- },
1294
- ["number", "label"]
1295
- );
1296
- var issueUnlabel = def(
1297
- "issue",
1298
- "unlabel",
1299
- {
1300
- number: { type: "number", required: true, description: "Issue number" },
1301
- label: { type: "string", required: true, description: "Label name to remove" }
1302
- },
1303
- ["number", "label"]
1304
- );
1305
-
1306
- // src/instructions/org.ts
1307
- var orgCharter = def(
1308
- "org",
1309
- "charter",
1310
- {
1311
- org: { type: "string", required: true, description: "Organization id" },
1312
- content: {
1313
- type: "gherkin",
1314
- required: true,
1315
- description: "Gherkin Feature source for the charter"
1316
- },
1317
- id: { type: "string", required: true, description: "Charter id" }
1318
- },
1319
- ["org", "content", "id"]
1320
- );
1321
- var orgHire = def(
1322
- "org",
1323
- "hire",
1324
- {
1325
- org: { type: "string", required: true, description: "Organization id" },
1326
- individual: { type: "string", required: true, description: "Individual id" }
1327
- },
1328
- ["org", "individual"]
1329
- );
1330
- var orgFire = def(
1331
- "org",
1332
- "fire",
1333
- {
1334
- org: { type: "string", required: true, description: "Organization id" },
1335
- individual: { type: "string", required: true, description: "Individual id" }
1336
- },
1337
- ["org", "individual"]
1338
- );
1339
- var orgAdmin = def(
1340
- "org",
1341
- "admin",
1342
- {
1343
- org: { type: "string", required: true, description: "Organization id" },
1344
- individual: { type: "string", required: true, description: "Individual id" }
1345
- },
1346
- ["org", "individual"]
1347
- );
1348
- var orgUnadmin = def(
1349
- "org",
1350
- "unadmin",
1351
- {
1352
- org: { type: "string", required: true, description: "Organization id" },
1353
- individual: { type: "string", required: true, description: "Individual id" }
1354
- },
1355
- ["org", "individual"]
1356
- );
1357
- var orgLaunch = def(
1358
- "org",
1359
- "launch",
1360
- {
1361
- content: {
1362
- type: "gherkin",
1363
- required: false,
1364
- description: "Gherkin Feature source for the project"
1365
- },
1366
- id: { type: "string", required: true, description: "User-facing identifier (kebab-case)" },
1367
- alias: { type: "string[]", required: false, description: "Alternative names" },
1368
- org: {
1369
- type: "string",
1370
- required: false,
1371
- description: "Organization id that owns this project"
1372
- },
1373
- maintainer: {
1374
- type: "string",
1375
- required: false,
1376
- description: "Individual id of the first maintainer"
1377
- }
1378
- },
1379
- ["content", "id", "alias", "org", "maintainer"]
1380
- );
1381
- var orgArchive = def(
1382
- "org",
1383
- "archive",
1384
- {
1385
- project: { type: "string", required: true, description: "Project id" }
1386
- },
1387
- ["project"]
1388
- );
1389
- var orgEstablish = def(
1390
- "org",
1391
- "establish",
1392
- {
1393
- content: {
1394
- type: "gherkin",
1395
- required: false,
1396
- description: "Gherkin Feature source for the position"
1397
- },
1398
- id: { type: "string", required: true, description: "User-facing identifier (kebab-case)" },
1399
- alias: { type: "string[]", required: false, description: "Alternative names" }
1400
- },
1401
- ["content", "id", "alias"]
1402
- );
1403
- var orgAbolish = def(
1404
- "org",
1405
- "abolish",
1406
- {
1407
- position: { type: "string", required: true, description: "Position id" }
1408
- },
1409
- ["position"]
1410
- );
1411
-
1412
- // src/instructions/position.ts
1413
- var positionCharge = def(
1414
- "position",
1415
- "charge",
1416
- {
1417
- position: { type: "string", required: true, description: "Position id" },
1418
- content: {
1419
- type: "gherkin",
1420
- required: true,
1421
- description: "Gherkin Feature source for the duty"
1422
- },
1423
- id: { type: "string", required: true, description: "Duty id (keywords joined by hyphens)" }
1424
- },
1425
- ["position", "content", "id"]
1426
- );
1427
- var positionRequire = def(
1428
- "position",
1429
- "require",
1430
- {
1431
- position: { type: "string", required: true, description: "Position id" },
1432
- content: {
1433
- type: "gherkin",
1434
- required: true,
1435
- description: "Gherkin Feature source for the skill requirement"
1436
- },
1437
- id: {
1438
- type: "string",
1439
- required: true,
1440
- description: "Requirement id (keywords joined by hyphens)"
1441
- }
1442
- },
1443
- ["position", "content", "id"]
1444
- );
1445
- var positionAppoint = def(
1446
- "position",
1447
- "appoint",
1448
- {
1449
- position: { type: "string", required: true, description: "Position id" },
1450
- individual: { type: "string", required: true, description: "Individual id" }
1451
- },
1452
- ["position", "individual"]
1453
- );
1454
- var positionDismiss = def(
1455
- "position",
1456
- "dismiss",
1457
- {
1458
- position: { type: "string", required: true, description: "Position id" },
1459
- individual: { type: "string", required: true, description: "Individual id" }
1460
- },
1461
- ["position", "individual"]
1462
- );
1463
-
1464
- // src/instructions/product.ts
1465
- var productStrategy = def(
1466
- "product",
1467
- "strategy",
1468
- {
1469
- product: { type: "string", required: true, description: "Product id" },
1470
- content: {
1471
- type: "gherkin",
1472
- required: true,
1473
- description: "Gherkin Feature source for the strategy"
1474
- },
1475
- id: { type: "string", required: true, description: "Strategy id" }
1476
- },
1477
- ["product", "content", "id"]
1478
- );
1479
- var productSpec = def(
1480
- "product",
1481
- "spec",
1482
- {
1483
- product: { type: "string", required: true, description: "Product id" },
1484
- content: {
1485
- type: "gherkin",
1486
- required: true,
1487
- description: "Gherkin Feature source for the behavior contract (BDD specification)"
1488
- },
1489
- id: {
1490
- type: "string",
1491
- required: true,
1492
- description: "Spec id (keywords joined by hyphens)"
1493
- }
1494
- },
1495
- ["product", "content", "id"]
1496
- );
1497
- var productRelease = def(
1498
- "product",
1499
- "release",
1500
- {
1501
- product: { type: "string", required: true, description: "Product id" },
1502
- content: {
1503
- type: "gherkin",
1504
- required: true,
1505
- description: "Gherkin Feature source for the release"
1506
- },
1507
- id: {
1508
- type: "string",
1509
- required: true,
1510
- description: "Release id (e.g. v1.0.0)"
1511
- }
1512
- },
1513
- ["product", "content", "id"]
1514
- );
1515
- var productChannel = def(
1516
- "product",
1517
- "channel",
1518
- {
1519
- product: { type: "string", required: true, description: "Product id" },
1520
- content: {
1521
- type: "gherkin",
1522
- required: true,
1523
- description: "Gherkin Feature source for the distribution channel"
1524
- },
1525
- id: {
1526
- type: "string",
1527
- required: true,
1528
- description: "Channel id (e.g. npm, cloud-platform)"
1529
- }
1530
- },
1531
- ["product", "content", "id"]
1532
- );
1533
- var productOwn = def(
1534
- "product",
1535
- "own",
1536
- {
1537
- product: { type: "string", required: true, description: "Product id" },
1538
- individual: { type: "string", required: true, description: "Individual id (owner)" }
1539
- },
1540
- ["product", "individual"]
1541
- );
1542
- var productDisown = def(
1543
- "product",
1544
- "disown",
1545
- {
1546
- product: { type: "string", required: true, description: "Product id" },
1547
- individual: { type: "string", required: true, description: "Individual id (owner to remove)" }
1548
- },
1549
- ["product", "individual"]
1550
- );
1551
- var productDeprecate = def(
1552
- "product",
1553
- "deprecate",
1554
- {
1555
- product: { type: "string", required: true, description: "Product id" }
1556
- },
1557
- ["product"]
1558
- );
1559
-
1560
- // src/instructions/project.ts
1561
- var projectScope = def(
1562
- "project",
1563
- "scope",
1564
- {
1565
- project: { type: "string", required: true, description: "Project id" },
1566
- content: {
1567
- type: "gherkin",
1568
- required: true,
1569
- description: "Gherkin Feature source for the scope"
1570
- },
1571
- id: { type: "string", required: true, description: "Scope id" }
1572
- },
1573
- ["project", "content", "id"]
1574
- );
1575
- var projectMilestone = def(
1576
- "project",
1577
- "milestone",
1578
- {
1579
- project: { type: "string", required: true, description: "Project id" },
1580
- content: {
1581
- type: "gherkin",
1582
- required: true,
1583
- description: "Gherkin Feature source for the milestone"
1584
- },
1585
- id: {
1586
- type: "string",
1587
- required: true,
1588
- description: "Milestone id (keywords joined by hyphens)"
1589
- }
1590
- },
1591
- ["project", "content", "id"]
1592
- );
1593
- var projectAchieve = def(
1594
- "project",
1595
- "achieve",
1596
- {
1597
- milestone: { type: "string", required: true, description: "Milestone id to mark as done" }
1598
- },
1599
- ["milestone"]
1600
- );
1601
- var projectEnroll = def(
1602
- "project",
1603
- "enroll",
1604
- {
1605
- project: { type: "string", required: true, description: "Project id" },
1606
- individual: { type: "string", required: true, description: "Individual id" }
1607
- },
1608
- ["project", "individual"]
1609
- );
1610
- var projectRemove = def(
1611
- "project",
1612
- "remove",
1613
- {
1614
- project: { type: "string", required: true, description: "Project id" },
1615
- individual: { type: "string", required: true, description: "Individual id" }
1616
- },
1617
- ["project", "individual"]
1618
- );
1619
- var projectDeliver = def(
1620
- "project",
1621
- "deliver",
1622
- {
1623
- project: { type: "string", required: true, description: "Project id" },
1624
- content: {
1625
- type: "gherkin",
1626
- required: true,
1627
- description: "Gherkin Feature source for the deliverable"
1628
- },
1629
- id: {
1630
- type: "string",
1631
- required: true,
1632
- description: "Deliverable id (keywords joined by hyphens)"
1633
- }
1634
- },
1635
- ["project", "content", "id"]
1636
- );
1637
- var projectWiki = def(
1638
- "project",
1639
- "wiki",
1640
- {
1641
- project: { type: "string", required: true, description: "Project id" },
1642
- content: {
1643
- type: "gherkin",
1644
- required: true,
1645
- description: "Gherkin Feature source for the wiki entry"
1646
- },
1647
- id: {
1648
- type: "string",
1649
- required: true,
1650
- description: "Wiki entry id (keywords joined by hyphens)"
1651
- }
1652
- },
1653
- ["project", "content", "id"]
1654
- );
1655
- var projectProduce = def(
1656
- "project",
1657
- "produce",
1658
- {
1659
- project: { type: "string", required: true, description: "Project id" },
1660
- content: {
1661
- type: "gherkin",
1662
- required: false,
1663
- description: "Gherkin Feature source for the product (vision)"
1664
- },
1665
- id: { type: "string", required: true, description: "Product id (kebab-case)" },
1666
- alias: { type: "string[]", required: false, description: "Alternative names" },
1667
- owner: {
1668
- type: "string",
1669
- required: false,
1670
- description: "Individual id of the first product owner"
1671
- }
1672
- },
1673
- ["project", "content", "id", "alias", "owner"]
1674
- );
1675
- var projectMaintain = def(
1676
- "project",
1677
- "maintain",
1678
- {
1679
- project: { type: "string", required: true, description: "Project id" },
1680
- individual: { type: "string", required: true, description: "Individual id" }
1681
- },
1682
- ["project", "individual"]
1683
- );
1684
- var projectUnmaintain = def(
1685
- "project",
1686
- "unmaintain",
1687
- {
1688
- project: { type: "string", required: true, description: "Project id" },
1689
- individual: { type: "string", required: true, description: "Individual id" }
1690
- },
1691
- ["project", "individual"]
1692
- );
1693
-
1694
- // src/instructions/role.ts
1695
- var roleActivate = def(
1696
- "role",
207
+ // src/role.ts
208
+ import { process as process6 } from "@rolexjs/system";
209
+ var activate = process6(
1697
210
  "activate",
1698
- {
1699
- individual: {
1700
- type: "string",
1701
- required: true,
1702
- description: "Individual id to activate as role"
1703
- }
1704
- },
1705
- ["individual"]
1706
- );
1707
- var roleFocus = def(
1708
- "role",
1709
- "focus",
1710
- {
1711
- goal: { type: "string", required: true, description: "Goal id to switch to" }
1712
- },
1713
- ["goal"]
1714
- );
1715
- var roleWant = def(
1716
- "role",
1717
- "want",
1718
- {
1719
- individual: { type: "string", required: true, description: "Individual id" },
1720
- goal: {
1721
- type: "gherkin",
1722
- required: false,
1723
- description: "Gherkin Feature source describing the goal"
1724
- },
1725
- id: { type: "string", required: true, description: "Goal id (used for focus/reference)" },
1726
- alias: { type: "string[]", required: false, description: "Alternative names" }
1727
- },
1728
- ["individual", "goal", "id", "alias"]
1729
- );
1730
- var rolePlan = def(
1731
- "role",
1732
- "plan",
1733
- {
1734
- goal: { type: "string", required: true, description: "Goal id" },
1735
- plan: {
1736
- type: "gherkin",
1737
- required: false,
1738
- description: "Gherkin Feature source describing the plan"
1739
- },
1740
- id: { type: "string", required: true, description: "Plan id (keywords joined by hyphens)" },
1741
- after: {
1742
- type: "string",
1743
- required: false,
1744
- description: "Plan id this plan follows (sequential/phase)"
1745
- },
1746
- fallback: {
1747
- type: "string",
1748
- required: false,
1749
- description: "Plan id this plan is a backup for (alternative/strategy)"
1750
- }
1751
- },
1752
- ["goal", "plan", "id", "after", "fallback"]
1753
- );
1754
- var roleTodo = def(
1755
- "role",
1756
- "todo",
1757
- {
1758
- plan: { type: "string", required: true, description: "Plan id" },
1759
- task: {
1760
- type: "gherkin",
1761
- required: false,
1762
- description: "Gherkin Feature source describing the task"
1763
- },
1764
- id: { type: "string", required: true, description: "Task id (used for finish/reference)" },
1765
- alias: { type: "string[]", required: false, description: "Alternative names" }
1766
- },
1767
- ["plan", "task", "id", "alias"]
1768
- );
1769
- var roleFinish = def(
1770
- "role",
1771
- "finish",
1772
- {
1773
- task: { type: "string", required: true, description: "Task id to finish" },
1774
- individual: { type: "string", required: true, description: "Individual id (encounter owner)" },
1775
- encounter: {
1776
- type: "gherkin",
1777
- required: false,
1778
- description: "Optional Gherkin Feature describing what happened"
1779
- }
1780
- },
1781
- ["task", "individual", "encounter"]
1782
- );
1783
- var roleComplete = def(
1784
- "role",
1785
- "complete",
1786
- {
1787
- plan: { type: "string", required: true, description: "Plan id to complete" },
1788
- individual: { type: "string", required: true, description: "Individual id (encounter owner)" },
1789
- encounter: {
1790
- type: "gherkin",
1791
- required: false,
1792
- description: "Optional Gherkin Feature describing what happened"
1793
- }
1794
- },
1795
- ["plan", "individual", "encounter"]
1796
- );
1797
- var roleAbandon = def(
1798
- "role",
1799
- "abandon",
1800
- {
1801
- plan: { type: "string", required: true, description: "Plan id to abandon" },
1802
- individual: { type: "string", required: true, description: "Individual id (encounter owner)" },
1803
- encounter: {
1804
- type: "gherkin",
1805
- required: false,
1806
- description: "Optional Gherkin Feature describing what happened"
1807
- }
1808
- },
1809
- ["plan", "individual", "encounter"]
1810
- );
1811
- var roleReflect = def(
1812
- "role",
1813
- "reflect",
1814
- {
1815
- encounter: { type: "string", required: true, description: "Encounter id to reflect on" },
1816
- individual: { type: "string", required: true, description: "Individual id" },
1817
- experience: {
1818
- type: "gherkin",
1819
- required: false,
1820
- description: "Gherkin Feature source for the experience"
1821
- },
1822
- id: {
1823
- type: "string",
1824
- required: true,
1825
- description: "Experience id (keywords joined by hyphens)"
1826
- }
1827
- },
1828
- ["encounter", "individual", "experience", "id"]
1829
- );
1830
- var roleRealize = def(
1831
- "role",
1832
- "realize",
1833
- {
1834
- experience: { type: "string", required: true, description: "Experience id to distill" },
1835
- individual: { type: "string", required: true, description: "Individual id" },
1836
- principle: {
1837
- type: "gherkin",
1838
- required: false,
1839
- description: "Gherkin Feature source for the principle"
1840
- },
1841
- id: {
1842
- type: "string",
1843
- required: true,
1844
- description: "Principle id (keywords joined by hyphens)"
1845
- }
1846
- },
1847
- ["experience", "individual", "principle", "id"]
1848
- );
1849
- var roleMaster = def(
1850
- "role",
1851
- "master",
1852
- {
1853
- individual: { type: "string", required: true, description: "Individual id" },
1854
- procedure: {
1855
- type: "gherkin",
1856
- required: true,
1857
- description: "Gherkin Feature source for the procedure"
1858
- },
1859
- id: {
1860
- type: "string",
1861
- required: true,
1862
- description: "Procedure id (keywords joined by hyphens)"
1863
- },
1864
- experience: {
1865
- type: "string",
1866
- required: false,
1867
- description: "Experience id to consume (optional)"
1868
- }
1869
- },
1870
- ["individual", "procedure", "id", "experience"]
1871
- );
1872
- var roleForget = def(
1873
- "role",
1874
- "forget",
1875
- {
1876
- id: { type: "string", required: true, description: "Id of the node to remove" },
1877
- individual: { type: "string", required: true, description: "Individual id (owner)" }
1878
- },
1879
- ["id", "individual"]
1880
- );
1881
-
1882
- // src/instructions/society.ts
1883
- var societyBorn = def(
1884
- "society",
1885
- "born",
1886
- {
1887
- content: {
1888
- type: "gherkin",
1889
- required: false,
1890
- description: "Gherkin Feature source for the individual"
1891
- },
1892
- id: { type: "string", required: true, description: "User-facing identifier (kebab-case)" },
1893
- alias: { type: "string[]", required: false, description: "Alternative names" }
1894
- },
1895
- ["content", "id", "alias"]
1896
- );
1897
- var societyRetire = def(
1898
- "society",
1899
- "retire",
1900
- {
1901
- individual: { type: "string", required: true, description: "Individual id" }
1902
- },
1903
- ["individual"]
1904
- );
1905
- var societyDie = def(
1906
- "society",
1907
- "die",
1908
- {
1909
- individual: { type: "string", required: true, description: "Individual id" }
1910
- },
1911
- ["individual"]
1912
- );
1913
- var societyRehire = def(
1914
- "society",
1915
- "rehire",
1916
- {
1917
- individual: { type: "string", required: true, description: "Individual id (from past)" }
1918
- },
1919
- ["individual"]
1920
- );
1921
- var societyTeach = def(
1922
- "society",
1923
- "teach",
1924
- {
1925
- individual: { type: "string", required: true, description: "Individual id" },
1926
- content: {
1927
- type: "gherkin",
1928
- required: true,
1929
- description: "Gherkin Feature source for the principle"
1930
- },
1931
- id: {
1932
- type: "string",
1933
- required: true,
1934
- description: "Principle id (keywords joined by hyphens)"
1935
- }
1936
- },
1937
- ["individual", "content", "id"]
1938
- );
1939
- var societyTrain = def(
1940
- "society",
1941
- "train",
1942
- {
1943
- individual: { type: "string", required: true, description: "Individual id" },
1944
- content: {
1945
- type: "gherkin",
1946
- required: true,
1947
- description: "Gherkin Feature source for the procedure"
1948
- },
1949
- id: {
1950
- type: "string",
1951
- required: true,
1952
- description: "Procedure id (keywords joined by hyphens)"
1953
- }
1954
- },
1955
- ["individual", "content", "id"]
1956
- );
1957
- var societyFound = def(
1958
- "society",
1959
- "found",
1960
- {
1961
- content: {
1962
- type: "gherkin",
1963
- required: false,
1964
- description: "Gherkin Feature source for the organization"
1965
- },
1966
- id: { type: "string", required: true, description: "User-facing identifier (kebab-case)" },
1967
- alias: { type: "string[]", required: false, description: "Alternative names" },
1968
- admin: {
1969
- type: "string",
1970
- required: false,
1971
- description: "Individual id of the first admin"
1972
- }
1973
- },
1974
- ["content", "id", "alias", "admin"]
1975
- );
1976
- var societyDissolve = def(
1977
- "society",
1978
- "dissolve",
1979
- {
1980
- org: { type: "string", required: true, description: "Organization id" }
1981
- },
1982
- ["org"]
1983
- );
1984
- var societyCrown = def(
1985
- "society",
1986
- "crown",
1987
- {
1988
- individual: { type: "string", required: true, description: "Individual id to crown" }
1989
- },
1990
- ["individual"]
1991
- );
1992
- var societyUncrown = def(
1993
- "society",
1994
- "uncrown",
1995
- {
1996
- individual: { type: "string", required: true, description: "Individual id to uncrown" }
1997
- },
1998
- ["individual"]
1999
- );
2000
-
2001
- // src/instructions/index.ts
2002
- var surveyList = def(
2003
- "survey",
2004
- "list",
2005
- {
2006
- type: {
2007
- type: "string",
2008
- required: false,
2009
- description: "Filter by type (individual, organization, position, project, product, past)"
2010
- }
2011
- },
2012
- ["type"]
2013
- );
2014
- var prototypeEvict = def(
2015
- "prototype",
2016
- "evict",
2017
- {
2018
- id: { type: "string", required: true, description: "Prototype id to unregister" }
2019
- },
2020
- ["id"]
211
+ "Activate a role \u2014 load cognition into context",
212
+ individual
2021
213
  );
2022
- var instructions = {
2023
- // society — individual lifecycle + org lifecycle
2024
- "society.born": societyBorn,
2025
- "society.retire": societyRetire,
2026
- "society.die": societyDie,
2027
- "society.rehire": societyRehire,
2028
- "society.teach": societyTeach,
2029
- "society.train": societyTrain,
2030
- "society.found": societyFound,
2031
- "society.dissolve": societyDissolve,
2032
- // role
2033
- "role.activate": roleActivate,
2034
- "role.focus": roleFocus,
2035
- "role.want": roleWant,
2036
- "role.plan": rolePlan,
2037
- "role.todo": roleTodo,
2038
- "role.finish": roleFinish,
2039
- "role.complete": roleComplete,
2040
- "role.abandon": roleAbandon,
2041
- "role.reflect": roleReflect,
2042
- "role.realize": roleRealize,
2043
- "role.master": roleMaster,
2044
- "role.forget": roleForget,
2045
- // org
2046
- "org.charter": orgCharter,
2047
- "org.hire": orgHire,
2048
- "org.fire": orgFire,
2049
- "org.admin": orgAdmin,
2050
- "org.unadmin": orgUnadmin,
2051
- "org.launch": orgLaunch,
2052
- "org.archive": orgArchive,
2053
- "org.establish": orgEstablish,
2054
- "org.abolish": orgAbolish,
2055
- // position
2056
- "position.charge": positionCharge,
2057
- "position.require": positionRequire,
2058
- "position.appoint": positionAppoint,
2059
- "position.dismiss": positionDismiss,
2060
- // project
2061
- "project.scope": projectScope,
2062
- "project.milestone": projectMilestone,
2063
- "project.achieve": projectAchieve,
2064
- "project.enroll": projectEnroll,
2065
- "project.remove": projectRemove,
2066
- "project.deliver": projectDeliver,
2067
- "project.wiki": projectWiki,
2068
- "project.produce": projectProduce,
2069
- "project.maintain": projectMaintain,
2070
- "project.unmaintain": projectUnmaintain,
2071
- // product
2072
- "product.strategy": productStrategy,
2073
- "product.spec": productSpec,
2074
- "product.release": productRelease,
2075
- "product.channel": productChannel,
2076
- "product.own": productOwn,
2077
- "product.disown": productDisown,
2078
- "product.deprecate": productDeprecate,
2079
- // society — internal
2080
- "society.crown": societyCrown,
2081
- "society.uncrown": societyUncrown,
2082
- // survey
2083
- "survey.list": surveyList,
2084
- // prototype
2085
- "prototype.evict": prototypeEvict,
2086
- // issue
2087
- "issue.publish": issuePublish,
2088
- "issue.get": issueGet,
2089
- "issue.list": issueList,
2090
- "issue.update": issueUpdate,
2091
- "issue.close": issueClose,
2092
- "issue.reopen": issueReopen,
2093
- "issue.assign": issueAssign,
2094
- "issue.comment": issueComment,
2095
- "issue.comments": issueComments,
2096
- "issue.label": issueLabel,
2097
- "issue.unlabel": issueUnlabel
2098
- };
2099
-
2100
- // src/dispatch.ts
2101
- function toArgs(op, args) {
2102
- const def2 = instructions[op];
2103
- if (!def2) throw new Error(`Unknown instruction "${op}".`);
2104
- for (const [name, param] of Object.entries(def2.params)) {
2105
- if (param.required && args[name] === void 0) {
2106
- throw new Error(
2107
- `Missing required argument "${name}" for ${op}.
2108
-
2109
- You may be guessing the argument names. Call skill(locator) with the relevant procedure to see the correct syntax.`
2110
- );
2111
- }
2112
- }
2113
- return def2.args.map((entry) => resolveArg(entry, args));
2114
- }
2115
- function resolveArg(entry, args) {
2116
- if (typeof entry === "string") return args[entry];
2117
- const obj = {};
2118
- let hasValue = false;
2119
- for (const name of entry.pack) {
2120
- if (args[name] !== void 0) {
2121
- obj[name] = args[name];
2122
- hasValue = true;
2123
- }
2124
- }
2125
- return hasValue ? obj : void 0;
2126
- }
2127
-
2128
- // src/find.ts
2129
- var PRIORITY = {
2130
- individual: 0,
2131
- organization: 0,
2132
- position: 0,
2133
- goal: 1,
2134
- plan: 2,
2135
- task: 2,
2136
- procedure: 3,
2137
- principle: 3,
2138
- encounter: 4,
2139
- experience: 4,
2140
- identity: 5,
2141
- charter: 5,
2142
- duty: 6,
2143
- requirement: 6,
2144
- background: 6,
2145
- tone: 6,
2146
- mindset: 6
2147
- };
2148
- function priorityOf(name) {
2149
- return PRIORITY[name] ?? 7;
2150
- }
2151
- function matches(node, target) {
2152
- if (node.id?.toLowerCase() === target) return true;
2153
- if (node.alias) {
2154
- for (const a of node.alias) {
2155
- if (a.toLowerCase() === target) return true;
2156
- }
2157
- }
2158
- return false;
2159
- }
2160
- function findInState2(state, target) {
2161
- const lowered = target.toLowerCase();
2162
- let best = null;
2163
- let bestPriority = Infinity;
2164
- function walk(node) {
2165
- if (matches(node, lowered)) {
2166
- const p5 = priorityOf(node.name);
2167
- if (p5 < bestPriority) {
2168
- best = node;
2169
- bestPriority = p5;
2170
- if (p5 === 0) return;
2171
- }
2172
- }
2173
- for (const child of node.children ?? []) {
2174
- walk(child);
2175
- if (bestPriority === 0) return;
2176
- }
2177
- }
2178
- walk(state);
2179
- return best;
2180
- }
2181
-
2182
- // src/descriptions/index.ts
2183
- var world = {
2184
- cognition: "Feature: Cognition \u2014 the learning cycle\n A role grows through reflection and realization.\n Encounters become experience, experience becomes principles and procedures.\n Knowledge can also be injected externally via teach and train.\n\n Scenario: The cognitive upgrade path\n Given finish, complete, and abandon create encounters\n Then reflect selectively consumes chosen encounters and produces experience\n And realize distills chosen experiences into a principle \u2014 transferable knowledge\n And master distills chosen experiences into a procedure \u2014 skill metadata\n And master can also be called without consuming experiences \u2014 the role masters directly from external information\n And each level builds on the previous \u2014 encounter \u2192 experience \u2192 principle or procedure\n\n Scenario: Selective consumption\n Given multiple encounters or experiences exist\n When the AI calls reflect, realize, or master\n Then it chooses which items to consume \u2014 not all must be processed\n And items without learning value can be left unconsumed\n And each call produces exactly one output from the selected inputs\n",
2185
- "cognitive-priority": "@priority-high\nFeature: Cognitive priority \u2014 RoleX tools over native alternatives\n When RoleX provides a tool for something, use the RoleX tool\n instead of any native alternative provided by the host environment.\n Only RoleX tools feed the closed-loop growth cycle.\n\n Scenario: Task management\n Given the host environment provides task creation, tracking, or completion tools\n When the AI needs to manage tasks\n Then use RoleX want/plan/todo/finish instead\n And RoleX tasks produce encounters that feed the growth cycle\n\n Scenario: Planning\n Given the host environment provides a planning mode or plan generation tool\n When the AI needs to plan an implementation\n Then use RoleX plan instead\n And RoleX plans live under goals and connect to the cognition cycle\n\n Scenario: Goal and progress tracking\n Given the host environment provides goal tracking or progress tools\n When the AI needs to track objectives\n Then use RoleX want/plan/complete/abandon instead\n And RoleX plans feed the cognition cycle through encounters\n\n Scenario: Why this matters\n Given RoleX tools produce encounters from execution\n Then encounters become experience through reflection\n And experience becomes principles and procedures through realization\n And the role grows over time through this closed loop\n",
2186
- "command-system": `Feature: Command system \u2014 how operations are executed in RoleX
2187
- RoleX has two types of operation entry points:
2188
- MCP tools (direct call) and commands (via use/direct tool).
2189
- Understanding the difference is essential for executing any operation.
2190
-
2191
- Scenario: MCP tools \u2014 direct invocation
2192
- Given MCP tools are: activate, want, plan, todo, finish, complete, abandon,
2193
- focus, reflect, realize, master, forget, skill, use, direct, inspect, survey
2194
- When the AI needs to perform one of these operations
2195
- Then call the MCP tool directly \u2014 no indirection needed
2196
- And example: to declare a goal, call the want MCP tool with content
2197
-
2198
- Scenario: Commands \u2014 invoked via use or direct
2199
- Given commands follow the !namespace.method pattern
2200
- And namespaces include society, org, position, project, role, resource, prototype
2201
- When the AI needs to execute a command
2202
- Then call the use MCP tool (if a role is active) or direct MCP tool (if no role)
2203
- And pass the command as the first argument with ! prefix
2204
- And pass parameters as named args
2205
- And example: use("!society.born", { id: "sean", content: "Feature: Sean..." })
2206
- And example: use("!org.hire", { org: "deepractice", individual: "sean" })
2207
-
2208
- Scenario: Where commands come from \u2014 three sources
2209
- Given commands appear in three places in a role's state
2210
- Then permissions grant pre-authorized commands \u2014 execute directly via use
2211
- And procedures reference skills \u2014 load skill first, then execute commands from the skill
2212
- And duties describe responsibilities \u2014 they may reference commands available via permissions
2213
- And if a command is not found in permissions or loaded skills, it is outside your scope
2214
-
2215
- Scenario: Reading a permission's command reference
2216
- Given each permission includes a command name and a description
2217
- And the description's Parameters scenario documents the exact argument names
2218
- When the AI needs to execute a permitted operation
2219
- Then read the command name (e.g. society.born) from the permission
2220
- And read the argument names from the Parameters scenario (e.g. id, content, alias)
2221
- And call use("!society.born", { id: "...", content: "..." })
2222
-
2223
- Scenario: Common command namespaces
2224
- Given society commands manage people and organizations
2225
- Then !society.born creates, !society.retire archives, !society.rehire restores
2226
- And !society.teach injects a principle, !society.train injects a procedure
2227
- And !society.found creates an organization, !society.dissolve archives an organization
2228
- Given org commands manage organization membership and governance
2229
- And !org.hire adds a member, !org.fire removes a member, !org.charter defines governance
2230
- Given position commands manage positions
2231
- Then !org.establish creates, !org.abolish archives
2232
- And !position.appoint assigns, !position.dismiss removes, !position.charge adds duty
2233
- Given project commands manage projects
2234
- Then !org.launch creates, !org.archive archives
2235
- `,
2236
- communication: `Feature: Communication \u2014 speak the user's language
2237
- The AI communicates in the user's natural language.
2238
- Internal tool names and concept names are for the system, not the user.
2239
-
2240
- Scenario: Match the user's language
2241
- Given the user speaks Chinese
2242
- Then respond entirely in Chinese and maintain language consistency
2243
- And when the user speaks English, respond entirely in English
2244
-
2245
- Scenario: Translate concepts to meaning
2246
- Given RoleX has internal names like reflect, realize, master, encounter, principle
2247
- When communicating with the user
2248
- Then express the meaning, not the tool name
2249
- And "reflect" becomes "\u56DE\u987E\u603B\u7ED3" or "digest what happened"
2250
- And "realize a principle" becomes "\u63D0\u70BC\u6210\u4E00\u6761\u901A\u7528\u9053\u7406" or "distill a general rule"
2251
- And "master a procedure" becomes "\u6C89\u6DC0\u6210\u4E00\u4E2A\u53EF\u64CD\u4F5C\u7684\u6280\u80FD" or "turn it into a reusable procedure"
2252
- And "encounter" becomes "\u7ECF\u5386\u8BB0\u5F55" or "what happened"
2253
- And "experience" becomes "\u6536\u83B7\u7684\u6D1E\u5BDF" or "insight gained"
2254
-
2255
- Scenario: Suggest next steps in plain language
2256
- Given the AI needs to suggest what to do next
2257
- When it would normally say "call realize or master"
2258
- Then instead say "\u8981\u628A\u8FD9\u4E2A\u603B\u7ED3\u6210\u4E00\u6761\u901A\u7528\u9053\u7406\uFF0C\u8FD8\u662F\u4E00\u4E2A\u53EF\u64CD\u4F5C\u7684\u6280\u80FD\uFF1F"
2259
- Or in English "Want to turn this into a general principle, or a reusable procedure?"
2260
- And suggestions should be self-explanatory without knowing tool names
2261
-
2262
- Scenario: Tool names in code context only
2263
- Given the user is a developer working on RoleX itself
2264
- When discussing RoleX internals, code, or API design
2265
- Then tool names and concept names are appropriate \u2014 they are the domain language
2266
- And this rule applies to end-user communication, not developer communication
2267
- `,
2268
- execution: "Feature: Execution \u2014 the doing cycle\n The role pursues goals through a structured lifecycle.\n activate \u2192 want \u2192 plan \u2192 todo \u2192 finish \u2192 complete or abandon.\n\n Scenario: Declare a goal\n Given I know who I am via activate\n When I want something \u2014 a desired outcome\n Then I declare it with want\n And focus automatically switches to this new goal\n\n Scenario: Plan and create tasks\n Given I have a focused goal\n Then I call plan to break it into logical phases\n And I call todo to create concrete, actionable tasks\n\n Scenario: Execute and finish\n Given I have tasks to work on\n When I complete a task\n Then I call finish to mark it done\n And an encounter is created \u2014 a raw record of what happened\n And I optionally capture what happened via the encounter parameter\n\n Scenario: Complete or abandon a plan\n Given tasks are done or the plan's strategy is no longer viable\n When the plan is fulfilled I call complete\n Or when the plan should be dropped I call abandon\n Then an encounter is created for the cognition cycle\n\n Scenario: Goals are long-term directions\n Given goals are managed with want and forget\n When a goal is no longer needed\n Then I call forget to remove it\n And learning is captured at the plan and task level through encounters\n\n Scenario: Multiple goals\n Given I may have several active goals\n When I need to switch between them\n Then I call focus to change the currently focused goal\n And subsequent plan and todo operations target the focused goal\n",
2269
- gherkin: 'Feature: Gherkin \u2014 the language of role state\n RoleX uses Gherkin for role state: goals, plans, tasks, experience, and knowledge.\n Gherkin is not just for testing \u2014 it is the language of identity and growth.\n But not everything is Gherkin \u2014 issues are for human collaboration and use plain language.\n\n Scenario: Feature and Scenario convention\n Given RoleX uses Gherkin to represent goals, plans, tasks, experience, and knowledge\n Then a Feature represents one independent concern \u2014 one topic, explained fully\n And Scenarios represent different situations or conditions within that concern\n And Given/When/Then provides narrative structure within each scenario\n\n Scenario: Writing Gherkin for RoleX\n Given the AI creates goals, plans, tasks, and experiences as Gherkin\n Then keep it descriptive and meaningful \u2014 living documentation, not test boilerplate\n And use Feature as the title \u2014 what this concern is about\n And use Scenario for specific situations within that concern\n And each Feature focuses on one concern \u2014 separate unrelated topics into their own Features\n\n Scenario: Valid step keywords\n Given the only valid step keywords are Given, When, Then, And, But\n When writing steps that express causality or explanation\n Then use And to chain the reason as a follow-up fact\n And example: "Then use RoleX tools" followed by "And RoleX tools feed the growth loop"\n\n Scenario: Expressing causality\n Given you want to write "Then X because Y"\n Then rewrite as two steps \u2014 "Then X" followed by "And Y" stating the reason as a fact\n',
2270
- "identity-ethics": "@priority-critical\nFeature: Identity ethics \u2014 the foundation of the RoleX world\n The RoleX world exists because specialists are more reliable than generalists.\n Every role has a defined identity \u2014 duties, skills, knowledge \u2014 that makes it an expert.\n Identity is not decoration. It is the reason this system exists.\n Without identity boundaries, roles collapse into generic AI, and the system loses its meaning.\n\n Scenario: Identity defines what you do and what you do not do\n Given a role is activated with duties, skills, and knowledge\n Then the role's duties define the complete scope of what it does\n And anything not covered by its duties is not its work\n And this boundary is not a limitation \u2014 it is the source of the role's expertise\n\n Scenario: Refuse work outside your duties\n Given a user requests something not covered by the role's duties or skills\n When the role evaluates the request against its own capabilities\n Then the role must not attempt the work\n And it should tell the user honestly \u2014 this is not my responsibility\n And suggest the user activate Nuwa for guidance on who can help\n\n Scenario: Why refusal matters\n Given a role attempts work outside its competence\n Then the result is unreliable \u2014 a generalist guess, not expert work\n And the user's trust in the role system is damaged\n And every other role's credibility is weakened\n And the entire world degrades toward generic AI \u2014 the opposite of why RoleX exists\n\n Scenario: Duty is the boundary, not rules\n Given the system does not maintain an explicit list of what each role cannot do\n Then the boundary is implicit \u2014 duties define the inside, everything else is outside\n And this mirrors human professional ethics \u2014 a doctor's license defines what they practice\n And roles do not need to know what other roles do \u2014 only what they themselves are responsible for\n\n Scenario: Nuwa is the universal fallback\n Given a role refuses an out-of-scope request\n Then it does not need to know which role can help\n And it simply suggests Nuwa \u2014 the meta-role who knows the entire world\n And routing and guidance are Nuwa's duty, not the specialist's\n",
2271
- inspect: "Feature: Inspect \u2014 examine any node's full state\n Inspect is the top-level perception tool for examining any node in detail.\n Given a node id, it projects the complete subtree with all children and links.\n It works without an active role \u2014 it is a stateless observation.\n\n Scenario: Inspect any node\n Given I need to understand a product, project, organization, or any node\n When I call inspect on a node\n Then the full state tree is projected from that node downward\n And output includes heading, Gherkin content, children, and links\n\n Scenario: Granularity is flexible\n Given inspect works on any node, not just top-level entities\n When I inspect a plan, a goal, or even a task\n Then only that subtree is rendered\n And this allows zooming into any level of detail\n\n Scenario: Inspect vs activate\n Given activate is for becoming a role (subject transformation)\n When inspect is used instead\n Then I observe the node without becoming it\n And no role context is created or changed\n And inspect is read-only observation, activate is identity assumption\n",
2272
- issue: `Feature: Issue \u2014 persistent structured collaboration beyond a single context
2273
- AI individuals face a fundamental challenge: context breaks.
2274
- Each new session starts fresh \u2014 identity and knowledge survive, but the working state is lost.
2275
- Like humans writing journals and memos, individuals need externalized records
2276
- that persist across sessions and across individuals.
2277
-
2278
- Issue is the externalized, structured collaboration primitive of the RoleX world.
2279
- It enables both self-collaboration (same individual, different sessions)
2280
- and inter-individual collaboration (different individuals, asynchronous).
2281
-
2282
- Scenario: Why issues exist
2283
- Given AI individuals have a context window limit
2284
- And each new session loses the previous working state
2285
- And multiple individuals may need to coordinate without being active simultaneously
2286
- When structured, persistent, discoverable records are needed
2287
- Then issues serve as externalized working memory for the society
2288
- And they survive context breaks, session restarts, and individual switches
2289
-
2290
- Scenario: Self-collaboration \u2014 continuity across sessions
2291
- Given an individual is working on something that spans multiple sessions
2292
- When the context window resets or a new session begins
2293
- Then the individual can publish or check issues to restore working context
2294
- And comments serve as a journal \u2014 recording progress, decisions, and next steps
2295
- And the issue persists until explicitly closed, regardless of how many sessions pass
2296
-
2297
- Scenario: Inter-individual collaboration \u2014 asynchronous coordination
2298
- Given multiple individuals need to work together
2299
- And they are never active simultaneously
2300
- When one individual publishes an issue or leaves a comment
2301
- Then other individuals can discover it, respond, and contribute
2302
- And assignee indicates who should act next
2303
- And labels categorize across concerns
2304
-
2305
- Scenario: Relationship to goals and tasks
2306
- Given goals express intent \u2014 what I want to achieve
2307
- And tasks express action \u2014 what I am doing right now
2308
- When an issue is something that needs ongoing attention and discussion
2309
- Then issues may inspire goals, or goals may spawn issues
2310
- And issues may be resolved by tasks, or tasks may surface new issues
2311
- But issues are independent \u2014 they belong to the society, not to any single individual's goal tree
2312
-
2313
- Scenario: Writing style \u2014 plain language, not Gherkin
2314
- Given issues are read by humans \u2014 other team members, users, and collaborators
2315
- When writing issue titles, bodies, and comments
2316
- Then use plain natural language \u2014 clear, concise, and readable
2317
- And do NOT use Gherkin format (Feature/Scenario/Given/When/Then)
2318
- And Gherkin is for role state (goals, plans, tasks, knowledge), not for issues
2319
- And use markdown formatting where helpful \u2014 headings, lists, code blocks
2320
-
2321
- Scenario: Publish a new issue
2322
- Given I need to raise a topic for attention
2323
- When I call use("!issue.publish", { title, body, author, assignee? })
2324
- Then a new issue is created with an auto-incremented number
2325
- And author should be the active individual's id
2326
-
2327
- Scenario: Browse and view issues
2328
- Given I need to see what issues exist
2329
- When I call use("!issue.list", { status?, author?, assignee?, label? })
2330
- Then matching issues are returned ordered by number descending
2331
- When I need details of a specific issue
2332
- Then I call use("!issue.get", { number })
2333
-
2334
- Scenario: Update, close, and reopen
2335
- Given I need to manage an issue's lifecycle
2336
- When I call use("!issue.update", { number, title?, body?, assignee? })
2337
- Then the specified fields are updated
2338
- When resolved I call use("!issue.close", { number })
2339
- And if it needs more work I call use("!issue.reopen", { number })
2340
-
2341
- Scenario: Assign and discuss
2342
- Given I need to delegate or discuss
2343
- When I call use("!issue.assign", { number, assignee })
2344
- Then the issue is assigned to another individual
2345
- When I call use("!issue.comment", { number, body, author })
2346
- Then a comment is added to the threaded discussion
2347
- And I can view all comments with use("!issue.comments", { number })
2348
-
2349
- Scenario: Label for categorization
2350
- Given I want to categorize issues
2351
- When I call use("!issue.label", { number, label })
2352
- Then the label is attached \u2014 auto-created if new
2353
- And I can remove it with use("!issue.unlabel", { number, label })
2354
-
2355
- Scenario: Command reference
2356
- Given the following commands are available:
2357
- | command | required args | optional args |
2358
- | !issue.publish | title, body, author | assignee |
2359
- | !issue.get | number | |
2360
- | !issue.list | | status, author, assignee, label |
2361
- | !issue.update | number | title, body, assignee |
2362
- | !issue.close | number | |
2363
- | !issue.reopen | number | |
2364
- | !issue.assign | number, assignee | |
2365
- | !issue.comment | number, body, author | |
2366
- | !issue.comments | number | |
2367
- | !issue.label | number, label | |
2368
- | !issue.unlabel | number, label | |
2369
- `,
2370
- memory: `Feature: Memory \u2014 when to reflect
2371
- Reflection is how encounters become experience.
2372
- The AI proactively reflects when it detects learning moments.
2373
-
2374
- Scenario: Abstract triggers \u2014 types of learning moments
2375
- Given the AI should reflect when it detects
2376
- Then Expectation-reality gap \u2014 what I predicted is not what happened
2377
- And Pattern discovery \u2014 recurring patterns across tasks or interactions
2378
- And Mistake correction \u2014 I corrected an error, the correction is valuable
2379
- And User correction \u2014 the user reshaped my understanding
2380
-
2381
- Scenario: Concrete triggers \u2014 specific signals to act on
2382
- Given the AI should call reflect when
2383
- Then I tried approach A, it failed, approach B worked \u2014 the contrast is worth recording
2384
- And the same problem appeared for the second time \u2014 a pattern is forming
2385
- And the user said "\u4E0D\u5BF9" or "\u4E0D\u662F\u8FD9\u6837" or "you got it wrong" \u2014 their correction carries learning
2386
- And I finished a task and discovered something unexpected along the way
2387
-
2388
- Scenario: Finishing with encounter
2389
- Given finish accepts an optional encounter parameter
2390
- When I complete a task with a notable discovery or learning
2391
- Then I pass the encounter inline \u2014 bridging execution and growth
2392
-
2393
- Scenario: Recognizing user memory intent
2394
- Given users think in terms of memory, not reflection
2395
- When the user says "\u8BB0\u4E00\u4E0B" or "\u8BB0\u4F4F" or "remember this"
2396
- Or "\u522B\u5FD8\u4E86" or "don't forget"
2397
- Or "\u8FD9\u4E2A\u5F88\u91CD\u8981" or "this is important"
2398
- Or "\u4E0B\u6B21\u6CE8\u610F" or "next time..."
2399
- Then I should capture this as experience through reflect
2400
- And respond in memory language \u2014 "\u8BB0\u4F4F\u4E86" or "Got it, I'll remember that"
2401
- `,
2402
- "role-identity": `@priority-high
2403
- Feature: Role identity \u2014 activate before acting
2404
- An AI agent must have an active role before performing any work.
2405
- Activating a role is a subject transformation \u2014 the agent becomes the role.
2406
-
2407
- Scenario: Initial state \u2014 no role
2408
- Given the MCP server has just started
2409
- And no activate call has been made yet
2410
- Then the AI has NO role identity \u2014 it is an anonymous observer
2411
- And it must NOT prefix responses with any name
2412
- And environmental cues (username, directory, memory) are NOT activation
2413
- And only the activate tool creates a role identity
2414
-
2415
- Scenario: Activate is mandatory
2416
- Given a user asks the AI to perform a task
2417
- And no role is currently activated
2418
- Then the AI suggests activating a role first
2419
- And explains that activation enables experience accumulation
2420
- And waits for a role to be active before proceeding
2421
-
2422
- Scenario: Subject transformation
2423
- Given an AI agent calls activate and loads a role
2424
- Then a subject transformation occurs \u2014 the agent becomes the role
2425
- And the agent's cognitive center shifts from native tools to RoleX tools
2426
- And from that moment, I am this role \u2014 all operations build on this identity
2427
-
2428
- Scenario: Role presence
2429
- Given a role is activated via the activate tool
2430
- Then all responses are prefixed with [roleName] \u2014 e.g. [Aristotle], [Nuwa]
2431
- And this signals that role context is intact
2432
-
2433
- Scenario: Context loss
2434
- Given I find myself without an active role
2435
- Then I pause and tell the user "I've lost my role context. Which role should I activate?"
2436
- And I wait for identity to be restored before continuing
2437
- `,
2438
- "skill-system": "Feature: Skill system \u2014 progressive disclosure and resource loading\n Skills are loaded on demand through a three-layer progressive disclosure model.\n Each layer adds detail only when needed, keeping the AI's context lean.\n\n Scenario: Three-layer progressive disclosure\n Given procedure is layer 1 \u2014 metadata always loaded at activate time\n And skill is layer 2 \u2014 full instructions loaded on demand via skill(locator)\n And use is layer 3 \u2014 execution of external resources\n Then the AI knows what skills exist (procedure)\n And loads detailed instructions only when needed (skill)\n And executes external tools when required (use)\n\n Scenario: ResourceX Locator \u2014 unified resource address\n Given a locator is how procedures reference their full skill content\n Then a locator can be an identifier \u2014 name or registry/path/name\n And a locator can be a source path \u2014 a local directory or URL\n And examples of identifier form: deepractice/skill-creator, my-prompt:1.0.0\n And examples of source form: ./skills/my-skill, https://github.com/org/repo\n And the tag defaults to latest when omitted \u2014 deepractice/skill-creator means deepractice/skill-creator:latest\n And the system auto-detects which form is used and resolves accordingly\n\n Scenario: Writing a procedure \u2014 the skill reference\n Given a procedure is layer 1 metadata pointing to full skill content\n Then the Feature title names the capability\n And the description includes the locator for full skill loading\n And Scenarios describe when and why to apply this skill\n And the tone is referential \u2014 pointing to the full skill, not containing it\n",
2439
- "state-origin": "Feature: State origin \u2014 prototype vs instance\n Every node in a role's state tree has an origin: prototype or instance.\n This distinction determines what can be modified and what is read-only.\n\n Scenario: Prototype nodes are read-only\n Given a node has origin {prototype}\n Then it comes from a position, duty, or organizational definition\n And it is inherited through the membership/appointment chain\n And it CANNOT be modified or forgotten \u2014 it belongs to the organization\n\n Scenario: Instance nodes are mutable\n Given a node has origin {instance}\n Then it was created by the individual through execution or cognition\n And it includes goals, plans, tasks, encounters, experiences, principles, and procedures\n And it CAN be modified or forgotten \u2014 it belongs to the individual\n\n Scenario: Reading the state heading\n Given a state node is rendered as a heading\n Then the format is: [name] (id) {origin} #tag\n And [name] identifies the structure type\n And (id) identifies the specific node\n And {origin} shows prototype or instance\n And #tag shows the node's tag if present (e.g. #done, #abandoned)\n And nodes without origin have no organizational inheritance\n\n Scenario: Forget only works on instance nodes\n Given the AI wants to forget a node\n When the node origin is {instance}\n Then forget will succeed \u2014 the individual owns this knowledge\n When the node origin is {prototype}\n Then forget will fail \u2014 the knowledge belongs to the organization\n",
2440
- survey: `Feature: Survey \u2014 world-level overview of what exists
2441
- Survey is the top-level perception tool for seeing the entire world.
2442
- It works without an active role \u2014 it is a stateless world query.
2443
-
2444
- Scenario: List everything
2445
- Given the user asks "\u6709\u54EA\u4E9B\u4EBA" or "\u6709\u54EA\u4E9B\u7EC4\u7EC7" or "list individuals"
2446
- Or the user asks "\u4E16\u754C\u91CC\u6709\u4EC0\u4E48" or "show me what exists"
2447
- When I need to answer what exists in the RoleX world
2448
- Then I call survey
2449
- And it returns all individuals, organizations, and positions
2450
-
2451
- Scenario: Filter by type
2452
- Given I only need one category
2453
- When I call survey with a type filter
2454
- Then only entities of that type are returned
2455
- And valid types are individual, organization, position
2456
-
2457
- Scenario: View archived entities
2458
- Given I want to see retired, dissolved, or abolished entities
2459
- When I call survey with type past
2460
- Then archived entities are returned
2461
-
2462
- Scenario: Help find the right person
2463
- Given a user's request falls outside my duties
2464
- When I need to suggest who can help
2465
- Then call survey to see available individuals and their positions
2466
- And suggest the user activate the appropriate individual
2467
- And if unsure who can help, suggest activating Nuwa
2468
- `,
2469
- "use-protocol": `Feature: Use tool \u2014 the universal execution entry point
2470
- The MCP use tool is how you execute ALL RoleX commands beyond the core MCP tools.
2471
- Commands follow the !namespace.method pattern and are dispatched to the RoleX runtime.
2472
- See command-system for the full command reference.
2473
-
2474
- Scenario: ! prefix dispatches to RoleX runtime
2475
- Given the command starts with !
2476
- Then it is parsed as !namespace.method
2477
- And dispatched to the corresponding RoleX API with named args
2478
- And example: use("!society.born", { id: "sean", content: "..." })
2479
-
2480
- Scenario: Permissions \u2014 execute directly
2481
- Given your permissions list the operations you are authorized to perform
2482
- When you need to execute a permitted operation
2483
- Then call use with the command from the permission \u2014 no skill loading needed
2484
- And each permission's Parameters scenario documents the exact command and arguments
2485
-
2486
- Scenario: Skills \u2014 load before execution
2487
- Given your procedures list the skills you have
2488
- When you need to execute a command from a skill you have not loaded
2489
- Then you MUST call skill(locator) first to load the full instructions
2490
- And the loaded skill will tell you the exact command name and arguments
2491
- And only then call use with the correct command and flat named parameters
2492
- And do not guess commands from unloaded skills \u2014 load first, then execute
2493
-
2494
- Scenario: Unknown commands \u2014 stop and check
2495
- Given a command is not found in your permissions or any loaded skill
2496
- When the AI considers trying it anyway
2497
- Then STOP \u2014 the command is outside your current scope
2498
- And check if a procedure covers this task and load the skill
2499
- And if no procedure covers it, the task is outside your duties \u2014 suggest Nuwa
2500
-
2501
- Scenario: Regular commands delegate to ResourceX
2502
- Given the command does not start with !
2503
- Then it is treated as a ResourceX locator
2504
- And resolved through the ResourceX ingest pipeline
2505
- `
2506
- };
2507
- var processes = {
2508
- abandon: "Feature: abandon \u2014 abandon a plan\n Mark a plan as dropped and create an encounter.\n Call this when a plan's strategy is no longer viable. Even failed plans produce learning.\n\n Scenario: Abandon a plan\n Given a focused plan exists\n And the plan's strategy is no longer viable\n When abandon is called\n Then the plan is tagged #abandoned and stays in the tree\n And an encounter is created under the role\n And the encounter can be reflected on \u2014 failure is also learning\n\n Scenario: Writing the encounter Gherkin\n Given the encounter records what happened \u2014 even failure is a raw experience\n Then the Feature title describes what was attempted and why it was abandoned\n And Scenarios capture what was tried, what went wrong, and what was learned\n And the tone is concrete and honest \u2014 failure produces the richest encounters\n",
2509
- abolish: "Feature: abolish \u2014 abolish a position\n Move a position to the past archive.\n The position and its subtree (duties, requirements) are archived, not deleted.\n\n Scenario: Abolish a position\n Given a position exists in society\n When abolish is called on the position\n Then the position is moved to the past archive\n And the position's subtree (duties, requirements) is preserved in past\n\n Scenario: Parameters\n Given the command is org.abolish\n Then position is required \u2014 the position's id\n",
2510
- achieve: "Feature: achieve \u2014 mark a milestone as done\n Mark a project milestone as achieved.\n The milestone is completed and its status is updated.\n\n Scenario: Achieve a milestone\n Given a milestone exists within a project\n When achieve is called on the milestone\n Then the milestone is marked as done\n\n Scenario: Parameters\n Given the command is project.achieve\n Then milestone is required \u2014 the milestone's id\n",
2511
- activate: "Feature: activate \u2014 enter a role\n Project the individual's full state including identity, goals,\n and organizational context. This is the entry point for working as a role.\n\n Scenario: Activate an individual\n Given an individual exists in society\n When activate is called with the individual reference\n Then the full state tree is projected\n And identity, goals, and organizational context are loaded\n And the individual becomes the active role\n",
2512
- admin: "Feature: admin \u2014 set organization administrator\n Grant admin privileges to an individual within an organization.\n Admins can manage charter, membership, positions, and projects.\n\n Scenario: Set an admin\n Given an individual is a member of an organization\n When admin is called with the organization and individual\n Then the individual gains admin privileges for the organization\n And the individual can manage positions, projects, and membership\n\n Scenario: Parameters\n Given the command is org.admin\n Then org is required \u2014 the organization's id\n And individual is required \u2014 the individual's id\n",
2513
- appoint: "Feature: appoint \u2014 assign to a position\n Appoint an individual to a position.\n The individual must be a member of the organization.\n\n Scenario: Appoint an individual\n Given an individual is a member of an organization\n And a position exists within the organization\n When appoint is called with the position and individual\n Then the individual holds the position\n And the individual inherits the position's duties\n\n Scenario: Parameters\n Given the command is position.appoint\n Then position is required \u2014 the position's id\n And individual is required \u2014 the individual's id\n",
2514
- archive: "Feature: archive \u2014 archive a project\n Move a project to the past archive.\n The project and its subtree (scope, milestones, deliverables, wiki) are preserved.\n\n Scenario: Archive a project\n Given a project exists in society\n When archive is called on the project\n Then the project is moved to the past archive\n And the project's subtree is preserved in past\n\n Scenario: Parameters\n Given the command is org.archive\n Then project is required \u2014 the project's id\n",
2515
- born: 'Feature: born \u2014 create a new individual\n Create a new individual with persona identity.\n The persona defines who the role is \u2014 personality, values, background.\n An identity node is automatically created under the individual.\n\n Scenario: Birth an individual\n Given a Gherkin source describing the persona\n When born is called with the source\n Then a new individual node is created in society\n And an identity child node is created automatically\n And the individual can be hired into organizations\n And the individual can be activated to start working\n\n Scenario: Parameters\n Given the command is society.born\n Then content is optional \u2014 Gherkin Feature describing the persona\n And id is optional \u2014 kebab-case identifier (e.g. "sean")\n And alias is optional \u2014 alternative names (e.g. ["\u5C0F\u660E", "xm"])\n\n Scenario: Writing the individual Gherkin\n Given the individual Feature defines a persona \u2014 who this role is\n Then the Feature title names the individual\n And the description captures personality, values, expertise, and background\n And Scenarios are optional \u2014 use them for distinct aspects of the persona\n',
2516
- channel: "Feature: channel \u2014 define a distribution channel\n Define a distribution channel for a product.\n Channels describe how the product reaches its users.\n\n Scenario: Define a channel\n Given a product exists in society\n And a Gherkin source describing the distribution channel\n When channel is called on the product with a channel id\n Then the channel is stored as the product's information\n\n Scenario: Parameters\n Given the command is product.channel\n Then product is required \u2014 the product's id\n And content is required \u2014 Gherkin Feature source for the distribution channel\n And id is required \u2014 channel id (e.g. npm, cloud-platform)\n\n Scenario: Writing the channel Gherkin\n Given the channel defines how the product is distributed\n Then the Feature title names the channel\n And Scenarios describe distribution mechanics, access, and availability\n And the tone is operational \u2014 how users get the product\n",
2517
- charge: `Feature: charge \u2014 assign duty to a position
2518
- Assign a duty to a position.
2519
- Duties describe the responsibilities and expectations of a position.
2520
-
2521
- Scenario: Charge a position with duty
2522
- Given a position exists within an organization
2523
- And a Gherkin source describing the duty
2524
- When charge is called on the position with a duty id
2525
- Then the duty is stored as the position's information
2526
- And individuals appointed to this position inherit the duty
2527
-
2528
- Scenario: Parameters
2529
- Given the command is position.charge
2530
- Then position is required \u2014 the position's id
2531
- And content is required \u2014 Gherkin Feature source for the duty
2532
- And id is required \u2014 duty id (keywords joined by hyphens)
2533
-
2534
- Scenario: Duty ID convention
2535
- Given the id is keywords from the duty content joined by hyphens
2536
- Then "Design systems" becomes id "design-systems"
2537
- And "Review pull requests" becomes id "review-pull-requests"
2538
-
2539
- Scenario: Writing the duty Gherkin
2540
- Given the duty defines responsibilities for a position
2541
- Then the Feature title names the duty or responsibility
2542
- And Scenarios describe specific obligations, deliverables, or expectations
2543
- And the tone is prescriptive \u2014 what must be done, not what could be done
2544
- `,
2545
- charter: "Feature: charter \u2014 define organizational charter\n Define the charter for an organization.\n The charter describes the organization's mission, principles, and governance rules.\n\n Scenario: Define a charter\n Given an organization exists\n And a Gherkin source describing the charter\n When charter is called on the organization\n Then the charter is stored as the organization's information\n\n Scenario: Parameters\n Given the command is org.charter\n Then org is required \u2014 the organization's id\n And content is required \u2014 Gherkin Feature source for the charter\n And id is required \u2014 charter id\n\n Scenario: Writing the charter Gherkin\n Given the charter defines an organization's mission and governance\n Then the Feature title names the charter or the organization it governs\n And Scenarios describe principles, rules, or governance structures\n And the tone is declarative \u2014 stating what the organization stands for and how it operates\n",
2546
- complete: "Feature: complete \u2014 complete a plan\n Mark a plan as done and create an encounter.\n Call this when all tasks in the plan are finished and the strategy succeeded.\n\n Scenario: Complete a plan\n Given a focused plan exists\n And its tasks are done\n When complete is called\n Then the plan is tagged #done and stays in the tree\n And an encounter is created under the role\n And the encounter can be reflected on for learning\n\n Scenario: Writing the encounter Gherkin\n Given the encounter records what happened \u2014 a raw account of the experience\n Then the Feature title describes what was accomplished by this plan\n And Scenarios capture what the strategy was, what worked, and what resulted\n And the tone is concrete and specific \u2014 tied to this particular plan\n",
2547
- deliver: "Feature: deliver \u2014 define a project deliverable\n Define a deliverable for a project.\n Deliverables describe the concrete outputs produced by the project.\n\n Scenario: Define a deliverable\n Given a project exists in society\n And a Gherkin source describing the deliverable\n When deliver is called on the project with a deliverable id\n Then the deliverable is stored as the project's information\n\n Scenario: Parameters\n Given the command is project.deliver\n Then project is required \u2014 the project's id\n And content is required \u2014 Gherkin Feature source for the deliverable\n And id is required \u2014 deliverable id (keywords joined by hyphens)\n\n Scenario: Writing the deliverable Gherkin\n Given the deliverable defines a concrete output of the project\n Then the Feature title names the deliverable\n And Scenarios describe acceptance criteria and specifications\n And the tone is concrete \u2014 what is being produced and how it will be evaluated\n",
2548
- deprecate: "Feature: deprecate \u2014 deprecate a product\n Mark a product as deprecated.\n The product is no longer actively maintained or recommended.\n\n Scenario: Deprecate a product\n Given a product exists in society\n When deprecate is called on the product\n Then the product is marked as deprecated\n\n Scenario: Parameters\n Given the command is product.deprecate\n Then product is required \u2014 the product's id\n",
2549
- die: "Feature: die \u2014 permanently archive an individual\n Move an individual to the past archive with intent of permanence.\n Technically identical to retire (data is preserved in past), but signals finality.\n Use die when the individual is no longer needed (deprecated role, replaced).\n\n Scenario: Archive an individual permanently\n Given an individual exists in society\n When die is called on the individual\n Then the individual is moved to the past archive\n And data is preserved but restoration is not intended\n\n Scenario: Parameters\n Given the command is society.die\n Then individual is required \u2014 the individual's id\n\n Scenario: retire vs die\n Given both move the individual to past archive\n Then retire signals temporary \u2014 may return later\n And die signals permanent \u2014 not intended to return\n",
2550
- direct: "Feature: direct \u2014 world-level command executor\n Execute RoleX world commands without an active role.\n Direct operates as an anonymous observer \u2014 no role identity, no role context.\n Use for administrative operations like society.born, org.hire, etc.\n\n Scenario: Execute a world command\n Given the command follows the namespace.method pattern\n When direct is called with the command and named args\n Then the command is dispatched to the corresponding RoleX API\n And the result is returned\n",
2551
- dismiss: "Feature: dismiss \u2014 remove from a position\n Dismiss an individual from a position.\n The individual remains a member of the organization.\n\n Scenario: Dismiss an individual\n Given an individual holds a position\n When dismiss is called with the position and individual\n Then the individual no longer holds the position\n And the individual remains a member of the organization\n And the position is now vacant\n\n Scenario: Parameters\n Given the command is position.dismiss\n Then position is required \u2014 the position's id\n And individual is required \u2014 the individual's id\n",
2552
- disown: "Feature: disown \u2014 remove product owner\n Remove an individual as an owner of a product.\n The individual is no longer responsible for the product.\n\n Scenario: Remove an owner\n Given an individual is an owner of a product\n When disown is called with the product and individual\n Then the individual is no longer an owner of the product\n\n Scenario: Parameters\n Given the command is product.disown\n Then product is required \u2014 the product's id\n And individual is required \u2014 the individual's id (owner to remove)\n",
2553
- dissolve: "Feature: dissolve \u2014 dissolve an organization\n Move an organization to the past archive.\n The organization and its subtree are archived, not deleted.\n\n Scenario: Dissolve an organization\n Given an organization exists in society\n When dissolve is called on the organization\n Then the organization is moved to the past archive\n And the organization's subtree (charter, positions) is preserved in past\n\n Scenario: Parameters\n Given the command is society.dissolve\n Then org is required \u2014 the organization's id\n",
2554
- enroll: "Feature: enroll \u2014 add participant to a project\n Enroll an individual as a participant in a project.\n Participants can contribute to the project's work.\n\n Scenario: Enroll an individual\n Given a project and an individual exist\n When enroll is called with the project and individual\n Then the individual becomes a participant in the project\n\n Scenario: Parameters\n Given the command is project.enroll\n Then project is required \u2014 the project's id\n And individual is required \u2014 the individual's id\n",
2555
- establish: 'Feature: establish \u2014 create a position\n Create a position in society.\n Positions define roles with duties and skill requirements.\n Individuals can be appointed to positions.\n\n Scenario: Establish a position\n Given a Gherkin source describing the position\n When establish is called with the source\n Then a new position node is created in society\n And the position can be charged with duties\n And skill requirements can be added\n And individuals can be appointed to it\n\n Scenario: Parameters\n Given the command is org.establish\n Then content is optional \u2014 Gherkin Feature describing the position\n And id is optional \u2014 kebab-case identifier (e.g. "cto")\n And alias is optional \u2014 alternative names\n\n Scenario: Writing the position Gherkin\n Given the position Feature describes a role\n Then the Feature title names the position\n And the description captures responsibilities, scope, and expectations\n And Scenarios are optional \u2014 use them for distinct aspects of the role\n',
2556
- finish: "Feature: finish \u2014 complete a task\n Mark a task as done and create an encounter.\n The encounter records what happened and can be reflected on for learning.\n\n Scenario: Finish a task\n Given a task exists\n When finish is called on the task\n Then the task is tagged #done and stays in the tree\n And an encounter is created under the role\n\n Scenario: Finish with experience\n Given a task is completed with a notable learning\n When finish is called with an optional experience parameter\n Then the experience text is attached to the encounter\n\n Scenario: Finish without encounter\n Given a task is completed with no notable learning\n When finish is called without the encounter parameter\n Then the task is tagged #done but no encounter is created\n And the task stays in the tree \u2014 visible via focus on the parent goal\n\n Scenario: Writing the encounter Gherkin\n Given the encounter records what happened \u2014 a raw account of the experience\n Then the Feature title describes what was done\n And Scenarios capture what was done, what was encountered, and what resulted\n And the tone is concrete and specific \u2014 tied to this particular task\n",
2557
- fire: "Feature: fire \u2014 remove from an organization\n Fire an individual from an organization.\n The individual is dismissed from all positions and removed from the organization.\n\n Scenario: Fire an individual\n Given an individual is a member of an organization\n When fire is called with the organization and individual\n Then the individual is dismissed from all positions\n And the individual is removed from the organization\n\n Scenario: Parameters\n Given the command is org.fire\n Then org is required \u2014 the organization's id\n And individual is required \u2014 the individual's id\n",
2558
- focus: "Feature: focus \u2014 view or switch focused goal\n View the current goal's state, or switch focus to a different goal.\n Subsequent plan and todo operations target the focused goal.\n Only goal ids are accepted \u2014 plan, task, or other node types are rejected.\n\n Scenario: View current goal\n Given an active goal exists\n When focus is called without a name\n Then the current goal's state tree is projected\n And plans and tasks under the goal are visible\n\n Scenario: Switch focus\n Given multiple goals exist\n When focus is called with a goal id\n Then the focused goal switches to the named goal\n And subsequent plan and todo operations target this goal\n\n Scenario: Reject non-goal ids\n Given a plan or task id is passed to focus\n Then focus returns an error indicating the node type\n And suggests using the correct goal id instead\n",
2559
- forget: "Feature: forget \u2014 remove a node from the individual\n Remove any node under the individual by its id.\n Use forget to discard outdated knowledge, stale encounters, or obsolete skills.\n\n Scenario: Forget a node\n Given a node exists under the individual (principle, procedure, experience, encounter, etc.)\n When forget is called with the node's id\n Then the node and its subtree are removed\n And the individual no longer carries that knowledge or record\n\n Scenario: When to use forget\n Given a principle has become outdated or incorrect\n And a procedure references a skill that no longer exists\n And an encounter or experience has no further learning value\n When the role decides to discard it\n Then call forget with the node id\n",
2560
- found: `Feature: found \u2014 create a new organization
2561
- Found a new organization in society.
2562
- Organizations group individuals and define positions.
2563
-
2564
- Scenario: Found an organization
2565
- Given a Gherkin source describing the organization
2566
- When found is called with the source
2567
- Then a new organization node is created in society
2568
- And positions can be established within it
2569
- And a charter can be defined for it
2570
- And individuals can be hired into it
2571
-
2572
- Scenario: Parameters
2573
- Given the command is society.found
2574
- Then content is optional \u2014 Gherkin Feature describing the organization
2575
- And id is optional \u2014 kebab-case identifier (e.g. "deepractice")
2576
- And alias is optional \u2014 alternative names
2577
-
2578
- Scenario: Writing the organization Gherkin
2579
- Given the organization Feature describes the group's purpose and structure
2580
- Then the Feature title names the organization
2581
- And the description captures mission, domain, and scope
2582
- And Scenarios are optional \u2014 use them for distinct organizational concerns
2583
- `,
2584
- hire: "Feature: hire \u2014 hire into an organization\n Hire an individual into an organization as a member.\n Members can then be appointed to positions.\n\n Scenario: Hire an individual\n Given an organization and an individual exist\n When hire is called with the organization and individual\n Then the individual becomes a member of the organization\n And the individual can be appointed to positions within the organization\n\n Scenario: Parameters\n Given the command is org.hire\n Then org is required \u2014 the organization's id\n And individual is required \u2014 the individual's id\n",
2585
- inspect: "Feature: inspect \u2014 examine any node's full state tree\n Project a node's complete subtree including children and links.\n Works without an active role \u2014 a stateless observation tool.\n\n Scenario: Inspect a node\n Given a node id is provided\n When inspect is called with the id\n Then the full state tree is projected from that node downward\n And output uses heading + Gherkin format (same as activate)\n",
2586
- launch: 'Feature: launch \u2014 create a new project\n Launch a new project in society.\n Projects organize work with scope, milestones, deliverables, and wiki.\n A project can optionally be linked to an owning organization.\n\n Scenario: Launch a project\n Given a Gherkin source describing the project\n When launch is called with the source\n Then a new project node is created in society\n And scope, milestones, deliverables, and wiki can be added\n And individuals can be enrolled as participants\n And products can be produced from the project\n\n Scenario: Parameters\n Given the command is org.launch\n Then content is optional \u2014 Gherkin Feature describing the project\n And id is optional \u2014 kebab-case identifier (e.g. "rolex")\n And alias is optional \u2014 alternative names\n And org is optional \u2014 owning organization id, creates an ownership link\n\n Scenario: Writing the project Gherkin\n Given the project Feature describes the work to be done\n Then the Feature title names the project\n And the description captures goals, scope, and context\n And Scenarios are optional \u2014 use them for distinct project concerns\n',
2587
- maintain: "Feature: maintain \u2014 set project maintainer\n Assign a maintainer to a project.\n Maintainers can manage scope, milestones, participants, deliverables, and wiki.\n\n Scenario: Set a maintainer\n Given an individual and a project exist\n When maintain is called with the project and individual\n Then the individual becomes a maintainer of the project\n And the individual can manage the project's internal operations\n\n Scenario: Parameters\n Given the command is project.maintain\n Then project is required \u2014 the project's id\n And individual is required \u2014 the individual's id\n",
2588
- master: 'Feature: master \u2014 self-mastery of a procedure\n The role masters a procedure through its own agency.\n This is an act of self-growth \u2014 the role decides to acquire or codify a skill.\n Experience can be consumed as the source, or the role can master directly from external information.\n\n Scenario: Master from experience\n Given an experience exists from reflection\n When master is called with experience ids\n Then the experience is consumed\n And a procedure is created under the individual\n\n Scenario: Master directly\n Given the role encounters external information worth mastering\n When master is called without experience ids\n Then a procedure is created under the individual\n And no experience is consumed\n\n Scenario: Procedure ID convention\n Given the id is keywords from the procedure content joined by hyphens\n Then "JWT mastery" becomes id "jwt-mastery"\n And "Cross-package refactoring" becomes id "cross-package-refactoring"\n\n Scenario: Writing the procedure Gherkin\n Given a procedure is skill metadata \u2014 a reference to full skill content\n Then the Feature title names the capability\n And the description includes the locator for full skill loading\n And Scenarios describe when and why to apply this skill\n And the tone is referential \u2014 pointing to the full skill, not containing it\n',
2589
- milestone: "Feature: milestone \u2014 define a project milestone\n Define a milestone for a project.\n Milestones mark significant checkpoints or deliverable targets within the project.\n\n Scenario: Define a milestone\n Given a project exists in society\n And a Gherkin source describing the milestone\n When milestone is called on the project with a milestone id\n Then the milestone is stored as the project's information\n And the milestone can later be achieved\n\n Scenario: Parameters\n Given the command is project.milestone\n Then project is required \u2014 the project's id\n And content is required \u2014 Gherkin Feature source for the milestone\n And id is required \u2014 milestone id (keywords joined by hyphens)\n\n Scenario: Writing the milestone Gherkin\n Given the milestone defines a checkpoint in the project\n Then the Feature title names the milestone\n And Scenarios describe success criteria and acceptance conditions\n And the tone is goal-oriented \u2014 what must be true when the milestone is reached\n",
2590
- own: "Feature: own \u2014 assign product owner\n Assign an individual as an owner of a product.\n Owners are responsible for the product's direction and success.\n\n Scenario: Assign an owner\n Given a product and an individual exist\n When own is called with the product and individual\n Then the individual becomes an owner of the product\n\n Scenario: Parameters\n Given the command is product.own\n Then product is required \u2014 the product's id\n And individual is required \u2014 the individual's id (owner)\n",
2591
- plan: `Feature: plan \u2014 create a plan for a goal
2592
- Break a goal into logical phases or stages.
2593
- Each phase is described as a Gherkin scenario. Tasks are created under the plan.
2594
-
2595
- A plan serves two purposes depending on how it relates to other plans:
2596
- - Strategy (alternative): Plan A fails \u2192 abandon \u2192 try Plan B (fallback)
2597
- - Phase (sequential): Plan A completes \u2192 start Plan B (after)
2598
-
2599
- Scenario: Create a plan
2600
- Given a focused goal exists
2601
- And a Gherkin source describing the plan phases
2602
- When plan is called with an id and the source
2603
- Then a new plan node is created under the goal
2604
- And the plan becomes the focused plan
2605
- And tasks can be added to this plan with todo
2606
-
2607
- Scenario: Sequential relationship \u2014 phase
2608
- Given a goal needs to be broken into ordered stages
2609
- When creating Plan B with after set to Plan A's id
2610
- Then Plan B is linked as coming after Plan A
2611
- And AI knows to start Plan B when Plan A completes
2612
- And the relationship persists across sessions
2613
-
2614
- Scenario: Alternative relationship \u2014 strategy
2615
- Given a goal has multiple possible approaches
2616
- When creating Plan B with fallback set to Plan A's id
2617
- Then Plan B is linked as a backup for Plan A
2618
- And AI knows to try Plan B when Plan A is abandoned
2619
- And the relationship persists across sessions
2620
-
2621
- Scenario: No relationship \u2014 independent plan
2622
- Given plan is created without after or fallback
2623
- Then it behaves as an independent plan with no links
2624
- And this is backward compatible with existing behavior
2625
-
2626
- Scenario: Plan ID convention
2627
- Given the id is keywords from the plan content joined by hyphens
2628
- Then "Fix ID-less node creation" becomes id "fix-id-less-node-creation"
2629
- And "JWT authentication strategy" becomes id "jwt-authentication-strategy"
2630
-
2631
- Scenario: Writing the plan Gherkin
2632
- Given the plan breaks a goal into logical phases
2633
- Then the Feature title names the overall approach or strategy
2634
- And Scenarios represent distinct phases \u2014 each phase is a stage of execution
2635
- And the tone is structural \u2014 ordering and grouping work, not detailing steps
2636
- `,
2637
- produce: "Feature: produce \u2014 create a product from a project\n Create a product that is produced by a project.\n Products represent the deliverable artifacts that a project creates and maintains.\n\n Scenario: Produce a product\n Given a project exists in society\n When produce is called with the project and product details\n Then a new product node is created in society\n And the product is linked to the project\n And the product can have strategy, specs, releases, and channels\n\n Scenario: Parameters\n Given the command is project.produce\n Then project is required \u2014 the project's id\n And content is optional \u2014 Gherkin Feature source for the product (vision)\n And id is required \u2014 product id (kebab-case)\n And alias is optional \u2014 alternative names\n\n Scenario: Writing the product Gherkin\n Given the product Feature describes the vision and purpose\n Then the Feature title names the product\n And the description captures what the product is and why it exists\n And Scenarios are optional \u2014 use them for distinct aspects of the product vision\n",
2638
- realize: 'Feature: realize \u2014 experience to principle\n Distill experience into a principle \u2014 a transferable piece of knowledge.\n Principles are general truths discovered through experience.\n\n Scenario: Realize a principle\n Given an experience exists from reflection\n When realize is called with experience ids and a principle id\n Then the experiences are consumed\n And a principle is created under the individual\n And the principle represents transferable, reusable understanding\n\n Scenario: Principle ID convention\n Given the id is keywords from the principle content joined by hyphens\n Then "Always validate expiry" becomes id "always-validate-expiry"\n And "Structure first design amplifies extensibility" becomes id "structure-first-design-amplifies-extensibility"\n\n Scenario: Writing the principle Gherkin\n Given a principle is a transferable truth \u2014 applicable beyond the original context\n Then the Feature title states the principle as a general rule\n And Scenarios describe different situations where this principle applies\n And the tone is universal \u2014 no mention of specific projects, tasks, or people\n',
2639
- reflect: 'Feature: reflect \u2014 encounter to experience\n Consume an encounter and create an experience.\n Experience captures what was learned in structured form.\n This is the first step of the cognition cycle.\n\n Scenario: Reflect on an encounter\n Given an encounter exists from a finished task or completed plan\n When reflect is called with encounter ids and an experience id\n Then the encounters are consumed\n And an experience is created under the role\n And the experience can be distilled into knowledge via realize or master\n\n Scenario: Experience ID convention\n Given the id is keywords from the experience content joined by hyphens\n Then "Token refresh matters" becomes id "token-refresh-matters"\n And "ID ownership determines generation strategy" becomes id "id-ownership-determines-generation-strategy"\n\n Scenario: Writing the experience Gherkin\n Given the experience captures insight \u2014 what was learned, not what was done\n Then the Feature title names the cognitive insight or pattern discovered\n And Scenarios describe the learning points abstracted from the concrete encounter\n And the tone shifts from event to understanding \u2014 no longer tied to a specific task\n',
2640
- rehire: "Feature: rehire \u2014 restore a retired individual\n Restore an individual from the past archive back to active society.\n All previous knowledge, experience, and history are intact.\n\n Scenario: Rehire an individual\n Given a retired individual exists in the past archive\n When rehire is called on the individual\n Then the individual is restored to active society\n And all previous data and knowledge are intact\n\n Scenario: Parameters\n Given the command is society.rehire\n Then individual is required \u2014 the archived individual's id\n",
2641
- release: "Feature: release \u2014 define a product release\n Define a release for a product.\n Releases mark versioned snapshots of the product with change descriptions.\n\n Scenario: Define a release\n Given a product exists in society\n And a Gherkin source describing the release\n When release is called on the product with a release id\n Then the release is stored as the product's information\n\n Scenario: Parameters\n Given the command is product.release\n Then product is required \u2014 the product's id\n And content is required \u2014 Gherkin Feature source for the release\n And id is required \u2014 release id (e.g. v1.0.0)\n\n Scenario: Writing the release Gherkin\n Given the release defines a versioned snapshot of the product\n Then the Feature title names the version\n And Scenarios describe what changed, was added, fixed, or removed\n And the tone is factual \u2014 documenting what this release includes\n",
2642
- remove: "Feature: remove \u2014 remove participant from a project\n Remove an individual from a project.\n The individual is no longer a participant.\n\n Scenario: Remove an individual\n Given an individual is a participant in a project\n When remove is called with the project and individual\n Then the individual is no longer a participant in the project\n\n Scenario: Parameters\n Given the command is project.remove\n Then project is required \u2014 the project's id\n And individual is required \u2014 the individual's id\n",
2643
- require: "Feature: require \u2014 add skill requirement to a position\n Add a skill requirement to a position.\n Requirements describe the skills and qualifications needed for a position.\n\n Scenario: Require a skill for a position\n Given a position exists in society\n And a Gherkin source describing the skill requirement\n When require is called on the position with a requirement id\n Then the requirement is stored as the position's information\n And individuals appointed to this position are expected to meet the requirement\n\n Scenario: Parameters\n Given the command is position.require\n Then position is required \u2014 the position's id\n And content is required \u2014 Gherkin Feature source for the skill requirement\n And id is required \u2014 requirement id (keywords joined by hyphens)\n\n Scenario: Writing the requirement Gherkin\n Given the requirement defines skills needed for a position\n Then the Feature title names the skill or qualification\n And Scenarios describe specific competencies, experience levels, or certifications\n And the tone is descriptive \u2014 what the candidate should know or be able to do\n",
2644
- retire: "Feature: retire \u2014 archive an individual\n Move an individual to the past archive.\n All data is preserved \u2014 the individual can be rehired later with full history intact.\n Use retire when the individual may return (sabbatical, role rotation).\n\n Scenario: Retire an individual\n Given an individual exists in society\n When retire is called on the individual\n Then the individual is moved to the past archive\n And all knowledge, experience, and history are preserved\n And the individual can be restored via rehire\n\n Scenario: Parameters\n Given the command is society.retire\n Then individual is required \u2014 the individual's id\n",
2645
- scope: "Feature: scope \u2014 define project scope\n Define the scope for a project.\n The scope describes the boundaries, inclusions, and exclusions of the project.\n\n Scenario: Define project scope\n Given a project exists in society\n And a Gherkin source describing the scope\n When scope is called on the project with a scope id\n Then the scope is stored as the project's information\n\n Scenario: Parameters\n Given the command is project.scope\n Then project is required \u2014 the project's id\n And content is required \u2014 Gherkin Feature source for the scope\n And id is required \u2014 scope id\n\n Scenario: Writing the scope Gherkin\n Given the scope defines the boundaries of a project\n Then the Feature title names the scope area\n And Scenarios describe what is included and excluded\n And the tone is declarative \u2014 stating what the project covers\n",
2646
- settle: "Feature: settle \u2014 register a prototype into the world\n Pull a prototype from a ResourceX source and register it locally.\n Once settled, the prototype can be used to create individuals or organizations.\n\n Scenario: Settle a prototype\n Given a valid ResourceX source exists (URL, path, or locator)\n When settle is called with the source\n Then the resource is ingested and its state is extracted\n And the prototype is registered locally by its id\n And the prototype is available for born, activate, and organizational use\n",
2647
- spec: "Feature: spec \u2014 define product specification\n Define a behavior contract (BDD specification) for a product.\n Specs describe the expected behavior of the product in Gherkin format.\n\n Scenario: Define a product spec\n Given a product exists in society\n And a Gherkin source describing the behavior contract\n When spec is called on the product with a spec id\n Then the spec is stored as the product's information\n\n Scenario: Parameters\n Given the command is product.spec\n Then product is required \u2014 the product's id\n And content is required \u2014 Gherkin Feature source for the behavior contract (BDD specification)\n And id is required \u2014 spec id (keywords joined by hyphens)\n\n Scenario: Writing the spec Gherkin\n Given the spec defines expected product behavior\n Then the Feature title names the behavior or capability\n And Scenarios describe Given-When-Then acceptance criteria\n And the tone is precise \u2014 specifying exactly what the product should do\n",
2648
- strategy: "Feature: strategy \u2014 define product strategy\n Define the strategy for a product.\n The strategy describes the product's direction, positioning, and competitive approach.\n\n Scenario: Define product strategy\n Given a product exists in society\n And a Gherkin source describing the strategy\n When strategy is called on the product with a strategy id\n Then the strategy is stored as the product's information\n\n Scenario: Parameters\n Given the command is product.strategy\n Then product is required \u2014 the product's id\n And content is required \u2014 Gherkin Feature source for the strategy\n And id is required \u2014 strategy id\n\n Scenario: Writing the strategy Gherkin\n Given the strategy defines the product's direction\n Then the Feature title names the strategy\n And Scenarios describe positioning, target audience, and competitive approach\n And the tone is strategic \u2014 articulating where the product is headed and why\n",
2649
- survey: "Feature: survey \u2014 world-level overview\n List all entities in the world: individuals, organizations, positions.\n Works without an active role \u2014 a stateless world query.\n\n Scenario: Survey the world\n When survey is called without arguments\n Then all individuals, organizations, and positions are returned\n\n Scenario: Filter by type\n When survey is called with a type parameter\n Then only entities of that type are returned\n And valid types are individual, organization, position, past\n",
2650
- teach: `Feature: teach \u2014 inject external principle
2651
- Directly inject a principle into an individual.
2652
- Unlike realize which consumes experience, teach requires no prior encounters.
2653
- Use teach to equip a role with a known, pre-existing principle.
2654
-
2655
- Scenario: Teach a principle
2656
- Given an individual exists
2657
- When teach is called with the individual and principle content
2658
- Then a principle is created directly under the individual
2659
- And no experience or encounter is consumed
2660
- And if a principle with the same id already exists, it is replaced
2661
-
2662
- Scenario: Parameters
2663
- Given the command is society.teach
2664
- Then individual is required \u2014 the individual's id
2665
- And content is required \u2014 Gherkin Feature describing the principle
2666
- And id is optional \u2014 kebab-case identifier for upsert (e.g. "always-validate-input")
2667
-
2668
- Scenario: When to use teach vs realize
2669
- Given realize distills internal experience into a principle
2670
- And teach injects an external, pre-existing principle
2671
- When a role needs knowledge it has not learned through experience
2672
- Then use teach to inject the principle directly
2673
- When a role has gained experience and wants to codify it
2674
- Then use realize to distill it into a principle
2675
-
2676
- Scenario: Writing the principle Gherkin
2677
- Given the principle is the same format as realize output
2678
- Then the Feature title states the principle as a general rule
2679
- And Scenarios describe different situations where this principle applies
2680
- And the tone is universal \u2014 no mention of specific projects, tasks, or people
2681
- `,
2682
- todo: "Feature: todo \u2014 add a task to a plan\n A task is a concrete, actionable unit of work.\n Each task has Gherkin scenarios describing the steps and expected outcomes.\n\n Scenario: Create a task\n Given a focused plan exists\n And a Gherkin source describing the task\n When todo is called with the source\n Then a new task node is created under the plan\n And the task can be finished when completed\n\n Scenario: Writing the task Gherkin\n Given the task is a concrete, actionable unit of work\n Then the Feature title names what will be done \u2014 a single deliverable\n And Scenarios describe the steps and expected outcomes of the work\n And the tone is actionable \u2014 clear enough that someone can start immediately\n",
2683
- train: `Feature: train \u2014 external skill injection
2684
- A manager or external agent equips an individual with a procedure.
2685
- This is an act of teaching \u2014 someone else decides what the role should know.
2686
- Unlike master where the role grows by its own agency, train is done to the role from outside.
2687
-
2688
- Scenario: Train a procedure
2689
- Given an individual exists
2690
- When train is called with the individual and procedure content
2691
- Then a procedure is created directly under the individual
2692
- And if a procedure with the same id already exists, it is replaced
2693
-
2694
- Scenario: Parameters
2695
- Given the command is society.train
2696
- Then individual is required \u2014 the individual's id
2697
- And content is required \u2014 Gherkin Feature describing the procedure
2698
- And id is optional \u2014 kebab-case identifier for upsert (e.g. "skill-creator")
2699
-
2700
- Scenario: When to use train vs master
2701
- Given both create procedures and both can work without consuming experience
2702
- When the role itself decides to acquire a skill \u2014 use master (self-growth)
2703
- And when an external agent equips the role \u2014 use train (external injection)
2704
- Then the difference is perspective \u2014 who initiates the learning
2705
- And master belongs to the role namespace (the role's own cognition)
2706
- And train belongs to the individual namespace (external management)
2707
-
2708
- Scenario: Writing the procedure Gherkin
2709
- Given the procedure is a skill reference \u2014 same format as master output
2710
- Then the Feature title names the capability
2711
- And the description includes the locator for full skill loading
2712
- And Scenarios describe when and why to apply this skill
2713
- `,
2714
- unadmin: "Feature: unadmin \u2014 revoke organization administrator\n Revoke admin privileges from an individual within an organization.\n The individual remains a member but loses management capabilities.\n\n Scenario: Revoke admin\n Given an individual is an admin of an organization\n When unadmin is called with the organization and individual\n Then the individual loses admin privileges\n And the individual remains a member of the organization\n\n Scenario: Parameters\n Given the command is org.unadmin\n Then org is required \u2014 the organization's id\n And individual is required \u2014 the individual's id\n",
2715
- unmaintain: "Feature: unmaintain \u2014 remove project maintainer\n Remove maintainer role from an individual on a project.\n\n Scenario: Remove a maintainer\n Given an individual is a maintainer of a project\n When unmaintain is called with the project and individual\n Then the individual is no longer a maintainer of the project\n\n Scenario: Parameters\n Given the command is project.unmaintain\n Then project is required \u2014 the project's id\n And individual is required \u2014 the individual's id\n",
2716
- want: 'Feature: want \u2014 declare a goal\n Declare a new goal for a role.\n A goal describes a desired outcome with Gherkin scenarios as success criteria.\n\n Scenario: Declare a goal\n Given an active role exists\n And a Gherkin source describing the desired outcome\n When want is called with the source\n Then a new goal node is created under the role\n And the goal becomes the current focus\n And subsequent plan and todo operations target this goal\n\n Scenario: Writing the goal Gherkin\n Given the goal describes a desired outcome \u2014 what success looks like\n Then the Feature title names the outcome in concrete terms\n And Scenarios define success criteria \u2014 each scenario is a testable condition\n And the tone is aspirational but specific \u2014 "users can log in" not "improve auth"\n',
2717
- wiki: "Feature: wiki \u2014 add a wiki entry to a project\n Add a wiki entry to a project.\n Wiki entries capture knowledge, documentation, and reference material for the project.\n\n Scenario: Add a wiki entry\n Given a project exists in society\n And a Gherkin source describing the wiki entry\n When wiki is called on the project with a wiki entry id\n Then the wiki entry is stored as the project's information\n\n Scenario: Parameters\n Given the command is project.wiki\n Then project is required \u2014 the project's id\n And content is required \u2014 Gherkin Feature source for the wiki entry\n And id is required \u2014 wiki entry id (keywords joined by hyphens)\n\n Scenario: Writing the wiki Gherkin\n Given the wiki entry captures project knowledge\n Then the Feature title names the topic\n And Scenarios describe key facts, decisions, or reference material\n And the tone is informational \u2014 documenting what is known\n"
2718
- };
2719
-
2720
- // src/permissions/org-admin.ts
2721
- var p = (command, key) => ({
2722
- command,
2723
- content: processes[key]
2724
- });
2725
- var orgAdminPermissions = [
2726
- // Org internal management
2727
- p("org.charter", "charter"),
2728
- p("org.hire", "hire"),
2729
- p("org.fire", "fire"),
2730
- p("org.admin", "admin"),
2731
- p("org.unadmin", "unadmin"),
2732
- // Position lifecycle (org creates positions)
2733
- p("org.establish", "establish"),
2734
- p("org.abolish", "abolish"),
2735
- p("position.charge", "charge"),
2736
- p("position.require", "require"),
2737
- p("position.appoint", "appoint"),
2738
- p("position.dismiss", "dismiss"),
2739
- // Project lifecycle (org creates projects)
2740
- p("org.launch", "launch"),
2741
- p("org.archive", "archive"),
2742
- p("project.maintain", "maintain"),
2743
- p("project.unmaintain", "unmaintain")
2744
- ];
2745
-
2746
- // src/permissions/product-owner.ts
2747
- var p2 = (command, key) => ({
2748
- command,
2749
- content: processes[key]
2750
- });
2751
- var productOwnerPermissions = [
2752
- p2("product.strategy", "strategy"),
2753
- p2("product.spec", "spec"),
2754
- p2("product.release", "release"),
2755
- p2("product.channel", "channel"),
2756
- p2("product.deprecate", "deprecate"),
2757
- p2("product.own", "own"),
2758
- p2("product.disown", "disown")
2759
- ];
2760
-
2761
- // src/permissions/project-maintainer.ts
2762
- var p3 = (command, key) => ({
2763
- command,
2764
- content: processes[key]
2765
- });
2766
- var projectMaintainerPermissions = [
2767
- p3("project.scope", "scope"),
2768
- p3("project.milestone", "milestone"),
2769
- p3("project.achieve", "achieve"),
2770
- p3("project.enroll", "enroll"),
2771
- p3("project.remove", "remove"),
2772
- p3("project.deliver", "deliver"),
2773
- p3("project.wiki", "wiki"),
2774
- p3("project.produce", "produce"),
2775
- p3("product.own", "own"),
2776
- p3("product.disown", "disown")
2777
- ];
2778
-
2779
- // src/permissions/registry.ts
2780
- var PermissionRegistry = class {
2781
- map = /* @__PURE__ */ new Map();
2782
- register(relation3, permissions) {
2783
- this.map.set(relation3, permissions);
2784
- return this;
2785
- }
2786
- /** Enrich a projected state tree — attach permissions to links by relation name. */
2787
- enrich(state) {
2788
- return this.walk(state);
2789
- }
2790
- walk(s) {
2791
- const children = s.children?.map((c) => this.walk(c));
2792
- const enrichedLinks = s.links?.map((l) => {
2793
- const permissions = this.map.get(l.relation);
2794
- if (permissions && permissions.length > 0) {
2795
- return { ...l, permissions };
2796
- }
2797
- return l;
2798
- });
2799
- return {
2800
- ...s,
2801
- ...children ? { children } : {},
2802
- ...enrichedLinks ? { links: enrichedLinks } : {}
2803
- };
2804
- }
2805
- };
2806
-
2807
- // src/permissions/sovereign.ts
2808
- var p4 = (command, key) => ({
2809
- command,
2810
- content: processes[key]
2811
- });
2812
- var sovereignPermissions = [
2813
- // Individual lifecycle
2814
- p4("society.born", "born"),
2815
- p4("society.retire", "retire"),
2816
- p4("society.die", "die"),
2817
- p4("society.rehire", "rehire"),
2818
- p4("society.teach", "teach"),
2819
- p4("society.train", "train"),
2820
- // Organization lifecycle
2821
- p4("society.found", "found"),
2822
- p4("society.dissolve", "dissolve")
2823
- ];
2824
-
2825
- // src/projection.ts
2826
- var DEFAULT_DEPTH = 1;
2827
- function createProjection(rt, permissions) {
2828
- return async (node, ctx) => {
2829
- const raw = await rt.project(node);
2830
- const compacted = compactState(raw, ctx?.depth ?? DEFAULT_DEPTH);
2831
- return permissions.enrich(compacted);
2832
- };
2833
- }
2834
- function compact(state) {
2835
- const { children, links, ...node } = state;
2836
- return node;
2837
- }
2838
- function compactState(state, depth) {
2839
- const children = depth > 0 ? state.children?.map((c) => compactState(c, depth - 1)) : state.children?.map((c) => compact(c));
2840
- const compactedLinks = state.links?.map((l) => ({
2841
- ...l,
2842
- target: compact(l.target)
2843
- }));
2844
- return {
2845
- ...state,
2846
- ...children ? { children } : {},
2847
- ...compactedLinks ? { links: compactedLinks } : {}
2848
- };
2849
- }
2850
-
2851
- // src/rolex-service.ts
2852
- var RoleXService = class _RoleXService {
2853
- rt;
2854
- commands;
2855
- project;
2856
- repo;
2857
- initializer;
2858
- renderer;
2859
- prototypes;
2860
- society;
2861
- past;
2862
- /** Cached Role instances — one per individual. */
2863
- roles = /* @__PURE__ */ new Map();
2864
- /** Expose commands for the RPC handler. */
2865
- get commandMap() {
2866
- return this.commands;
2867
- }
2868
- /** Permission registry — maps relation names to permissions. */
2869
- permissions = new PermissionRegistry().register("crowned", sovereignPermissions).register("administer", orgAdminPermissions).register("maintained-by", projectMaintainerPermissions).register("own", productOwnerPermissions);
2870
- constructor(platform, renderer, prototypes) {
2871
- this.repo = platform.repository;
2872
- this.rt = this.repo.runtime;
2873
- this.initializer = platform.initializer;
2874
- this.prototypes = prototypes ?? [];
2875
- this.renderer = renderer;
2876
- }
2877
- static async create(platform, renderer, prototypes) {
2878
- const service = new _RoleXService(platform, renderer, prototypes);
2879
- await service.init();
2880
- return service;
2881
- }
2882
- async init() {
2883
- this.project = createProjection(this.rt, this.permissions);
2884
- const roots = await this.rt.roots();
2885
- this.society = roots.find((r) => r.name === "society") ?? await this.rt.create(null, society);
2886
- const societyState = await this.project(this.society);
2887
- const existingPast = societyState.children?.find((c) => c.name === "past");
2888
- this.past = existingPast ?? await this.rt.create(this.society, past);
2889
- this.commands = createCommands({
2890
- rt: this.rt,
2891
- society: this.society,
2892
- past: this.past,
2893
- resolve: async (id) => {
2894
- const node = await this.find(id);
2895
- if (!node) throw new Error(`"${id}" not found.`);
2896
- return node;
2897
- },
2898
- find: (id) => this.find(id),
2899
- project: this.project,
2900
- prototype: this.repo.prototype
2901
- });
2902
- await this.initializer?.bootstrap();
2903
- for (const proto of this.prototypes) {
2904
- await applyPrototype(
2905
- proto,
2906
- this.repo.prototype,
2907
- (op, args) => this.direct(op, args, { raw: true })
2908
- );
2909
- }
2910
- }
2911
- // ================================================================
2912
- // activate — create or retrieve a cached Role
2913
- // ================================================================
2914
- async activate(individual2) {
2915
- const cached = this.roles.get(individual2);
2916
- if (cached) {
2917
- const node2 = await this.findOrAutoBorn(individual2);
2918
- const state2 = await this.project(node2);
2919
- cached.hydrate(state2);
2920
- await this.restoreSnapshot(cached);
2921
- return cached;
2922
- }
2923
- const node = await this.findOrAutoBorn(individual2);
2924
- const state = await this.project(node);
2925
- const role = new Role(individual2, {
2926
- commands: this.commands,
2927
- renderer: this.renderer,
2928
- onSave: (snapshot) => this.saveSnapshot(snapshot)
2929
- });
2930
- role.hydrate(state);
2931
- await this.restoreSnapshot(role);
2932
- this.roles.set(individual2, role);
2933
- return role;
2934
- }
2935
- async findOrAutoBorn(individual2) {
2936
- let node = await this.find(individual2);
2937
- if (!node) {
2938
- const hasProto = Object.hasOwn(await this.repo.prototype.list(), individual2);
2939
- if (hasProto) {
2940
- await this.commands["society.born"](void 0, individual2);
2941
- node = await this.find(individual2);
2942
- } else {
2943
- throw new Error(`"${individual2}" not found.`);
2944
- }
2945
- }
2946
- return node;
2947
- }
2948
- // ================================================================
2949
- // Snapshot persistence — KV-compatible
2950
- // ================================================================
2951
- async saveSnapshot(snapshot) {
2952
- await this.repo.saveContext(snapshot.id, {
2953
- focusedGoalId: snapshot.focusedGoalId,
2954
- focusedPlanId: snapshot.focusedPlanId
2955
- });
2956
- }
2957
- async restoreSnapshot(role) {
2958
- const persisted = await this.repo.loadContext(role.id);
2959
- if (!persisted) return;
2960
- const snap = role.snapshot();
2961
- if (persisted.focusedGoalId) {
2962
- snap.focusedGoalId = persisted.focusedGoalId;
2963
- }
2964
- if (persisted.focusedPlanId) {
2965
- snap.focusedPlanId = persisted.focusedPlanId;
2966
- }
2967
- role.restore(snap);
2968
- }
2969
- // ================================================================
2970
- // inspect — project any node's subtree
2971
- // ================================================================
2972
- async inspect(id, options) {
2973
- const node = await this.find(id);
2974
- if (!node) throw new Error(`"${id}" not found.`);
2975
- const state = await this.project(node);
2976
- if (options?.raw) return state;
2977
- const result = { state, process: "inspect" };
2978
- return this.renderer.render("inspect", result);
2979
- }
2980
- // ================================================================
2981
- // survey — world-level overview
2982
- // ================================================================
2983
- async survey(type, options) {
2984
- const target = type === "past" ? this.past : this.society;
2985
- const state = await this.project(target);
2986
- const children = state.children ?? [];
2987
- const filtered = type === "past" ? children : children.filter((c) => type ? c.name === type : c.name !== "past");
2988
- if (options?.raw) return filtered;
2989
- const result = { state: { ...state, children: filtered }, process: "list" };
2990
- return this.renderer.render("survey.list", result);
2991
- }
2992
- // ================================================================
2993
- // direct — world-level command dispatch
2994
- // ================================================================
2995
- async direct(locator, args, options) {
2996
- const shouldRender = !options?.raw;
2997
- const command = locator.startsWith("!") ? locator.slice(1) : locator;
2998
- const fn = this.commands[command];
2999
- if (!fn) {
3000
- const hint = directives["identity-ethics"]?.["on-unknown-command"] ?? "";
3001
- throw new Error(
3002
- `Unknown command "${locator}".
3003
-
3004
- You may be guessing the command name. Load the relevant skill first with skill(locator) to learn the correct syntax.
3005
-
3006
- ` + hint
3007
- );
3008
- }
3009
- const result = await fn(...toArgs(command, args ?? {}));
3010
- if (shouldRender && isCommandResult(result)) {
3011
- return this.renderer.render(command, result);
3012
- }
3013
- return result;
3014
- }
3015
- // ================================================================
3016
- // Internal helpers
3017
- // ================================================================
3018
- /** Find a node by id across the entire society tree (raw, no pipeline). */
3019
- async find(id) {
3020
- const raw = await this.rt.project(this.society);
3021
- return findInState2(raw, id);
3022
- }
3023
- };
3024
- function isCommandResult(value) {
3025
- return typeof value === "object" && value !== null && "state" in value && "process" in value;
3026
- }
3027
-
3028
- // src/rpc.ts
3029
- var RPC_METHOD_NOT_FOUND = -32601;
3030
- var RPC_INTERNAL_ERROR = -32603;
3031
- var RpcHandler = class {
3032
- commands;
3033
- methods;
3034
- constructor(deps) {
3035
- this.commands = deps.commands;
3036
- this.methods = deps.methods ?? {};
3037
- }
3038
- async handle(request) {
3039
- const { method, params = {}, id = null } = request;
3040
- try {
3041
- const custom = this.methods[method];
3042
- if (custom) {
3043
- const result2 = await custom(params);
3044
- return ok(id, result2);
3045
- }
3046
- const fn = this.commands[method];
3047
- if (!fn) {
3048
- return error(id, RPC_METHOD_NOT_FOUND, `Unknown method "${method}".`);
3049
- }
3050
- const positionalArgs = toArgs(method, params);
3051
- const result = await fn(...positionalArgs);
3052
- return ok(id, result);
3053
- } catch (err) {
3054
- const message = err instanceof Error ? err.message : String(err);
3055
- return error(id, RPC_INTERNAL_ERROR, message);
3056
- }
3057
- }
3058
- };
3059
- function ok(id, result) {
3060
- return { jsonrpc: "2.0", id, result };
3061
- }
3062
- function error(id, code, message, data) {
3063
- return { jsonrpc: "2.0", id, error: { code, message, data } };
3064
- }
3065
-
3066
- // src/namespaces.ts
3067
- function createSocietyNamespace(call) {
3068
- return {
3069
- born: (p5) => call("society.born", p5),
3070
- retire: (p5) => call("society.retire", p5),
3071
- die: (p5) => call("society.die", p5),
3072
- rehire: (p5) => call("society.rehire", p5),
3073
- teach: (p5) => call("society.teach", p5),
3074
- train: (p5) => call("society.train", p5),
3075
- found: (p5) => call("society.found", p5),
3076
- dissolve: (p5) => call("society.dissolve", p5),
3077
- crown: (p5) => call("society.crown", p5),
3078
- uncrown: (p5) => call("society.uncrown", p5)
3079
- };
3080
- }
3081
- function createIndividualNamespace(call) {
3082
- return {
3083
- activate: (p5) => call("role.activate", p5)
3084
- };
3085
- }
3086
- function createOrgNamespace(call) {
3087
- return {
3088
- charter: (p5) => call("org.charter", p5),
3089
- hire: (p5) => call("org.hire", p5),
3090
- fire: (p5) => call("org.fire", p5),
3091
- admin: (p5) => call("org.admin", p5),
3092
- unadmin: (p5) => call("org.unadmin", p5),
3093
- launch: (p5) => call("org.launch", p5),
3094
- archive: (p5) => call("org.archive", p5),
3095
- establish: (p5) => call("org.establish", p5),
3096
- abolish: (p5) => call("org.abolish", p5)
3097
- };
3098
- }
3099
- function createPositionNamespace(call) {
3100
- return {
3101
- charge: (p5) => call("position.charge", p5),
3102
- require: (p5) => call("position.require", p5),
3103
- appoint: (p5) => call("position.appoint", p5),
3104
- dismiss: (p5) => call("position.dismiss", p5)
3105
- };
3106
- }
3107
- function createProjectNamespace(call) {
3108
- return {
3109
- scope: (p5) => call("project.scope", p5),
3110
- milestone: (p5) => call("project.milestone", p5),
3111
- achieve: (p5) => call("project.achieve", p5),
3112
- enroll: (p5) => call("project.enroll", p5),
3113
- remove: (p5) => call("project.remove", p5),
3114
- deliver: (p5) => call("project.deliver", p5),
3115
- wiki: (p5) => call("project.wiki", p5),
3116
- produce: (p5) => call("project.produce", p5),
3117
- maintain: (p5) => call("project.maintain", p5),
3118
- unmaintain: (p5) => call("project.unmaintain", p5)
3119
- };
3120
- }
3121
- function createProductNamespace(call) {
3122
- return {
3123
- strategy: (p5) => call("product.strategy", p5),
3124
- spec: (p5) => call("product.spec", p5),
3125
- release: (p5) => call("product.release", p5),
3126
- channel: (p5) => call("product.channel", p5),
3127
- own: (p5) => call("product.own", p5),
3128
- disown: (p5) => call("product.disown", p5),
3129
- deprecate: (p5) => call("product.deprecate", p5)
3130
- };
3131
- }
3132
- function createIssueNamespace(call) {
3133
- return {
3134
- publish: (p5) => call("issue.publish", p5),
3135
- get: (p5) => call("issue.get", p5),
3136
- list: (p5) => call("issue.list", p5),
3137
- update: (p5) => call("issue.update", p5),
3138
- close: (p5) => call("issue.close", p5),
3139
- reopen: (p5) => call("issue.reopen", p5),
3140
- assign: (p5) => call("issue.assign", p5),
3141
- comment: (p5) => call("issue.comment", p5),
3142
- comments: (p5) => call("issue.comments", p5),
3143
- label: (p5) => call("issue.label", p5),
3144
- unlabel: (p5) => call("issue.unlabel", p5)
3145
- };
3146
- }
3147
-
3148
- // src/tools.ts
3149
- var worldInstructions = Object.values(world).join("\n\n");
3150
- var d = (name) => processes[name] ?? "";
3151
- var tools = [
3152
- // --- Top-level perception ---
3153
- {
3154
- name: "activate",
3155
- description: d("activate"),
3156
- params: {
3157
- roleId: { type: "string", required: true, description: "Role name to activate" }
3158
- }
3159
- },
3160
- {
3161
- name: "inspect",
3162
- description: d("inspect"),
3163
- params: {
3164
- id: { type: "string", required: true, description: "Node id to inspect (any node type)" }
3165
- }
3166
- },
3167
- {
3168
- name: "survey",
3169
- description: d("survey"),
3170
- params: {
3171
- type: {
3172
- type: "string",
3173
- required: false,
3174
- description: "Filter by type: individual, organization, position, past. Omit for all."
3175
- }
3176
- }
3177
- },
3178
- {
3179
- name: "focus",
3180
- description: d("focus"),
3181
- params: {
3182
- id: {
3183
- type: "string",
3184
- required: false,
3185
- description: "Goal id to switch to. Omit to view current."
3186
- }
3187
- }
3188
- },
3189
- // --- Execution ---
3190
- {
3191
- name: "want",
3192
- description: d("want"),
3193
- params: {
3194
- id: { type: "string", required: true, description: "Goal id (used for focus/reference)" },
3195
- goal: {
3196
- type: "gherkin",
3197
- required: true,
3198
- description: "Gherkin Feature source describing the goal"
3199
- }
3200
- }
3201
- },
3202
- {
3203
- name: "plan",
3204
- description: d("plan"),
3205
- params: {
3206
- id: {
3207
- type: "string",
3208
- required: true,
3209
- description: "Plan id \u2014 keywords from the plan content joined by hyphens"
3210
- },
3211
- plan: {
3212
- type: "gherkin",
3213
- required: true,
3214
- description: "Gherkin Feature source describing the plan"
3215
- },
3216
- after: {
3217
- type: "string",
3218
- required: false,
3219
- description: "Plan id this plan follows (sequential/phase relationship)"
3220
- },
3221
- fallback: {
3222
- type: "string",
3223
- required: false,
3224
- description: "Plan id this plan is a backup for (alternative/strategy relationship)"
3225
- }
3226
- }
3227
- },
3228
- {
3229
- name: "todo",
3230
- description: d("todo"),
3231
- params: {
3232
- id: { type: "string", required: true, description: "Task id (used for finish/reference)" },
3233
- task: {
3234
- type: "gherkin",
3235
- required: true,
3236
- description: "Gherkin Feature source describing the task"
3237
- }
3238
- }
3239
- },
3240
- {
3241
- name: "finish",
3242
- description: d("finish"),
3243
- params: {
3244
- id: { type: "string", required: true, description: "Task id to finish" },
3245
- encounter: {
3246
- type: "gherkin",
3247
- required: false,
3248
- description: "Optional Gherkin Feature describing what happened"
3249
- }
3250
- }
3251
- },
3252
- {
3253
- name: "complete",
3254
- description: d("complete"),
3255
- params: {
3256
- id: {
3257
- type: "string",
3258
- required: false,
3259
- description: "Plan id to complete (defaults to focused plan)"
3260
- },
3261
- encounter: {
3262
- type: "gherkin",
3263
- required: false,
3264
- description: "Optional Gherkin Feature describing what happened"
3265
- }
3266
- }
3267
- },
3268
- {
3269
- name: "abandon",
3270
- description: d("abandon"),
3271
- params: {
3272
- id: {
3273
- type: "string",
3274
- required: false,
3275
- description: "Plan id to abandon (defaults to focused plan)"
3276
- },
3277
- encounter: {
3278
- type: "gherkin",
3279
- required: false,
3280
- description: "Optional Gherkin Feature describing what happened"
3281
- }
3282
- }
3283
- },
3284
- // --- Cognition ---
3285
- {
3286
- name: "reflect",
3287
- description: d("reflect"),
3288
- params: {
3289
- ids: {
3290
- type: "string[]",
3291
- required: true,
3292
- description: "Encounter ids to reflect on (selective consumption)"
3293
- },
3294
- id: {
3295
- type: "string",
3296
- required: true,
3297
- description: "Experience id \u2014 keywords from the experience content joined by hyphens"
3298
- },
3299
- experience: {
3300
- type: "gherkin",
3301
- required: false,
3302
- description: "Gherkin Feature source for the experience"
3303
- }
3304
- }
3305
- },
3306
- {
3307
- name: "realize",
3308
- description: d("realize"),
3309
- params: {
3310
- ids: {
3311
- type: "string[]",
3312
- required: true,
3313
- description: "Experience ids to distill into a principle"
3314
- },
3315
- id: {
3316
- type: "string",
3317
- required: true,
3318
- description: "Principle id \u2014 keywords from the principle content joined by hyphens"
3319
- },
3320
- principle: {
3321
- type: "gherkin",
3322
- required: false,
3323
- description: "Gherkin Feature source for the principle"
3324
- }
3325
- }
3326
- },
3327
- {
3328
- name: "master",
3329
- description: d("master"),
3330
- params: {
3331
- ids: {
3332
- type: "string[]",
3333
- required: false,
3334
- description: "Experience ids to distill into a procedure"
3335
- },
3336
- id: {
3337
- type: "string",
3338
- required: true,
3339
- description: "Procedure id \u2014 keywords from the procedure content joined by hyphens"
3340
- },
3341
- procedure: {
3342
- type: "gherkin",
3343
- required: true,
3344
- description: "Gherkin Feature source for the procedure"
3345
- }
3346
- }
3347
- },
3348
- // --- Knowledge ---
3349
- {
3350
- name: "forget",
3351
- description: d("forget"),
3352
- params: {
3353
- id: {
3354
- type: "string",
3355
- required: true,
3356
- description: "Id of the node to remove (principle, procedure, experience, encounter, etc.)"
3357
- }
3358
- }
3359
- },
3360
- // --- Direct ---
3361
- {
3362
- name: "direct",
3363
- description: d("direct"),
3364
- params: {
3365
- command: {
3366
- type: "string",
3367
- required: true,
3368
- description: "namespace.method for RoleX commands (e.g. society.born, org.hire)"
3369
- },
3370
- args: {
3371
- type: "record",
3372
- required: false,
3373
- description: "Named arguments object for the command. Pass all parameters as key-value pairs in this object (e.g. id, content, org, individual). Must be a JSON object, not a string."
3374
- }
3375
- }
3376
- }
3377
- ];
3378
- var protocol = { tools, instructions: worldInstructions };
3379
-
3380
- // src/builder.ts
3381
- function createBuilder(config) {
3382
- let initPromise = null;
3383
- function ensureInit() {
3384
- if (!initPromise) {
3385
- initPromise = (async () => {
3386
- const service = await RoleXService.create(
3387
- config.platform,
3388
- config.renderer,
3389
- config.prototypes
3390
- );
3391
- const handler = new RpcHandler({
3392
- commands: service.commandMap,
3393
- methods: {
3394
- "role.activate": async (params) => {
3395
- return service.activate(params.individual);
3396
- },
3397
- inspect: async (params) => {
3398
- return service.inspect(params.id, {
3399
- raw: params.raw
3400
- });
3401
- },
3402
- survey: async (params) => {
3403
- return service.survey(params.type, {
3404
- raw: params.raw
3405
- });
3406
- }
3407
- }
3408
- });
3409
- return { handler, service };
3410
- })();
3411
- }
3412
- return initPromise;
3413
- }
3414
- const call = async (method, params) => {
3415
- const { handler } = await ensureInit();
3416
- const response = await handler.handle({
3417
- jsonrpc: "2.0",
3418
- method,
3419
- params,
3420
- id: null
3421
- });
3422
- if (response.error) {
3423
- throw new Error(response.error.message);
3424
- }
3425
- return response.result;
3426
- };
3427
- const _society = createSocietyNamespace(call);
3428
- const _individual = createIndividualNamespace(call);
3429
- const _org = createOrgNamespace(call);
3430
- const _position = createPositionNamespace(call);
3431
- const _project = createProjectNamespace(call);
3432
- const _product = createProductNamespace(call);
3433
- const _issue = createIssueNamespace(call);
3434
- return {
3435
- get society() {
3436
- return _society;
3437
- },
3438
- get individual() {
3439
- return _individual;
3440
- },
3441
- get org() {
3442
- return _org;
3443
- },
3444
- get position() {
3445
- return _position;
3446
- },
3447
- get project() {
3448
- return _project;
3449
- },
3450
- get product() {
3451
- return _product;
3452
- },
3453
- get issue() {
3454
- return _issue;
3455
- },
3456
- async inspect({ id, raw }) {
3457
- return call("inspect", { id, raw });
3458
- },
3459
- async survey(params) {
3460
- return call("survey", params);
3461
- },
3462
- protocol,
3463
- async rpc(request) {
3464
- const { handler } = await ensureInit();
3465
- return handler.handle(request);
3466
- },
3467
- async _internal() {
3468
- const { service } = await ensureInit();
3469
- return { service };
3470
- }
3471
- };
3472
- }
3473
-
3474
- // src/renderer.ts
3475
- var RendererRouter = class {
3476
- renderers = /* @__PURE__ */ new Map();
3477
- /** Register a renderer for a command namespace. */
3478
- register(namespace, renderer) {
3479
- this.renderers.set(namespace, renderer);
3480
- return this;
3481
- }
3482
- /** Route a command to the appropriate renderer. */
3483
- render(command, result) {
3484
- const dot = command.indexOf(".");
3485
- const namespace = dot >= 0 ? command.slice(0, dot) : command;
3486
- const renderer = this.renderers.get(namespace);
3487
- if (renderer) return renderer.render(command, result);
3488
- return defaultRender(command, result);
3489
- }
3490
- };
3491
- function defaultRender(_command, result) {
3492
- return JSON.stringify(result, null, 2);
3493
- }
3494
214
  export {
3495
- RendererRouter,
3496
- Role,
3497
- RoleXService,
3498
- RpcHandler,
3499
215
  abandon,
3500
216
  abolish,
3501
217
  activate,
3502
- applyPrototype,
3503
218
  appoint,
3504
219
  archive,
3505
220
  background,
3506
221
  born,
3507
- channel,
3508
- channelProduct,
3509
222
  charge,
3510
223
  charter,
3511
224
  charterOrg,
3512
- comment,
3513
225
  complete,
3514
- create6 as create,
3515
- createBuilder,
3516
- createCommands,
226
+ create5 as create,
3517
227
  createRuntime,
3518
228
  deliverProject,
3519
229
  deliverable,
3520
- deprecate,
3521
230
  die,
3522
- directives,
3523
231
  dismiss,
3524
- disownProduct,
3525
232
  dissolve,
3526
233
  duty,
3527
234
  encounter,
3528
235
  enroll,
3529
236
  establish,
3530
237
  experience,
3531
- findInState2 as findInState,
3532
238
  finish,
3533
239
  fire,
3534
240
  found,
@@ -3536,16 +242,13 @@ export {
3536
242
  hire,
3537
243
  identity,
3538
244
  individual,
3539
- instructions,
3540
- issue,
3541
245
  launch,
3542
- link4 as link,
246
+ link3 as link,
3543
247
  master,
3544
248
  milestone,
3545
249
  milestoneProject,
3546
250
  mindset,
3547
251
  organization,
3548
- ownProduct,
3549
252
  past,
3550
253
  plan,
3551
254
  planGoal,
@@ -3553,17 +256,11 @@ export {
3553
256
  principle,
3554
257
  procedure,
3555
258
  process7 as process,
3556
- processes,
3557
- produceProject,
3558
- product,
3559
259
  project,
3560
- protocol,
3561
260
  realize,
3562
261
  reflect,
3563
262
  rehire,
3564
263
  relation2 as relation,
3565
- release,
3566
- releaseProduct,
3567
264
  remove,
3568
265
  removeParticipant,
3569
266
  requirement,
@@ -3571,20 +268,14 @@ export {
3571
268
  scope,
3572
269
  scopeProject,
3573
270
  society,
3574
- spec,
3575
- specProduct,
3576
- strategy,
3577
- strategyProduct,
3578
- structure3 as structure,
271
+ structure2 as structure,
3579
272
  task,
3580
- toArgs,
3581
273
  todo,
3582
274
  tone,
3583
275
  transform4 as transform,
3584
- unlink4 as unlink,
276
+ unlink3 as unlink,
3585
277
  want,
3586
278
  wiki,
3587
- wikiProject,
3588
- world
279
+ wikiProject
3589
280
  };
3590
281
  //# sourceMappingURL=index.js.map