rolexjs 1.3.1-dev-20260304123741 → 2.0.0-dev-20260305000914

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -267,7 +267,7 @@ declare class Rolex {
267
267
  private issuex?;
268
268
  private repo;
269
269
  private readonly initializer?;
270
- private readonly bootstrap;
270
+ private readonly prototypes;
271
271
  private society;
272
272
  private past;
273
273
  private constructor();
@@ -275,7 +275,7 @@ declare class Rolex {
275
275
  static create(platform: Platform): Promise<Rolex>;
276
276
  /** Async initialization — called by Rolex.create(). */
277
277
  private init;
278
- /** Genesis — create the world on first run. Settles built-in prototypes. */
278
+ /** Genesis — create the world on first run. Applies built-in prototypes. */
279
279
  genesis(): Promise<void>;
280
280
  /**
281
281
  * Activate a role — returns a stateful Role handle.
package/dist/index.js CHANGED
@@ -807,7 +807,7 @@ var Role = class {
807
807
 
808
808
  // src/rolex.ts
809
809
  import * as C from "@rolexjs/core";
810
- import { createOps, directives as directives2, toArgs } from "@rolexjs/prototype";
810
+ import { applyPrototype, createOps, directives as directives2, toArgs } from "@rolexjs/prototype";
811
811
  import { createIssueX } from "issuexjs";
812
812
  import { createResourceX, setProvider } from "resourcexjs";
813
813
  var Rolex = class _Rolex {
@@ -817,14 +817,14 @@ var Rolex = class _Rolex {
817
817
  issuex;
818
818
  repo;
819
819
  initializer;
820
- bootstrap;
820
+ prototypes;
821
821
  society;
822
822
  past;
823
823
  constructor(platform) {
824
824
  this.repo = platform.repository;
825
825
  this.rt = this.repo.runtime;
826
826
  this.initializer = platform.initializer;
827
- this.bootstrap = platform.bootstrap ?? [];
827
+ this.prototypes = platform.prototypes ?? [];
828
828
  if (platform.resourcexProvider) {
829
829
  setProvider(platform.resourcexProvider);
830
830
  this.resourcex = createResourceX(
@@ -864,11 +864,11 @@ var Rolex = class _Rolex {
864
864
  direct: (locator, args) => this.direct(locator, args)
865
865
  });
866
866
  }
867
- /** Genesis — create the world on first run. Settles built-in prototypes. */
867
+ /** Genesis — create the world on first run. Applies built-in prototypes. */
868
868
  async genesis() {
869
869
  await this.initializer?.bootstrap();
870
- for (const source of this.bootstrap) {
871
- await this.direct("!prototype.settle", { source });
870
+ for (const proto of this.prototypes) {
871
+ await applyPrototype(proto, this.repo.prototype, (op, args) => this.direct(op, args));
872
872
  }
873
873
  }
874
874
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/context.ts","../src/feature.ts","../src/find.ts","../src/issue-render.ts","../src/render.ts","../src/project-render.ts","../src/role.ts","../src/rolex.ts"],"sourcesContent":["/**\n * rolexjs — RoleX API + Render layer.\n *\n * Usage:\n * import { Rolex, Role, describe, hint } from \"rolexjs\";\n *\n * const rolex = await createRoleX(platform);\n * await rolex.genesis();\n * const role = await rolex.activate(\"sean\");\n * await role.want(\"Feature: Ship v1\", \"ship-v1\");\n */\n\n// Re-export core (structures + processes)\nexport * from \"@rolexjs/core\";\n// Context\nexport { RoleContext } from \"./context.js\";\n// Feature (Gherkin type + parse/serialize)\nexport type { DataTableRow, Feature, Scenario, Step } from \"./feature.js\";\nexport { parse, serialize } from \"./feature.js\";\n// Find\nexport { findInState } from \"./find.js\";\n// Issue Render\nexport type { IssueAction, LabelResolver } from \"./issue-render.js\";\nexport {\n renderComment,\n renderCommentList,\n renderIssue,\n renderIssueList,\n renderIssueResult,\n} from \"./issue-render.js\";\n// Project Render\nexport type { ProjectAction } from \"./project-render.js\";\nexport { renderProject, renderProjectResult } from \"./project-render.js\";\nexport type { RenderOptions, RenderStateOptions } from \"./render.js\";\n// Render\nexport { describe, detail, directive, hint, render, renderState, world } from \"./render.js\";\n// Role\nexport { Role } from \"./role.js\";\n// API\nexport type { CensusEntry } from \"./rolex.js\";\nexport { createRoleX, Rolex } from \"./rolex.js\";\n","/**\n * RoleContext — stateful session context for role operations.\n *\n * Tracks execution state from the individual's perspective:\n * - roleId (who I am)\n * - focusedGoalId / focusedPlanId (what I'm working on)\n * - encounter / experience id sets (what I have for cognition)\n *\n * Created by activate, updated by subsequent role operations.\n * Consumers (MCP, CLI) hold a reference and pass it through.\n */\nimport type { State } from \"@rolexjs/system\";\n\nexport class RoleContext {\n roleId: string;\n focusedGoalId: string | null = null;\n focusedPlanId: string | null = null;\n\n readonly encounterIds = new Set<string>();\n readonly experienceIds = new Set<string>();\n\n constructor(roleId: string) {\n this.roleId = roleId;\n }\n\n // ================================================================\n // Requirements — throw if missing\n // ================================================================\n\n requireGoalId(): string {\n if (!this.focusedGoalId) throw new Error(\"No focused goal. Call want first.\");\n return this.focusedGoalId;\n }\n\n requirePlanId(): string {\n if (!this.focusedPlanId) throw new Error(\"No focused plan. Call plan first.\");\n return this.focusedPlanId;\n }\n\n // ================================================================\n // Cognition registries\n // ================================================================\n\n addEncounter(id: string) {\n this.encounterIds.add(id);\n }\n\n requireEncounterIds(ids: string[]) {\n for (const id of ids) {\n if (!this.encounterIds.has(id)) throw new Error(`Encounter not found: \"${id}\"`);\n }\n }\n\n consumeEncounters(ids: string[]) {\n for (const id of ids) {\n this.encounterIds.delete(id);\n }\n }\n\n addExperience(id: string) {\n this.experienceIds.add(id);\n }\n\n requireExperienceIds(ids: string[]) {\n for (const id of ids) {\n if (!this.experienceIds.has(id)) throw new Error(`Experience not found: \"${id}\"`);\n }\n }\n\n consumeExperiences(ids: string[]) {\n for (const id of ids) {\n this.experienceIds.delete(id);\n }\n }\n\n // ================================================================\n // Rehydration — rebuild from activation state\n // ================================================================\n\n /** Walk the state tree and populate registries. */\n rehydrate(state: State) {\n this.walk(state);\n }\n\n private walk(node: State) {\n if (node.id) {\n switch (node.name) {\n case \"goal\":\n if (!this.focusedGoalId) this.focusedGoalId = node.id;\n break;\n case \"encounter\":\n this.encounterIds.add(node.id);\n break;\n case \"experience\":\n this.experienceIds.add(node.id);\n break;\n }\n }\n for (const child of (node as State & { children?: readonly State[] }).children ?? []) {\n this.walk(child);\n }\n }\n\n // ================================================================\n // Cognitive hints — state-aware AI self-direction cues\n // ================================================================\n\n /** First-person, state-aware hint for the AI after an operation. */\n cognitiveHint(process: string): string | null {\n switch (process) {\n case \"activate\":\n if (!this.focusedGoalId)\n return \"I have no goal yet. I should call `want` to declare one, or `focus` to review existing goals.\";\n return \"I have an active goal. I should call `focus` to review progress, or `want` to declare a new goal.\";\n\n case \"focus\":\n if (!this.focusedPlanId)\n return \"I have a goal but no focused plan. I should call `plan` to create or focus on one.\";\n return \"I have a plan. I should call `todo` to create tasks, or continue working.\";\n\n case \"want\":\n return \"Goal declared. I should call `plan` to design how to achieve it.\";\n\n case \"plan\":\n return \"Plan created. I should call `todo` to create concrete tasks.\";\n\n case \"todo\":\n return \"Task created. I can add more with `todo`, or start working and call `finish` when done.\";\n\n case \"finish\": {\n const encCount = this.encounterIds.size;\n if (encCount > 0 && !this.focusedGoalId)\n return `Task finished. No more goals — I have ${encCount} encounter(s) to choose from for \\`reflect\\`, or \\`want\\` a new goal.`;\n return \"Task finished. I should continue with remaining tasks, or call `complete` when the plan is done.\";\n }\n\n case \"complete\":\n case \"abandon\": {\n const encCount = this.encounterIds.size;\n const goalNote = this.focusedGoalId\n ? ` I should check if goal \"${this.focusedGoalId}\" needs a new \\`plan\\`, or \\`forget\\` it if the direction is fulfilled.`\n : \"\";\n if (encCount > 0)\n return `Plan closed.${goalNote} I have ${encCount} encounter(s) to choose from for \\`reflect\\`, or I can continue with other plans.`;\n return `Plan closed.${goalNote} I can create a new \\`plan\\`, or \\`focus\\` on another goal.`;\n }\n\n case \"reflect\": {\n const expCount = this.experienceIds.size;\n if (expCount > 0)\n return `Experience gained. I can \\`realize\\` principles or \\`master\\` procedures — ${expCount} experience(s) available.`;\n return \"Experience gained. I can `realize` a principle, `master` a procedure, or continue working.\";\n }\n\n case \"realize\":\n return \"Principle added. I should continue working.\";\n\n case \"master\":\n return \"Procedure added. I should continue working.\";\n\n default:\n return null;\n }\n }\n}\n","/**\n * Feature — the information format for the RoleX concept world.\n *\n * Every node's information is a Gherkin Feature.\n * This is our own type — decoupled from @cucumber/messages.\n */\n\nexport interface Feature {\n readonly name: string;\n readonly description?: string;\n readonly tags?: readonly string[];\n readonly scenarios: readonly Scenario[];\n}\n\nexport interface Scenario {\n readonly name: string;\n readonly description?: string;\n readonly tags?: readonly string[];\n readonly steps: readonly Step[];\n}\n\nexport interface Step {\n readonly keyword: string;\n readonly text: string;\n readonly dataTable?: readonly DataTableRow[];\n}\n\nexport interface DataTableRow {\n readonly cells: readonly string[];\n}\n\n// ================================================================\n// Parse + Serialize\n// ================================================================\n\nimport { parse as parseGherkin } from \"@rolexjs/parser\";\n\n/** Parse a Gherkin source string into a Feature. */\nexport function parse(source: string): Feature {\n const doc = parseGherkin(source);\n const f = doc.feature;\n if (!f) throw new Error(\"No Feature found in source\");\n\n return {\n name: f.name,\n ...(f.description?.trim() ? { description: f.description.trim() } : {}),\n ...(f.tags?.length ? { tags: f.tags.map((t) => t.name) } : {}),\n scenarios: (f.children ?? [])\n .filter((c) => c.scenario)\n .map((c) => {\n const s = c.scenario!;\n return {\n name: s.name,\n ...(s.description?.trim() ? { description: s.description.trim() } : {}),\n ...(s.tags?.length ? { tags: s.tags.map((t) => t.name) } : {}),\n steps: (s.steps ?? []).map((st) => ({\n keyword: st.keyword,\n text: st.text,\n ...(st.dataTable\n ? {\n dataTable: st.dataTable.rows.map((r) => ({\n cells: r.cells.map((c) => c.value),\n })),\n }\n : {}),\n })),\n };\n }),\n };\n}\n\n/** Serialize a Feature back to Gherkin source string. */\nexport function serialize(feature: Feature): string {\n const lines: string[] = [];\n\n if (feature.tags?.length) {\n lines.push(feature.tags.join(\" \"));\n }\n lines.push(`Feature: ${feature.name}`);\n if (feature.description) {\n for (const line of feature.description.split(\"\\n\")) {\n lines.push(` ${line}`);\n }\n }\n\n for (const scenario of feature.scenarios) {\n lines.push(\"\");\n if (scenario.tags?.length) {\n lines.push(` ${scenario.tags.join(\" \")}`);\n }\n lines.push(` Scenario: ${scenario.name}`);\n if (scenario.description) {\n for (const line of scenario.description.split(\"\\n\")) {\n lines.push(` ${line}`);\n }\n }\n for (const step of scenario.steps) {\n lines.push(` ${step.keyword}${step.text}`);\n if (step.dataTable) {\n for (const row of step.dataTable) {\n lines.push(` | ${row.cells.join(\" | \")} |`);\n }\n }\n }\n }\n\n return `${lines.join(\"\\n\")}\\n`;\n}\n","/**\n * Find — unified node lookup with priority-based disambiguation.\n *\n * When multiple nodes share the same id (allowed after relaxing\n * global uniqueness), prefer \"addressable\" nodes over internal metadata.\n *\n * Priority (lower = preferred):\n * 0: individual, organization, position — top-level entities\n * 1: goal — execution roots\n * 2: plan, task — execution nodes\n * 3: procedure, principle — individual knowledge\n * 4: encounter, experience — cognition artifacts\n * 5: identity, charter — structural definitions\n * 6: duty, requirement, background, etc. — internal metadata\n */\nimport type { State, Structure } from \"@rolexjs/system\";\n\nconst PRIORITY: Record<string, number> = {\n individual: 0,\n organization: 0,\n position: 0,\n goal: 1,\n plan: 2,\n task: 2,\n procedure: 3,\n principle: 3,\n encounter: 4,\n experience: 4,\n identity: 5,\n charter: 5,\n duty: 6,\n requirement: 6,\n background: 6,\n tone: 6,\n mindset: 6,\n};\n\nfunction priorityOf(name: string): number {\n return PRIORITY[name] ?? 7;\n}\n\nfunction matches(node: State, target: string): boolean {\n if (node.id?.toLowerCase() === target) return true;\n if (node.alias) {\n for (const a of node.alias) {\n if (a.toLowerCase() === target) return true;\n }\n }\n return false;\n}\n\n/**\n * Find a node by id or alias in a state tree.\n *\n * When multiple nodes match, returns the one with the highest priority\n * (top-level entities > execution nodes > knowledge > metadata).\n */\nexport function findInState(state: State, target: string): Structure | null {\n const lowered = target.toLowerCase();\n let best: Structure | null = null;\n let bestPriority = Infinity;\n\n function walk(node: State): void {\n if (matches(node, lowered)) {\n const p = priorityOf(node.name);\n if (p < bestPriority) {\n best = node;\n bestPriority = p;\n if (p === 0) return; // Can't do better\n }\n }\n for (const child of node.children ?? []) {\n walk(child);\n if (bestPriority === 0) return; // Early exit\n }\n }\n\n walk(state);\n return best;\n}\n","/**\n * Issue Render — format IssueX data as readable text.\n *\n * Lightweight rendering for issue operations.\n * Unlike the core render layer (which projects State trees),\n * this module formats flat IssueX objects into human-readable strings.\n */\nimport type { Comment, Issue } from \"issuexjs\";\n\n// ================================================================\n// Types\n// ================================================================\n\nexport type IssueAction =\n | \"publish\"\n | \"get\"\n | \"list\"\n | \"close\"\n | \"reopen\"\n | \"update\"\n | \"assign\"\n | \"comment\"\n | \"comments\"\n | \"label\"\n | \"unlabel\";\n\nexport type LabelResolver = (ids: string[]) => Promise<string[]>;\n\n// ================================================================\n// Single Issue\n// ================================================================\n\nexport function renderIssue(issue: Issue, labelNames?: string[]): string {\n const lines: string[] = [];\n\n lines.push(`#${issue.number} ${issue.title} [${issue.status}]`);\n\n const meta: string[] = [`Author: ${issue.author}`];\n if (issue.assignee) meta.push(`Assignee: ${issue.assignee}`);\n if (labelNames && labelNames.length > 0) {\n meta.push(`Labels: ${labelNames.join(\", \")}`);\n }\n lines.push(meta.join(\" | \"));\n\n if (issue.body) {\n lines.push(\"───\");\n lines.push(issue.body);\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Issue List\n// ================================================================\n\nexport function renderIssueList(issues: Issue[]): string {\n if (issues.length === 0) return \"No issues found.\";\n\n const lines: string[] = [];\n for (const issue of issues) {\n const assignee = issue.assignee ? ` → ${issue.assignee}` : \"\";\n lines.push(`#${issue.number} [${issue.status}] ${issue.title} (${issue.author}${assignee})`);\n }\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Comments\n// ================================================================\n\nexport function renderComment(comment: Comment): string {\n const time = formatTime(comment.createdAt);\n return `${comment.author} (${time}):\\n${comment.body}`;\n}\n\nexport function renderCommentList(comments: Comment[]): string {\n if (comments.length === 0) return \"No comments.\";\n return comments.map(renderComment).join(\"\\n───\\n\");\n}\n\n// ================================================================\n// Status line\n// ================================================================\n\nconst statusTemplates: Record<string, (issue: Issue) => string> = {\n publish: (i) => `Issue #${i.number} created.`,\n close: (i) => `Issue #${i.number} closed.`,\n reopen: (i) => `Issue #${i.number} reopened.`,\n update: (i) => `Issue #${i.number} updated.`,\n assign: (i) => `Issue #${i.number} assigned to ${i.assignee ?? \"nobody\"}.`,\n comment: (i) => `Comment added to #${i.number}.`,\n label: (i) => `Label added to #${i.number}.`,\n unlabel: (i) => `Label removed from #${i.number}.`,\n};\n\n// ================================================================\n// Compose — the main entry point for Role.use()\n// ================================================================\n\n/**\n * Render an issue operation result as readable text.\n * Dispatches to the right renderer based on action.\n */\nexport async function renderIssueResult(\n action: IssueAction,\n result: unknown,\n resolveLabels?: LabelResolver\n): Promise<string> {\n switch (action) {\n case \"list\":\n return renderIssueList(result as Issue[]);\n\n case \"comments\":\n return renderCommentList(result as Comment[]);\n\n case \"comment\": {\n const comment = result as Comment;\n return `Comment added to issue.\\n\\n${renderComment(comment)}`;\n }\n\n case \"get\": {\n if (!result) return \"Issue not found.\";\n const issue = result as Issue;\n const labelNames = await resolveLabelNames(issue, resolveLabels);\n return renderIssue(issue, labelNames);\n }\n\n default: {\n // All other actions return an Issue with a status line\n const issue = result as Issue;\n const labelNames = await resolveLabelNames(issue, resolveLabels);\n const status = statusTemplates[action]?.(issue) ?? `Issue #${issue.number} ${action}.`;\n return `${status}\\n\\n${renderIssue(issue, labelNames)}`;\n }\n }\n}\n\n// ================================================================\n// Helpers\n// ================================================================\n\nfunction formatTime(iso: string): string {\n return iso.replace(\"T\", \" \").replace(/\\.\\d+Z$/, \"\");\n}\n\nasync function resolveLabelNames(\n issue: Issue,\n resolveLabels?: LabelResolver\n): Promise<string[] | undefined> {\n if (!issue.labels || issue.labels.length === 0) return undefined;\n if (!resolveLabels) return undefined;\n return resolveLabels(issue.labels);\n}\n","/**\n * Render — 3-layer output for all Rolex operations.\n *\n * Layer 1: Status — what just happened (describe)\n * Layer 2: Hint — what to do next (hint + cognitive hint)\n * Layer 3: Projection — full state tree as markdown (renderState)\n *\n * render() composes the 3 layers. MCP and CLI are pure pass-through.\n */\nimport type { State } from \"@rolexjs/system\";\n\n// ================================================================\n// Description — what happened\n// ================================================================\n\nconst descriptions: Record<string, (name: string, state: State) => string> = {\n // Lifecycle\n born: (n) => `Individual \"${n}\" is born.`,\n found: (n) => `Organization \"${n}\" is founded.`,\n establish: (n) => `Position \"${n}\" is established.`,\n charter: (n) => `Charter defined for \"${n}\".`,\n charge: (n) => `Duty \"${n}\" assigned.`,\n retire: (n) => `\"${n}\" retired.`,\n die: (n) => `\"${n}\" is gone.`,\n dissolve: (n) => `Organization \"${n}\" dissolved.`,\n abolish: (n) => `Position \"${n}\" abolished.`,\n rehire: (n) => `\"${n}\" is back.`,\n\n // Organization\n hire: (n) => `\"${n}\" hired.`,\n fire: (n) => `\"${n}\" fired.`,\n appoint: (n) => `\"${n}\" appointed.`,\n dismiss: (n) => `\"${n}\" dismissed.`,\n\n // Project\n launch: (n) => `Project \"${n}\" launched.`,\n scope: (n) => `Scope defined for \"${n}\".`,\n milestone: (n) => `Milestone \"${n}\" added.`,\n achieve: (n) => `Milestone \"${n}\" achieved.`,\n enroll: (n) => `\"${n}\" enrolled.`,\n remove: (n) => `\"${n}\" removed.`,\n deliver: (n) => `Deliverable \"${n}\" added.`,\n wiki: (n) => `Wiki entry \"${n}\" added.`,\n archive: (n) => `Project \"${n}\" archived.`,\n\n // Role\n activate: (n) => `Role \"${n}\" activated.`,\n focus: (n) => `Focused on goal \"${n}\".`,\n\n // Execution\n want: (n) => `Goal \"${n}\" declared.`,\n plan: (n) => `Plan created for \"${n}\".`,\n todo: (n) => `Task \"${n}\" added.`,\n finish: (n) => `Task \"${n}\" finished → encounter recorded.`,\n complete: (n) => `Plan \"${n}\" completed → encounter recorded.`,\n abandon: (n) => `Plan \"${n}\" abandoned → encounter recorded.`,\n\n // Cognition\n reflect: (n) => `Reflected on \"${n}\" → experience gained.`,\n realize: (n) => `Realized principle from \"${n}\".`,\n master: (n) => `Mastered procedure from \"${n}\".`,\n\n // Knowledge management\n forget: (n) => `\"${n}\" forgotten.`,\n};\n\nexport function describe(process: string, name: string, state: State): string {\n const fn = descriptions[process];\n return fn ? fn(name, state) : `${process} completed.`;\n}\n\n// ================================================================\n// Hint — what to do next\n// ================================================================\n\nconst hints: Record<string, string> = {\n // Lifecycle\n born: \"hire into an organization, or activate to start working.\",\n found: \"define a charter for the organization.\",\n establish: \"charge with duties, then appoint members.\",\n charter: \"establish positions for the organization.\",\n charge: \"appoint someone to this position.\",\n retire: \"rehire if needed later.\",\n die: \"this individual is permanently gone.\",\n dissolve: \"the organization no longer exists.\",\n abolish: \"the position no longer exists.\",\n rehire: \"activate to resume working.\",\n\n // Organization\n hire: \"appoint to a position, or activate to start working.\",\n fire: \"the individual is no longer a member.\",\n appoint: \"the individual now holds this position.\",\n dismiss: \"the position is now vacant.\",\n\n // Project\n launch: \"define scope, add milestones, or enroll members.\",\n scope: \"add milestones to break down the project.\",\n milestone: \"enroll members and start working.\",\n achieve: \"continue with remaining milestones, or archive the project.\",\n enroll: \"assign milestones and start working.\",\n remove: \"the individual is no longer a participant.\",\n deliver: \"deliverable recorded.\",\n wiki: \"knowledge entry recorded.\",\n archive: \"the project is archived.\",\n\n // Role\n activate: \"want a goal, or check the current state.\",\n focus: \"plan how to work toward it, or add tasks.\",\n\n // Execution\n want: \"plan how to work toward it.\",\n plan: \"add tasks with todo.\",\n todo: \"start working, finish when done.\",\n finish: \"continue with remaining tasks, or complete the plan.\",\n complete: \"reflect on encounters to gain experience.\",\n abandon: \"reflect on encounters to learn from the experience.\",\n\n // Cognition\n reflect: \"realize principles or master procedures from experience.\",\n realize: \"principle added.\",\n master: \"procedure added.\",\n\n // Knowledge management\n forget: \"the node has been removed.\",\n};\n\nexport function hint(process: string): string {\n const h = hints[process];\n return h ? `Next: ${h}` : \"What would you like to do next?\";\n}\n\n// ================================================================\n// Detail — longer process descriptions (from .feature files)\n// ================================================================\n\nimport { directives, processes, world } from \"@rolexjs/prototype\";\n\n/** Full Gherkin feature content for a process — sourced from .feature files. */\nexport function detail(process: string): string {\n return processes[process] ?? \"\";\n}\n\n/** World feature descriptions — framework-level instructions. */\nexport { world };\n\n// ================================================================\n// Directive — system-level commands at decision points\n// ================================================================\n\n/** Get a directive by topic and scenario. Returns empty string if not found. */\nexport function directive(topic: string, scenario: string): string {\n return directives[topic]?.[scenario] ?? \"\";\n}\n\n// ================================================================\n// Generic State renderer — renders any State tree as markdown\n// ================================================================\n\n/**\n * renderState — markdown renderer for State trees.\n *\n * Rules:\n * - Heading: \"#\" repeated to depth + \" [name]\"\n * - Body: raw information field as-is (full Gherkin preserved)\n * - Links: \"> → relation [target.name]\" with target feature name\n * - Children: sorted by concept hierarchy, then rendered at depth+1\n * - Fold: when fold(node) returns true, render heading only (no body/links/children)\n *\n * Markdown heading depth caps at 6 (######).\n */\nexport interface RenderStateOptions {\n /** When returns true, render only the heading — skip body, links, and children. */\n fold?: (node: State) => boolean;\n}\n\nexport function renderState(state: State, depth = 1, options?: RenderStateOptions): string {\n const lines: string[] = [];\n const level = Math.min(depth, 6);\n const heading = \"#\".repeat(level);\n\n // Heading: [name] (id) {origin} #tag [progress]\n const idPart = state.id ? ` (${state.id})` : \"\";\n const originPart = state.origin ? ` {${state.origin}}` : \"\";\n const tagPart = state.tag ? ` #${state.tag}` : \"\";\n const progressPart = state.name === \"goal\" ? goalProgress(state) : \"\";\n lines.push(`${heading} [${state.name}]${idPart}${originPart}${tagPart}${progressPart}`);\n\n // Folded: heading only\n if (options?.fold?.(state)) {\n return lines.join(\"\\n\");\n }\n\n // Body: full information as-is\n if (state.information) {\n lines.push(\"\");\n lines.push(state.information);\n }\n\n // Links — plan references are compact, organizational links are expanded\n if (state.links && state.links.length > 0) {\n const compactRelations = new Set([\"after\", \"before\", \"fallback\", \"fallback-for\"]);\n const compact = state.links.filter((l) => compactRelations.has(l.relation));\n const expanded = state.links.filter((l) => !compactRelations.has(l.relation));\n for (const link of compact) {\n const targetId = link.target.id ? ` (${link.target.id})` : \"\";\n const targetTag = link.target.tag ? ` #${link.target.tag}` : \"\";\n lines.push(`> ${link.relation}: [${link.target.name}]${targetId}${targetTag}`);\n }\n if (expanded.length > 0) {\n const targets = sortByConceptOrder(expanded.map((l) => l.target));\n for (const target of targets) {\n lines.push(\"\");\n lines.push(renderState(target, depth + 1, options));\n }\n }\n }\n\n // Children — sorted by concept hierarchy, empty nodes filtered out\n if (state.children && state.children.length > 0) {\n const sorted = sortByConceptOrder(state.children.filter((c) => !isEmpty(c)));\n for (const child of sorted) {\n lines.push(\"\");\n lines.push(renderState(child, depth + 1, options));\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Concept ordering — children sorted by structure hierarchy\n// ================================================================\n\n/** Concept tree order: identity → cognition → knowledge → execution → organization. */\nconst CONCEPT_ORDER: readonly string[] = [\n // Individual — Identity\n \"identity\",\n \"background\",\n \"tone\",\n \"mindset\",\n // Individual — Cognition\n \"encounter\",\n \"experience\",\n // Individual — Knowledge\n \"principle\",\n \"procedure\",\n // Individual — Execution\n \"goal\",\n \"plan\",\n \"task\",\n // Organization\n \"charter\",\n // Position\n \"position\",\n \"duty\",\n // Project\n \"scope\",\n \"milestone\",\n \"deliverable\",\n \"wiki\",\n];\n\n/** Summarize plan/task completion for a goal heading. */\nfunction goalProgress(goal: State): string {\n let plans = 0;\n let plansDone = 0;\n let tasks = 0;\n let tasksDone = 0;\n\n function walk(node: State): void {\n if (node.name === \"plan\") {\n plans++;\n if (node.tag === \"done\" || node.tag === \"abandoned\") plansDone++;\n } else if (node.name === \"task\") {\n tasks++;\n if (node.tag === \"done\") tasksDone++;\n }\n for (const child of node.children ?? []) walk(child);\n }\n\n for (const child of goal.children ?? []) walk(child);\n if (plans === 0 && tasks === 0) return \"\";\n const parts: string[] = [];\n if (plans > 0) parts.push(`${plansDone}/${plans} plans`);\n if (tasks > 0) parts.push(`${tasksDone}/${tasks} tasks`);\n return ` [${parts.join(\", \")}]`;\n}\n\n/** A node is empty when it has no id, no information, and no children. */\nfunction isEmpty(node: State): boolean {\n return !node.id && !node.information && (!node.children || node.children.length === 0);\n}\n\n/** Sort children by concept hierarchy order. Unknown names go to the end, preserving relative order. */\nfunction sortByConceptOrder(children: readonly State[]): readonly State[] {\n return [...children].sort((a, b) => {\n const ai = CONCEPT_ORDER.indexOf(a.name);\n const bi = CONCEPT_ORDER.indexOf(b.name);\n const aOrder = ai >= 0 ? ai : CONCEPT_ORDER.length;\n const bOrder = bi >= 0 ? bi : CONCEPT_ORDER.length;\n return aOrder - bOrder;\n });\n}\n\n// ================================================================\n// Render — 3-layer output for tool results\n// ================================================================\n\nexport interface RenderOptions {\n /** The process that was executed. */\n process: string;\n /** Display name for the primary node. */\n name: string;\n /** State projection of the affected node. */\n state: State;\n /** AI cognitive hint — first-person, state-aware self-direction cue. */\n cognitiveHint?: string | null;\n /** Fold predicate — folded nodes render heading only. */\n fold?: RenderStateOptions[\"fold\"];\n}\n\n/** Render a full 3-layer output string. */\nexport function render(opts: RenderOptions): string {\n const { process, name, state, cognitiveHint, fold } = opts;\n const lines: string[] = [];\n\n // Layer 1: Status\n lines.push(describe(process, name, state));\n\n // Layer 2: Hint (static) + Cognitive hint (state-aware)\n lines.push(hint(process));\n if (cognitiveHint) {\n lines.push(`I → ${cognitiveHint}`);\n }\n\n // Layer 3: Projection — generic markdown rendering of the full state tree\n lines.push(\"\");\n lines.push(renderState(state, 1, fold ? { fold } : undefined));\n\n return lines.join(\"\\n\");\n}\n","/**\n * Project Render — format project state as readable text.\n *\n * Renders project operations into human-readable summaries.\n * Participation links show member names only (not full individual trees).\n * Milestones show progress status (#done or pending).\n */\nimport type { State } from \"@rolexjs/system\";\nimport { describe, hint } from \"./render.js\";\n\n// ================================================================\n// Types\n// ================================================================\n\nexport type ProjectAction =\n | \"launch\"\n | \"scope\"\n | \"milestone\"\n | \"achieve\"\n | \"enroll\"\n | \"remove\"\n | \"deliver\"\n | \"wiki\"\n | \"archive\";\n\n// ================================================================\n// Project Overview\n// ================================================================\n\nexport function renderProject(state: State): string {\n const lines: string[] = [];\n const id = state.id ?? \"(no id)\";\n const tag = state.tag ? ` #${state.tag}` : \"\";\n\n // Title\n lines.push(`# ${id}${tag}`);\n\n // Feature body\n if (state.information) {\n lines.push(\"\");\n lines.push(state.information);\n }\n\n // Members (participation links — compact)\n const members = state.links?.filter((l) => l.relation === \"participation\") ?? [];\n if (members.length > 0) {\n lines.push(\"\");\n lines.push(\"## Members\");\n for (const m of members) {\n const alias = m.target.alias?.length ? ` (${m.target.alias.join(\", \")})` : \"\";\n lines.push(`- ${m.target.id ?? \"(no id)\"}${alias}`);\n }\n }\n\n // Children by type\n const children = state.children ?? [];\n\n const scopes = children.filter((c) => c.name === \"scope\");\n const milestones = children.filter((c) => c.name === \"milestone\");\n const deliverables = children.filter((c) => c.name === \"deliverable\");\n const wikis = children.filter((c) => c.name === \"wiki\");\n\n if (scopes.length > 0) {\n lines.push(\"\");\n lines.push(\"## Scope\");\n for (const s of scopes) {\n if (s.information) lines.push(s.information);\n }\n }\n\n if (milestones.length > 0) {\n lines.push(\"\");\n lines.push(\"## Milestones\");\n for (const m of milestones) {\n const tag = m.tag ? ` #${m.tag}` : \"\";\n const marker = m.tag === \"done\" ? \"[x]\" : \"[ ]\";\n const title = extractFeatureTitle(m.information);\n lines.push(`- ${marker} ${m.id ?? title}${tag}`);\n if (m.information && m.id) {\n const desc = extractFeatureTitle(m.information);\n if (desc && desc !== m.id) lines.push(` ${desc}`);\n }\n }\n }\n\n if (deliverables.length > 0) {\n lines.push(\"\");\n lines.push(\"## Deliverables\");\n for (const d of deliverables) {\n const title = d.id ?? extractFeatureTitle(d.information);\n lines.push(`- ${title}`);\n }\n }\n\n if (wikis.length > 0) {\n lines.push(\"\");\n lines.push(\"## Wiki\");\n for (const w of wikis) {\n const title = w.id ?? extractFeatureTitle(w.information);\n lines.push(`- ${title}`);\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Compose — main entry point\n// ================================================================\n\n/**\n * Render a project operation result as readable text.\n * Returns status + hint + project overview.\n */\nexport function renderProjectResult(action: ProjectAction, state: State): string {\n const name = state.id ?? state.name;\n const lines: string[] = [];\n\n // Layer 1: Status\n lines.push(describe(action, name, state));\n\n // Layer 2: Hint\n lines.push(hint(action));\n\n // Layer 3: Project overview\n // For child operations (scope, milestone, etc.), find the project parent\n const projectState = isProjectNode(state) ? state : null;\n if (projectState) {\n lines.push(\"\");\n lines.push(renderProject(projectState));\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Helpers\n// ================================================================\n\nfunction isProjectNode(state: State): boolean {\n return state.name === \"project\";\n}\n\nfunction extractFeatureTitle(information?: string | null): string {\n if (!information) return \"(untitled)\";\n const match = information.match(/^Feature:\\s*(.+)$/m);\n return match?.[1]?.trim() ?? information.split(\"\\n\")[0].trim();\n}\n","/**\n * Role — stateful handle returned by Rolex.activate().\n *\n * Holds roleId + RoleContext internally.\n * All operations return rendered 3-layer text (status + hint + projection).\n * MCP and CLI are pure pass-through — no render logic needed.\n *\n * Usage:\n * const role = await rolex.activate(\"sean\");\n * await role.want(\"Feature: Ship v1\", \"ship-v1\"); // → rendered string\n * await role.plan(\"Feature: Phase 1\", \"phase-1\"); // → rendered string\n * await role.finish(\"write-tests\", \"Feature: Tests written\");\n */\n\nimport type { OpResult, Ops } from \"@rolexjs/prototype\";\nimport type { RoleContext } from \"./context.js\";\nimport { type IssueAction, type LabelResolver, renderIssueResult } from \"./issue-render.js\";\nimport { type ProjectAction, renderProjectResult } from \"./project-render.js\";\nimport { render } from \"./render.js\";\n\n/**\n * Internal API surface that Role delegates to.\n * Constructed by Rolex.activate() — not part of public API.\n */\nexport interface RolexInternal {\n ops: Ops;\n saveCtx(ctx: RoleContext): void | Promise<void>;\n direct<T>(locator: string, args?: Record<string, unknown>): Promise<T>;\n resolveLabels?: LabelResolver;\n}\n\nexport class Role {\n readonly roleId: string;\n readonly ctx: RoleContext;\n private api: RolexInternal;\n\n constructor(roleId: string, ctx: RoleContext, api: RolexInternal) {\n this.roleId = roleId;\n this.ctx = ctx;\n this.api = api;\n }\n\n /** Project the individual's full state tree (used after activate). */\n async project(): Promise<string> {\n const result = await this.api.ops[\"role.focus\"](this.roleId);\n const focusedGoalId = this.ctx.focusedGoalId;\n return this.fmt(\"activate\", this.roleId, result, {\n fold: (node) =>\n (node.name === \"goal\" && node.id !== focusedGoalId) || node.name === \"requirement\",\n });\n }\n\n /** Render an OpResult into a 3-layer output string. */\n private fmt(\n process: string,\n name: string,\n result: OpResult,\n extra?: { fold?: (node: import(\"@rolexjs/system\").State) => boolean }\n ): string {\n return render({\n process,\n name,\n state: result.state,\n cognitiveHint: this.ctx.cognitiveHint(process) ?? null,\n fold: extra?.fold,\n });\n }\n\n private async save(): Promise<void> {\n await this.api.saveCtx(this.ctx);\n }\n\n // ---- Execution ----\n\n /** Focus: view or switch focused goal. Only accepts goal ids. */\n async focus(goal?: string): Promise<string> {\n const goalId = goal ?? this.ctx.requireGoalId();\n const result = await this.api.ops[\"role.focus\"](goalId);\n if (result.state.name !== \"goal\") {\n throw new Error(\n `\"${goalId}\" is a ${result.state.name}, not a goal. focus only accepts goal ids.`\n );\n }\n const switched = goalId !== this.ctx.focusedGoalId;\n this.ctx.focusedGoalId = goalId;\n if (switched) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"focus\", goalId, result);\n }\n\n /** Want: declare a goal. */\n async want(goal?: string, id?: string, alias?: readonly string[]): Promise<string> {\n const result = await this.api.ops[\"role.want\"](this.roleId, goal, id, alias);\n if (id) this.ctx.focusedGoalId = id;\n this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"want\", id ?? this.roleId, result);\n }\n\n /** Plan: create a plan for the focused goal. */\n async plan(plan?: string, id?: string, after?: string, fallback?: string): Promise<string> {\n const result = await this.api.ops[\"role.plan\"](\n this.ctx.requireGoalId(),\n plan,\n id,\n after,\n fallback\n );\n if (id) this.ctx.focusedPlanId = id;\n await this.save();\n return this.fmt(\"plan\", id ?? \"plan\", result);\n }\n\n /** Todo: add a task to the focused plan. */\n async todo(task?: string, id?: string, alias?: readonly string[]): Promise<string> {\n const result = await this.api.ops[\"role.todo\"](this.ctx.requirePlanId(), task, id, alias);\n return this.fmt(\"todo\", id ?? \"task\", result);\n }\n\n /** Finish: complete a task, optionally record an encounter. */\n async finish(task: string, encounter?: string): Promise<string> {\n const result = await this.api.ops[\"role.finish\"](task, this.roleId, encounter);\n if (encounter && result.state.id) {\n this.ctx.addEncounter(result.state.id);\n }\n return this.fmt(\"finish\", task, result);\n }\n\n /** Complete: close a plan as done, record encounter. */\n async complete(plan?: string, encounter?: string): Promise<string> {\n const planId = plan ?? this.ctx.requirePlanId();\n const result = await this.api.ops[\"role.complete\"](planId, this.roleId, encounter);\n this.ctx.addEncounter(result.state.id ?? planId);\n if (this.ctx.focusedPlanId === planId) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"complete\", planId, result);\n }\n\n /** Abandon: drop a plan, record encounter. */\n async abandon(plan?: string, encounter?: string): Promise<string> {\n const planId = plan ?? this.ctx.requirePlanId();\n const result = await this.api.ops[\"role.abandon\"](planId, this.roleId, encounter);\n this.ctx.addEncounter(result.state.id ?? planId);\n if (this.ctx.focusedPlanId === planId) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"abandon\", planId, result);\n }\n\n // ---- Cognition ----\n\n /** Reflect: consume encounters → experience. Empty encounters = direct creation. */\n async reflect(encounters: string[], experience?: string, id?: string): Promise<string> {\n if (encounters.length > 0) {\n this.ctx.requireEncounterIds(encounters);\n }\n // First encounter goes through ops (creates experience + removes encounter)\n const first = encounters[0] as string | undefined;\n const result = await this.api.ops[\"role.reflect\"](first, this.roleId, experience, id);\n // Remaining encounters are consumed via forget\n for (let i = 1; i < encounters.length; i++) {\n await this.api.ops[\"role.forget\"](encounters[i]);\n }\n if (encounters.length > 0) {\n this.ctx.consumeEncounters(encounters);\n }\n if (id) this.ctx.addExperience(id);\n return this.fmt(\"reflect\", id ?? \"experience\", result);\n }\n\n /** Realize: consume experiences → principle. Empty experiences = direct creation. */\n async realize(experiences: string[], principle?: string, id?: string): Promise<string> {\n if (experiences.length > 0) {\n this.ctx.requireExperienceIds(experiences);\n }\n // First experience goes through ops (creates principle + removes experience)\n const first = experiences[0] as string | undefined;\n const result = await this.api.ops[\"role.realize\"](first, this.roleId, principle, id);\n // Remaining experiences are consumed via forget\n for (let i = 1; i < experiences.length; i++) {\n await this.api.ops[\"role.forget\"](experiences[i]);\n }\n if (experiences.length > 0) {\n this.ctx.consumeExperiences(experiences);\n }\n return this.fmt(\"realize\", id ?? \"principle\", result);\n }\n\n /** Master: create procedure, optionally consuming experiences. */\n async master(procedure: string, id?: string, experiences?: string[]): Promise<string> {\n if (experiences && experiences.length > 0) {\n this.ctx.requireExperienceIds(experiences);\n }\n // First experience goes through ops (creates procedure + removes experience)\n const first = experiences?.[0];\n const result = await this.api.ops[\"role.master\"](this.roleId, procedure, id, first);\n // Remaining experiences are consumed via forget\n if (experiences) {\n for (let i = 1; i < experiences.length; i++) {\n await this.api.ops[\"role.forget\"](experiences[i]);\n }\n this.ctx.consumeExperiences(experiences);\n }\n return this.fmt(\"master\", id ?? \"procedure\", result);\n }\n\n // ---- Knowledge management ----\n\n /** Forget: remove any node under the individual by id. */\n async forget(nodeId: string): Promise<string> {\n const result = await this.api.ops[\"role.forget\"](nodeId);\n if (this.ctx.focusedGoalId === nodeId) this.ctx.focusedGoalId = null;\n if (this.ctx.focusedPlanId === nodeId) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"forget\", nodeId, result);\n }\n\n // ---- Skills + unified entry ----\n\n /** Skill: load full skill content by locator. */\n async skill(locator: string): Promise<string> {\n return await this.api.ops[\"role.skill\"](locator);\n }\n\n /** Use: subjective execution — `!ns.method` or ResourceX locator. */\n async use<T = unknown>(locator: string, args?: Record<string, unknown>): Promise<T> {\n const result = await this.api.direct<T>(locator, args);\n // Render issue results as readable text\n if (locator.startsWith(\"!issue.\")) {\n const action = locator.slice(\"!issue.\".length) as IssueAction;\n return (await renderIssueResult(action, result, this.api.resolveLabels)) as T;\n }\n // Render project results as readable text\n if (locator.startsWith(\"!project.\")) {\n const action = locator.slice(\"!project.\".length) as ProjectAction;\n const opResult = result as { state: import(\"@rolexjs/system\").State };\n return renderProjectResult(action, opResult.state) as T;\n }\n return result;\n }\n}\n","/**\n * Rolex — thin API shell.\n *\n * Public API:\n * genesis() — create the world on first run\n * activate(id) — returns a stateful Role handle\n * direct(loc, args) — direct the world to execute an instruction\n *\n * All operation implementations live in @rolexjs/prototype (createOps).\n * Rolex just wires Platform → ops and manages Role lifecycle.\n */\n\nimport type { Platform, RoleXRepository } from \"@rolexjs/core\";\nimport * as C from \"@rolexjs/core\";\nimport { createOps, directives, type Ops, toArgs } from \"@rolexjs/prototype\";\nimport type { Initializer, Runtime, Structure } from \"@rolexjs/system\";\nimport { createIssueX, type IssueX } from \"issuexjs\";\nimport type { ResourceX } from \"resourcexjs\";\nimport { createResourceX, setProvider } from \"resourcexjs\";\nimport { RoleContext } from \"./context.js\";\nimport { findInState } from \"./find.js\";\nimport { Role, type RolexInternal } from \"./role.js\";\n\n/** Summary entry returned by census.list. */\nexport interface CensusEntry {\n id?: string;\n name: string;\n tag?: string;\n}\n\nexport class Rolex {\n private rt: Runtime;\n private ops!: Ops;\n private resourcex?: ResourceX;\n private issuex?: IssueX;\n private repo: RoleXRepository;\n private readonly initializer?: Initializer;\n\n private readonly bootstrap: readonly string[];\n private society!: Structure;\n private past!: Structure;\n\n private constructor(platform: Platform) {\n this.repo = platform.repository;\n this.rt = this.repo.runtime;\n this.initializer = platform.initializer;\n this.bootstrap = platform.bootstrap ?? [];\n\n // Create ResourceX from injected provider\n if (platform.resourcexProvider) {\n setProvider(platform.resourcexProvider);\n this.resourcex = createResourceX(\n platform.resourcexExecutor\n ? { isolator: \"custom\", executor: platform.resourcexExecutor }\n : undefined\n );\n }\n\n // Create IssueX from injected provider\n if (platform.issuexProvider) {\n this.issuex = createIssueX({ provider: platform.issuexProvider });\n }\n }\n\n /** Create a Rolex instance from a Platform (async due to Runtime initialization). */\n static async create(platform: Platform): Promise<Rolex> {\n const rolex = new Rolex(platform);\n await rolex.init();\n return rolex;\n }\n\n /** Async initialization — called by Rolex.create(). */\n private async init(): Promise<void> {\n // Ensure world roots exist\n const roots = await this.rt.roots();\n this.society =\n roots.find((r) => r.name === \"society\") ?? (await this.rt.create(null, C.society));\n\n const societyState = await this.rt.project(this.society);\n const existingPast = societyState.children?.find((c) => c.name === \"past\");\n this.past = existingPast ?? (await this.rt.create(this.society, C.past));\n\n // Create ops from prototype — all operation implementations\n this.ops = createOps({\n rt: this.rt,\n society: this.society,\n past: this.past,\n resolve: async (id: string) => {\n const node = await this.find(id);\n if (!node) throw new Error(`\"${id}\" not found.`);\n return node;\n },\n find: (id: string) => this.find(id),\n resourcex: this.resourcex,\n issuex: this.issuex,\n prototype: this.repo.prototype,\n direct: (locator: string, args?: Record<string, unknown>) => this.direct(locator, args),\n });\n }\n\n /** Genesis — create the world on first run. Settles built-in prototypes. */\n async genesis(): Promise<void> {\n await this.initializer?.bootstrap();\n // Settle bootstrap prototypes\n for (const source of this.bootstrap) {\n await this.direct(\"!prototype.settle\", { source });\n }\n }\n\n /**\n * Activate a role — returns a stateful Role handle.\n *\n * If the individual does not exist in runtime but a prototype is registered,\n * auto-born the individual first.\n */\n async activate(individual: string): Promise<Role> {\n let node = await this.find(individual);\n if (!node) {\n const hasProto = Object.hasOwn(this.repo.prototype.list(), individual);\n if (hasProto) {\n await this.ops[\"individual.born\"](undefined, individual);\n node = (await this.find(individual))!;\n } else {\n throw new Error(`\"${individual}\" not found.`);\n }\n }\n const state = await this.rt.project(node);\n const ctx = new RoleContext(individual);\n ctx.rehydrate(state);\n\n // Restore persisted focus (only override rehydrate default when persisted value is valid)\n const persisted = await this.repo.loadContext(individual);\n if (persisted) {\n if (persisted.focusedGoalId && (await this.find(persisted.focusedGoalId))) {\n ctx.focusedGoalId = persisted.focusedGoalId;\n }\n if (persisted.focusedPlanId && (await this.find(persisted.focusedPlanId))) {\n ctx.focusedPlanId = persisted.focusedPlanId;\n }\n }\n\n // Build internal API for Role — ops + ctx persistence\n const ops = this.ops;\n const repo = this.repo;\n const saveCtx = async (c: RoleContext) => {\n await repo.saveContext(c.roleId, {\n focusedGoalId: c.focusedGoalId,\n focusedPlanId: c.focusedPlanId,\n });\n };\n\n const api: RolexInternal = {\n ops,\n saveCtx,\n direct: this.direct.bind(this),\n resolveLabels: this.issuex\n ? async (ids: string[]) => {\n const names: string[] = [];\n for (const id of ids) {\n const label = await this.issuex!.getLabel(id);\n if (label) names.push(label.name);\n }\n return names;\n }\n : undefined,\n };\n\n return new Role(individual, ctx, api);\n }\n\n /** Find a node by id or alias across the entire society tree. Internal use only. */\n private async find(id: string): Promise<Structure | null> {\n const state = await this.rt.project(this.society);\n return findInState(state, id);\n }\n\n /**\n * Direct the world to execute an instruction.\n *\n * - `!namespace.method` — dispatch to ops\n * - anything else — delegate to ResourceX `ingest`\n */\n async direct<T = unknown>(locator: string, args?: Record<string, unknown>): Promise<T> {\n if (locator.startsWith(\"!\")) {\n const command = locator.slice(1);\n const fn = this.ops[command];\n if (!fn) {\n const hint = directives[\"identity-ethics\"]?.[\"on-unknown-command\"] ?? \"\";\n throw new Error(\n `Unknown command \"${locator}\".\\n\\n` +\n \"You may be guessing the command name. \" +\n \"Load the relevant skill first with skill(locator) to learn the correct syntax.\\n\\n\" +\n hint\n );\n }\n return (await fn(...toArgs(command, args ?? {}))) as T;\n }\n if (!this.resourcex) throw new Error(\"ResourceX is not available.\");\n return this.resourcex.ingest<T>(locator, args);\n }\n}\n\n/** Create a Rolex instance from a Platform. */\nexport async function createRoleX(platform: Platform): Promise<Rolex> {\n return Rolex.create(platform);\n}\n"],"mappings":";AAaA,cAAc;;;ACAP,IAAM,cAAN,MAAkB;AAAA,EACvB;AAAA,EACA,gBAA+B;AAAA,EAC/B,gBAA+B;AAAA,EAEtB,eAAe,oBAAI,IAAY;AAAA,EAC/B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A,QAAI,CAAC,KAAK,UAAW,OAAM,IAAI,MAAM,6BAA6B;AAClE,WAAO,KAAK,UAAU,OAAU,SAAS,IAAI;AAAA,EAC/C;AACF;AAGA,eAAsB,YAAY,UAAoC;AACpE,SAAO,MAAM,OAAO,QAAQ;AAC9B;","names":["c","tag","directives","hint","directives"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/context.ts","../src/feature.ts","../src/find.ts","../src/issue-render.ts","../src/render.ts","../src/project-render.ts","../src/role.ts","../src/rolex.ts"],"sourcesContent":["/**\n * rolexjs — RoleX API + Render layer.\n *\n * Usage:\n * import { Rolex, Role, describe, hint } from \"rolexjs\";\n *\n * const rolex = await createRoleX(platform);\n * await rolex.genesis();\n * const role = await rolex.activate(\"sean\");\n * await role.want(\"Feature: Ship v1\", \"ship-v1\");\n */\n\n// Re-export core (structures + processes)\nexport * from \"@rolexjs/core\";\n// Context\nexport { RoleContext } from \"./context.js\";\n// Feature (Gherkin type + parse/serialize)\nexport type { DataTableRow, Feature, Scenario, Step } from \"./feature.js\";\nexport { parse, serialize } from \"./feature.js\";\n// Find\nexport { findInState } from \"./find.js\";\n// Issue Render\nexport type { IssueAction, LabelResolver } from \"./issue-render.js\";\nexport {\n renderComment,\n renderCommentList,\n renderIssue,\n renderIssueList,\n renderIssueResult,\n} from \"./issue-render.js\";\n// Project Render\nexport type { ProjectAction } from \"./project-render.js\";\nexport { renderProject, renderProjectResult } from \"./project-render.js\";\nexport type { RenderOptions, RenderStateOptions } from \"./render.js\";\n// Render\nexport { describe, detail, directive, hint, render, renderState, world } from \"./render.js\";\n// Role\nexport { Role } from \"./role.js\";\n// API\nexport type { CensusEntry } from \"./rolex.js\";\nexport { createRoleX, Rolex } from \"./rolex.js\";\n","/**\n * RoleContext — stateful session context for role operations.\n *\n * Tracks execution state from the individual's perspective:\n * - roleId (who I am)\n * - focusedGoalId / focusedPlanId (what I'm working on)\n * - encounter / experience id sets (what I have for cognition)\n *\n * Created by activate, updated by subsequent role operations.\n * Consumers (MCP, CLI) hold a reference and pass it through.\n */\nimport type { State } from \"@rolexjs/system\";\n\nexport class RoleContext {\n roleId: string;\n focusedGoalId: string | null = null;\n focusedPlanId: string | null = null;\n\n readonly encounterIds = new Set<string>();\n readonly experienceIds = new Set<string>();\n\n constructor(roleId: string) {\n this.roleId = roleId;\n }\n\n // ================================================================\n // Requirements — throw if missing\n // ================================================================\n\n requireGoalId(): string {\n if (!this.focusedGoalId) throw new Error(\"No focused goal. Call want first.\");\n return this.focusedGoalId;\n }\n\n requirePlanId(): string {\n if (!this.focusedPlanId) throw new Error(\"No focused plan. Call plan first.\");\n return this.focusedPlanId;\n }\n\n // ================================================================\n // Cognition registries\n // ================================================================\n\n addEncounter(id: string) {\n this.encounterIds.add(id);\n }\n\n requireEncounterIds(ids: string[]) {\n for (const id of ids) {\n if (!this.encounterIds.has(id)) throw new Error(`Encounter not found: \"${id}\"`);\n }\n }\n\n consumeEncounters(ids: string[]) {\n for (const id of ids) {\n this.encounterIds.delete(id);\n }\n }\n\n addExperience(id: string) {\n this.experienceIds.add(id);\n }\n\n requireExperienceIds(ids: string[]) {\n for (const id of ids) {\n if (!this.experienceIds.has(id)) throw new Error(`Experience not found: \"${id}\"`);\n }\n }\n\n consumeExperiences(ids: string[]) {\n for (const id of ids) {\n this.experienceIds.delete(id);\n }\n }\n\n // ================================================================\n // Rehydration — rebuild from activation state\n // ================================================================\n\n /** Walk the state tree and populate registries. */\n rehydrate(state: State) {\n this.walk(state);\n }\n\n private walk(node: State) {\n if (node.id) {\n switch (node.name) {\n case \"goal\":\n if (!this.focusedGoalId) this.focusedGoalId = node.id;\n break;\n case \"encounter\":\n this.encounterIds.add(node.id);\n break;\n case \"experience\":\n this.experienceIds.add(node.id);\n break;\n }\n }\n for (const child of (node as State & { children?: readonly State[] }).children ?? []) {\n this.walk(child);\n }\n }\n\n // ================================================================\n // Cognitive hints — state-aware AI self-direction cues\n // ================================================================\n\n /** First-person, state-aware hint for the AI after an operation. */\n cognitiveHint(process: string): string | null {\n switch (process) {\n case \"activate\":\n if (!this.focusedGoalId)\n return \"I have no goal yet. I should call `want` to declare one, or `focus` to review existing goals.\";\n return \"I have an active goal. I should call `focus` to review progress, or `want` to declare a new goal.\";\n\n case \"focus\":\n if (!this.focusedPlanId)\n return \"I have a goal but no focused plan. I should call `plan` to create or focus on one.\";\n return \"I have a plan. I should call `todo` to create tasks, or continue working.\";\n\n case \"want\":\n return \"Goal declared. I should call `plan` to design how to achieve it.\";\n\n case \"plan\":\n return \"Plan created. I should call `todo` to create concrete tasks.\";\n\n case \"todo\":\n return \"Task created. I can add more with `todo`, or start working and call `finish` when done.\";\n\n case \"finish\": {\n const encCount = this.encounterIds.size;\n if (encCount > 0 && !this.focusedGoalId)\n return `Task finished. No more goals — I have ${encCount} encounter(s) to choose from for \\`reflect\\`, or \\`want\\` a new goal.`;\n return \"Task finished. I should continue with remaining tasks, or call `complete` when the plan is done.\";\n }\n\n case \"complete\":\n case \"abandon\": {\n const encCount = this.encounterIds.size;\n const goalNote = this.focusedGoalId\n ? ` I should check if goal \"${this.focusedGoalId}\" needs a new \\`plan\\`, or \\`forget\\` it if the direction is fulfilled.`\n : \"\";\n if (encCount > 0)\n return `Plan closed.${goalNote} I have ${encCount} encounter(s) to choose from for \\`reflect\\`, or I can continue with other plans.`;\n return `Plan closed.${goalNote} I can create a new \\`plan\\`, or \\`focus\\` on another goal.`;\n }\n\n case \"reflect\": {\n const expCount = this.experienceIds.size;\n if (expCount > 0)\n return `Experience gained. I can \\`realize\\` principles or \\`master\\` procedures — ${expCount} experience(s) available.`;\n return \"Experience gained. I can `realize` a principle, `master` a procedure, or continue working.\";\n }\n\n case \"realize\":\n return \"Principle added. I should continue working.\";\n\n case \"master\":\n return \"Procedure added. I should continue working.\";\n\n default:\n return null;\n }\n }\n}\n","/**\n * Feature — the information format for the RoleX concept world.\n *\n * Every node's information is a Gherkin Feature.\n * This is our own type — decoupled from @cucumber/messages.\n */\n\nexport interface Feature {\n readonly name: string;\n readonly description?: string;\n readonly tags?: readonly string[];\n readonly scenarios: readonly Scenario[];\n}\n\nexport interface Scenario {\n readonly name: string;\n readonly description?: string;\n readonly tags?: readonly string[];\n readonly steps: readonly Step[];\n}\n\nexport interface Step {\n readonly keyword: string;\n readonly text: string;\n readonly dataTable?: readonly DataTableRow[];\n}\n\nexport interface DataTableRow {\n readonly cells: readonly string[];\n}\n\n// ================================================================\n// Parse + Serialize\n// ================================================================\n\nimport { parse as parseGherkin } from \"@rolexjs/parser\";\n\n/** Parse a Gherkin source string into a Feature. */\nexport function parse(source: string): Feature {\n const doc = parseGherkin(source);\n const f = doc.feature;\n if (!f) throw new Error(\"No Feature found in source\");\n\n return {\n name: f.name,\n ...(f.description?.trim() ? { description: f.description.trim() } : {}),\n ...(f.tags?.length ? { tags: f.tags.map((t) => t.name) } : {}),\n scenarios: (f.children ?? [])\n .filter((c) => c.scenario)\n .map((c) => {\n const s = c.scenario!;\n return {\n name: s.name,\n ...(s.description?.trim() ? { description: s.description.trim() } : {}),\n ...(s.tags?.length ? { tags: s.tags.map((t) => t.name) } : {}),\n steps: (s.steps ?? []).map((st) => ({\n keyword: st.keyword,\n text: st.text,\n ...(st.dataTable\n ? {\n dataTable: st.dataTable.rows.map((r) => ({\n cells: r.cells.map((c) => c.value),\n })),\n }\n : {}),\n })),\n };\n }),\n };\n}\n\n/** Serialize a Feature back to Gherkin source string. */\nexport function serialize(feature: Feature): string {\n const lines: string[] = [];\n\n if (feature.tags?.length) {\n lines.push(feature.tags.join(\" \"));\n }\n lines.push(`Feature: ${feature.name}`);\n if (feature.description) {\n for (const line of feature.description.split(\"\\n\")) {\n lines.push(` ${line}`);\n }\n }\n\n for (const scenario of feature.scenarios) {\n lines.push(\"\");\n if (scenario.tags?.length) {\n lines.push(` ${scenario.tags.join(\" \")}`);\n }\n lines.push(` Scenario: ${scenario.name}`);\n if (scenario.description) {\n for (const line of scenario.description.split(\"\\n\")) {\n lines.push(` ${line}`);\n }\n }\n for (const step of scenario.steps) {\n lines.push(` ${step.keyword}${step.text}`);\n if (step.dataTable) {\n for (const row of step.dataTable) {\n lines.push(` | ${row.cells.join(\" | \")} |`);\n }\n }\n }\n }\n\n return `${lines.join(\"\\n\")}\\n`;\n}\n","/**\n * Find — unified node lookup with priority-based disambiguation.\n *\n * When multiple nodes share the same id (allowed after relaxing\n * global uniqueness), prefer \"addressable\" nodes over internal metadata.\n *\n * Priority (lower = preferred):\n * 0: individual, organization, position — top-level entities\n * 1: goal — execution roots\n * 2: plan, task — execution nodes\n * 3: procedure, principle — individual knowledge\n * 4: encounter, experience — cognition artifacts\n * 5: identity, charter — structural definitions\n * 6: duty, requirement, background, etc. — internal metadata\n */\nimport type { State, Structure } from \"@rolexjs/system\";\n\nconst PRIORITY: Record<string, number> = {\n individual: 0,\n organization: 0,\n position: 0,\n goal: 1,\n plan: 2,\n task: 2,\n procedure: 3,\n principle: 3,\n encounter: 4,\n experience: 4,\n identity: 5,\n charter: 5,\n duty: 6,\n requirement: 6,\n background: 6,\n tone: 6,\n mindset: 6,\n};\n\nfunction priorityOf(name: string): number {\n return PRIORITY[name] ?? 7;\n}\n\nfunction matches(node: State, target: string): boolean {\n if (node.id?.toLowerCase() === target) return true;\n if (node.alias) {\n for (const a of node.alias) {\n if (a.toLowerCase() === target) return true;\n }\n }\n return false;\n}\n\n/**\n * Find a node by id or alias in a state tree.\n *\n * When multiple nodes match, returns the one with the highest priority\n * (top-level entities > execution nodes > knowledge > metadata).\n */\nexport function findInState(state: State, target: string): Structure | null {\n const lowered = target.toLowerCase();\n let best: Structure | null = null;\n let bestPriority = Infinity;\n\n function walk(node: State): void {\n if (matches(node, lowered)) {\n const p = priorityOf(node.name);\n if (p < bestPriority) {\n best = node;\n bestPriority = p;\n if (p === 0) return; // Can't do better\n }\n }\n for (const child of node.children ?? []) {\n walk(child);\n if (bestPriority === 0) return; // Early exit\n }\n }\n\n walk(state);\n return best;\n}\n","/**\n * Issue Render — format IssueX data as readable text.\n *\n * Lightweight rendering for issue operations.\n * Unlike the core render layer (which projects State trees),\n * this module formats flat IssueX objects into human-readable strings.\n */\nimport type { Comment, Issue } from \"issuexjs\";\n\n// ================================================================\n// Types\n// ================================================================\n\nexport type IssueAction =\n | \"publish\"\n | \"get\"\n | \"list\"\n | \"close\"\n | \"reopen\"\n | \"update\"\n | \"assign\"\n | \"comment\"\n | \"comments\"\n | \"label\"\n | \"unlabel\";\n\nexport type LabelResolver = (ids: string[]) => Promise<string[]>;\n\n// ================================================================\n// Single Issue\n// ================================================================\n\nexport function renderIssue(issue: Issue, labelNames?: string[]): string {\n const lines: string[] = [];\n\n lines.push(`#${issue.number} ${issue.title} [${issue.status}]`);\n\n const meta: string[] = [`Author: ${issue.author}`];\n if (issue.assignee) meta.push(`Assignee: ${issue.assignee}`);\n if (labelNames && labelNames.length > 0) {\n meta.push(`Labels: ${labelNames.join(\", \")}`);\n }\n lines.push(meta.join(\" | \"));\n\n if (issue.body) {\n lines.push(\"───\");\n lines.push(issue.body);\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Issue List\n// ================================================================\n\nexport function renderIssueList(issues: Issue[]): string {\n if (issues.length === 0) return \"No issues found.\";\n\n const lines: string[] = [];\n for (const issue of issues) {\n const assignee = issue.assignee ? ` → ${issue.assignee}` : \"\";\n lines.push(`#${issue.number} [${issue.status}] ${issue.title} (${issue.author}${assignee})`);\n }\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Comments\n// ================================================================\n\nexport function renderComment(comment: Comment): string {\n const time = formatTime(comment.createdAt);\n return `${comment.author} (${time}):\\n${comment.body}`;\n}\n\nexport function renderCommentList(comments: Comment[]): string {\n if (comments.length === 0) return \"No comments.\";\n return comments.map(renderComment).join(\"\\n───\\n\");\n}\n\n// ================================================================\n// Status line\n// ================================================================\n\nconst statusTemplates: Record<string, (issue: Issue) => string> = {\n publish: (i) => `Issue #${i.number} created.`,\n close: (i) => `Issue #${i.number} closed.`,\n reopen: (i) => `Issue #${i.number} reopened.`,\n update: (i) => `Issue #${i.number} updated.`,\n assign: (i) => `Issue #${i.number} assigned to ${i.assignee ?? \"nobody\"}.`,\n comment: (i) => `Comment added to #${i.number}.`,\n label: (i) => `Label added to #${i.number}.`,\n unlabel: (i) => `Label removed from #${i.number}.`,\n};\n\n// ================================================================\n// Compose — the main entry point for Role.use()\n// ================================================================\n\n/**\n * Render an issue operation result as readable text.\n * Dispatches to the right renderer based on action.\n */\nexport async function renderIssueResult(\n action: IssueAction,\n result: unknown,\n resolveLabels?: LabelResolver\n): Promise<string> {\n switch (action) {\n case \"list\":\n return renderIssueList(result as Issue[]);\n\n case \"comments\":\n return renderCommentList(result as Comment[]);\n\n case \"comment\": {\n const comment = result as Comment;\n return `Comment added to issue.\\n\\n${renderComment(comment)}`;\n }\n\n case \"get\": {\n if (!result) return \"Issue not found.\";\n const issue = result as Issue;\n const labelNames = await resolveLabelNames(issue, resolveLabels);\n return renderIssue(issue, labelNames);\n }\n\n default: {\n // All other actions return an Issue with a status line\n const issue = result as Issue;\n const labelNames = await resolveLabelNames(issue, resolveLabels);\n const status = statusTemplates[action]?.(issue) ?? `Issue #${issue.number} ${action}.`;\n return `${status}\\n\\n${renderIssue(issue, labelNames)}`;\n }\n }\n}\n\n// ================================================================\n// Helpers\n// ================================================================\n\nfunction formatTime(iso: string): string {\n return iso.replace(\"T\", \" \").replace(/\\.\\d+Z$/, \"\");\n}\n\nasync function resolveLabelNames(\n issue: Issue,\n resolveLabels?: LabelResolver\n): Promise<string[] | undefined> {\n if (!issue.labels || issue.labels.length === 0) return undefined;\n if (!resolveLabels) return undefined;\n return resolveLabels(issue.labels);\n}\n","/**\n * Render — 3-layer output for all Rolex operations.\n *\n * Layer 1: Status — what just happened (describe)\n * Layer 2: Hint — what to do next (hint + cognitive hint)\n * Layer 3: Projection — full state tree as markdown (renderState)\n *\n * render() composes the 3 layers. MCP and CLI are pure pass-through.\n */\nimport type { State } from \"@rolexjs/system\";\n\n// ================================================================\n// Description — what happened\n// ================================================================\n\nconst descriptions: Record<string, (name: string, state: State) => string> = {\n // Lifecycle\n born: (n) => `Individual \"${n}\" is born.`,\n found: (n) => `Organization \"${n}\" is founded.`,\n establish: (n) => `Position \"${n}\" is established.`,\n charter: (n) => `Charter defined for \"${n}\".`,\n charge: (n) => `Duty \"${n}\" assigned.`,\n retire: (n) => `\"${n}\" retired.`,\n die: (n) => `\"${n}\" is gone.`,\n dissolve: (n) => `Organization \"${n}\" dissolved.`,\n abolish: (n) => `Position \"${n}\" abolished.`,\n rehire: (n) => `\"${n}\" is back.`,\n\n // Organization\n hire: (n) => `\"${n}\" hired.`,\n fire: (n) => `\"${n}\" fired.`,\n appoint: (n) => `\"${n}\" appointed.`,\n dismiss: (n) => `\"${n}\" dismissed.`,\n\n // Project\n launch: (n) => `Project \"${n}\" launched.`,\n scope: (n) => `Scope defined for \"${n}\".`,\n milestone: (n) => `Milestone \"${n}\" added.`,\n achieve: (n) => `Milestone \"${n}\" achieved.`,\n enroll: (n) => `\"${n}\" enrolled.`,\n remove: (n) => `\"${n}\" removed.`,\n deliver: (n) => `Deliverable \"${n}\" added.`,\n wiki: (n) => `Wiki entry \"${n}\" added.`,\n archive: (n) => `Project \"${n}\" archived.`,\n\n // Role\n activate: (n) => `Role \"${n}\" activated.`,\n focus: (n) => `Focused on goal \"${n}\".`,\n\n // Execution\n want: (n) => `Goal \"${n}\" declared.`,\n plan: (n) => `Plan created for \"${n}\".`,\n todo: (n) => `Task \"${n}\" added.`,\n finish: (n) => `Task \"${n}\" finished → encounter recorded.`,\n complete: (n) => `Plan \"${n}\" completed → encounter recorded.`,\n abandon: (n) => `Plan \"${n}\" abandoned → encounter recorded.`,\n\n // Cognition\n reflect: (n) => `Reflected on \"${n}\" → experience gained.`,\n realize: (n) => `Realized principle from \"${n}\".`,\n master: (n) => `Mastered procedure from \"${n}\".`,\n\n // Knowledge management\n forget: (n) => `\"${n}\" forgotten.`,\n};\n\nexport function describe(process: string, name: string, state: State): string {\n const fn = descriptions[process];\n return fn ? fn(name, state) : `${process} completed.`;\n}\n\n// ================================================================\n// Hint — what to do next\n// ================================================================\n\nconst hints: Record<string, string> = {\n // Lifecycle\n born: \"hire into an organization, or activate to start working.\",\n found: \"define a charter for the organization.\",\n establish: \"charge with duties, then appoint members.\",\n charter: \"establish positions for the organization.\",\n charge: \"appoint someone to this position.\",\n retire: \"rehire if needed later.\",\n die: \"this individual is permanently gone.\",\n dissolve: \"the organization no longer exists.\",\n abolish: \"the position no longer exists.\",\n rehire: \"activate to resume working.\",\n\n // Organization\n hire: \"appoint to a position, or activate to start working.\",\n fire: \"the individual is no longer a member.\",\n appoint: \"the individual now holds this position.\",\n dismiss: \"the position is now vacant.\",\n\n // Project\n launch: \"define scope, add milestones, or enroll members.\",\n scope: \"add milestones to break down the project.\",\n milestone: \"enroll members and start working.\",\n achieve: \"continue with remaining milestones, or archive the project.\",\n enroll: \"assign milestones and start working.\",\n remove: \"the individual is no longer a participant.\",\n deliver: \"deliverable recorded.\",\n wiki: \"knowledge entry recorded.\",\n archive: \"the project is archived.\",\n\n // Role\n activate: \"want a goal, or check the current state.\",\n focus: \"plan how to work toward it, or add tasks.\",\n\n // Execution\n want: \"plan how to work toward it.\",\n plan: \"add tasks with todo.\",\n todo: \"start working, finish when done.\",\n finish: \"continue with remaining tasks, or complete the plan.\",\n complete: \"reflect on encounters to gain experience.\",\n abandon: \"reflect on encounters to learn from the experience.\",\n\n // Cognition\n reflect: \"realize principles or master procedures from experience.\",\n realize: \"principle added.\",\n master: \"procedure added.\",\n\n // Knowledge management\n forget: \"the node has been removed.\",\n};\n\nexport function hint(process: string): string {\n const h = hints[process];\n return h ? `Next: ${h}` : \"What would you like to do next?\";\n}\n\n// ================================================================\n// Detail — longer process descriptions (from .feature files)\n// ================================================================\n\nimport { directives, processes, world } from \"@rolexjs/prototype\";\n\n/** Full Gherkin feature content for a process — sourced from .feature files. */\nexport function detail(process: string): string {\n return processes[process] ?? \"\";\n}\n\n/** World feature descriptions — framework-level instructions. */\nexport { world };\n\n// ================================================================\n// Directive — system-level commands at decision points\n// ================================================================\n\n/** Get a directive by topic and scenario. Returns empty string if not found. */\nexport function directive(topic: string, scenario: string): string {\n return directives[topic]?.[scenario] ?? \"\";\n}\n\n// ================================================================\n// Generic State renderer — renders any State tree as markdown\n// ================================================================\n\n/**\n * renderState — markdown renderer for State trees.\n *\n * Rules:\n * - Heading: \"#\" repeated to depth + \" [name]\"\n * - Body: raw information field as-is (full Gherkin preserved)\n * - Links: \"> → relation [target.name]\" with target feature name\n * - Children: sorted by concept hierarchy, then rendered at depth+1\n * - Fold: when fold(node) returns true, render heading only (no body/links/children)\n *\n * Markdown heading depth caps at 6 (######).\n */\nexport interface RenderStateOptions {\n /** When returns true, render only the heading — skip body, links, and children. */\n fold?: (node: State) => boolean;\n}\n\nexport function renderState(state: State, depth = 1, options?: RenderStateOptions): string {\n const lines: string[] = [];\n const level = Math.min(depth, 6);\n const heading = \"#\".repeat(level);\n\n // Heading: [name] (id) {origin} #tag [progress]\n const idPart = state.id ? ` (${state.id})` : \"\";\n const originPart = state.origin ? ` {${state.origin}}` : \"\";\n const tagPart = state.tag ? ` #${state.tag}` : \"\";\n const progressPart = state.name === \"goal\" ? goalProgress(state) : \"\";\n lines.push(`${heading} [${state.name}]${idPart}${originPart}${tagPart}${progressPart}`);\n\n // Folded: heading only\n if (options?.fold?.(state)) {\n return lines.join(\"\\n\");\n }\n\n // Body: full information as-is\n if (state.information) {\n lines.push(\"\");\n lines.push(state.information);\n }\n\n // Links — plan references are compact, organizational links are expanded\n if (state.links && state.links.length > 0) {\n const compactRelations = new Set([\"after\", \"before\", \"fallback\", \"fallback-for\"]);\n const compact = state.links.filter((l) => compactRelations.has(l.relation));\n const expanded = state.links.filter((l) => !compactRelations.has(l.relation));\n for (const link of compact) {\n const targetId = link.target.id ? ` (${link.target.id})` : \"\";\n const targetTag = link.target.tag ? ` #${link.target.tag}` : \"\";\n lines.push(`> ${link.relation}: [${link.target.name}]${targetId}${targetTag}`);\n }\n if (expanded.length > 0) {\n const targets = sortByConceptOrder(expanded.map((l) => l.target));\n for (const target of targets) {\n lines.push(\"\");\n lines.push(renderState(target, depth + 1, options));\n }\n }\n }\n\n // Children — sorted by concept hierarchy, empty nodes filtered out\n if (state.children && state.children.length > 0) {\n const sorted = sortByConceptOrder(state.children.filter((c) => !isEmpty(c)));\n for (const child of sorted) {\n lines.push(\"\");\n lines.push(renderState(child, depth + 1, options));\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Concept ordering — children sorted by structure hierarchy\n// ================================================================\n\n/** Concept tree order: identity → cognition → knowledge → execution → organization. */\nconst CONCEPT_ORDER: readonly string[] = [\n // Individual — Identity\n \"identity\",\n \"background\",\n \"tone\",\n \"mindset\",\n // Individual — Cognition\n \"encounter\",\n \"experience\",\n // Individual — Knowledge\n \"principle\",\n \"procedure\",\n // Individual — Execution\n \"goal\",\n \"plan\",\n \"task\",\n // Organization\n \"charter\",\n // Position\n \"position\",\n \"duty\",\n // Project\n \"scope\",\n \"milestone\",\n \"deliverable\",\n \"wiki\",\n];\n\n/** Summarize plan/task completion for a goal heading. */\nfunction goalProgress(goal: State): string {\n let plans = 0;\n let plansDone = 0;\n let tasks = 0;\n let tasksDone = 0;\n\n function walk(node: State): void {\n if (node.name === \"plan\") {\n plans++;\n if (node.tag === \"done\" || node.tag === \"abandoned\") plansDone++;\n } else if (node.name === \"task\") {\n tasks++;\n if (node.tag === \"done\") tasksDone++;\n }\n for (const child of node.children ?? []) walk(child);\n }\n\n for (const child of goal.children ?? []) walk(child);\n if (plans === 0 && tasks === 0) return \"\";\n const parts: string[] = [];\n if (plans > 0) parts.push(`${plansDone}/${plans} plans`);\n if (tasks > 0) parts.push(`${tasksDone}/${tasks} tasks`);\n return ` [${parts.join(\", \")}]`;\n}\n\n/** A node is empty when it has no id, no information, and no children. */\nfunction isEmpty(node: State): boolean {\n return !node.id && !node.information && (!node.children || node.children.length === 0);\n}\n\n/** Sort children by concept hierarchy order. Unknown names go to the end, preserving relative order. */\nfunction sortByConceptOrder(children: readonly State[]): readonly State[] {\n return [...children].sort((a, b) => {\n const ai = CONCEPT_ORDER.indexOf(a.name);\n const bi = CONCEPT_ORDER.indexOf(b.name);\n const aOrder = ai >= 0 ? ai : CONCEPT_ORDER.length;\n const bOrder = bi >= 0 ? bi : CONCEPT_ORDER.length;\n return aOrder - bOrder;\n });\n}\n\n// ================================================================\n// Render — 3-layer output for tool results\n// ================================================================\n\nexport interface RenderOptions {\n /** The process that was executed. */\n process: string;\n /** Display name for the primary node. */\n name: string;\n /** State projection of the affected node. */\n state: State;\n /** AI cognitive hint — first-person, state-aware self-direction cue. */\n cognitiveHint?: string | null;\n /** Fold predicate — folded nodes render heading only. */\n fold?: RenderStateOptions[\"fold\"];\n}\n\n/** Render a full 3-layer output string. */\nexport function render(opts: RenderOptions): string {\n const { process, name, state, cognitiveHint, fold } = opts;\n const lines: string[] = [];\n\n // Layer 1: Status\n lines.push(describe(process, name, state));\n\n // Layer 2: Hint (static) + Cognitive hint (state-aware)\n lines.push(hint(process));\n if (cognitiveHint) {\n lines.push(`I → ${cognitiveHint}`);\n }\n\n // Layer 3: Projection — generic markdown rendering of the full state tree\n lines.push(\"\");\n lines.push(renderState(state, 1, fold ? { fold } : undefined));\n\n return lines.join(\"\\n\");\n}\n","/**\n * Project Render — format project state as readable text.\n *\n * Renders project operations into human-readable summaries.\n * Participation links show member names only (not full individual trees).\n * Milestones show progress status (#done or pending).\n */\nimport type { State } from \"@rolexjs/system\";\nimport { describe, hint } from \"./render.js\";\n\n// ================================================================\n// Types\n// ================================================================\n\nexport type ProjectAction =\n | \"launch\"\n | \"scope\"\n | \"milestone\"\n | \"achieve\"\n | \"enroll\"\n | \"remove\"\n | \"deliver\"\n | \"wiki\"\n | \"archive\";\n\n// ================================================================\n// Project Overview\n// ================================================================\n\nexport function renderProject(state: State): string {\n const lines: string[] = [];\n const id = state.id ?? \"(no id)\";\n const tag = state.tag ? ` #${state.tag}` : \"\";\n\n // Title\n lines.push(`# ${id}${tag}`);\n\n // Feature body\n if (state.information) {\n lines.push(\"\");\n lines.push(state.information);\n }\n\n // Members (participation links — compact)\n const members = state.links?.filter((l) => l.relation === \"participation\") ?? [];\n if (members.length > 0) {\n lines.push(\"\");\n lines.push(\"## Members\");\n for (const m of members) {\n const alias = m.target.alias?.length ? ` (${m.target.alias.join(\", \")})` : \"\";\n lines.push(`- ${m.target.id ?? \"(no id)\"}${alias}`);\n }\n }\n\n // Children by type\n const children = state.children ?? [];\n\n const scopes = children.filter((c) => c.name === \"scope\");\n const milestones = children.filter((c) => c.name === \"milestone\");\n const deliverables = children.filter((c) => c.name === \"deliverable\");\n const wikis = children.filter((c) => c.name === \"wiki\");\n\n if (scopes.length > 0) {\n lines.push(\"\");\n lines.push(\"## Scope\");\n for (const s of scopes) {\n if (s.information) lines.push(s.information);\n }\n }\n\n if (milestones.length > 0) {\n lines.push(\"\");\n lines.push(\"## Milestones\");\n for (const m of milestones) {\n const tag = m.tag ? ` #${m.tag}` : \"\";\n const marker = m.tag === \"done\" ? \"[x]\" : \"[ ]\";\n const title = extractFeatureTitle(m.information);\n lines.push(`- ${marker} ${m.id ?? title}${tag}`);\n if (m.information && m.id) {\n const desc = extractFeatureTitle(m.information);\n if (desc && desc !== m.id) lines.push(` ${desc}`);\n }\n }\n }\n\n if (deliverables.length > 0) {\n lines.push(\"\");\n lines.push(\"## Deliverables\");\n for (const d of deliverables) {\n const title = d.id ?? extractFeatureTitle(d.information);\n lines.push(`- ${title}`);\n }\n }\n\n if (wikis.length > 0) {\n lines.push(\"\");\n lines.push(\"## Wiki\");\n for (const w of wikis) {\n const title = w.id ?? extractFeatureTitle(w.information);\n lines.push(`- ${title}`);\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Compose — main entry point\n// ================================================================\n\n/**\n * Render a project operation result as readable text.\n * Returns status + hint + project overview.\n */\nexport function renderProjectResult(action: ProjectAction, state: State): string {\n const name = state.id ?? state.name;\n const lines: string[] = [];\n\n // Layer 1: Status\n lines.push(describe(action, name, state));\n\n // Layer 2: Hint\n lines.push(hint(action));\n\n // Layer 3: Project overview\n // For child operations (scope, milestone, etc.), find the project parent\n const projectState = isProjectNode(state) ? state : null;\n if (projectState) {\n lines.push(\"\");\n lines.push(renderProject(projectState));\n }\n\n return lines.join(\"\\n\");\n}\n\n// ================================================================\n// Helpers\n// ================================================================\n\nfunction isProjectNode(state: State): boolean {\n return state.name === \"project\";\n}\n\nfunction extractFeatureTitle(information?: string | null): string {\n if (!information) return \"(untitled)\";\n const match = information.match(/^Feature:\\s*(.+)$/m);\n return match?.[1]?.trim() ?? information.split(\"\\n\")[0].trim();\n}\n","/**\n * Role — stateful handle returned by Rolex.activate().\n *\n * Holds roleId + RoleContext internally.\n * All operations return rendered 3-layer text (status + hint + projection).\n * MCP and CLI are pure pass-through — no render logic needed.\n *\n * Usage:\n * const role = await rolex.activate(\"sean\");\n * await role.want(\"Feature: Ship v1\", \"ship-v1\"); // → rendered string\n * await role.plan(\"Feature: Phase 1\", \"phase-1\"); // → rendered string\n * await role.finish(\"write-tests\", \"Feature: Tests written\");\n */\n\nimport type { OpResult, Ops } from \"@rolexjs/prototype\";\nimport type { RoleContext } from \"./context.js\";\nimport { type IssueAction, type LabelResolver, renderIssueResult } from \"./issue-render.js\";\nimport { type ProjectAction, renderProjectResult } from \"./project-render.js\";\nimport { render } from \"./render.js\";\n\n/**\n * Internal API surface that Role delegates to.\n * Constructed by Rolex.activate() — not part of public API.\n */\nexport interface RolexInternal {\n ops: Ops;\n saveCtx(ctx: RoleContext): void | Promise<void>;\n direct<T>(locator: string, args?: Record<string, unknown>): Promise<T>;\n resolveLabels?: LabelResolver;\n}\n\nexport class Role {\n readonly roleId: string;\n readonly ctx: RoleContext;\n private api: RolexInternal;\n\n constructor(roleId: string, ctx: RoleContext, api: RolexInternal) {\n this.roleId = roleId;\n this.ctx = ctx;\n this.api = api;\n }\n\n /** Project the individual's full state tree (used after activate). */\n async project(): Promise<string> {\n const result = await this.api.ops[\"role.focus\"](this.roleId);\n const focusedGoalId = this.ctx.focusedGoalId;\n return this.fmt(\"activate\", this.roleId, result, {\n fold: (node) =>\n (node.name === \"goal\" && node.id !== focusedGoalId) || node.name === \"requirement\",\n });\n }\n\n /** Render an OpResult into a 3-layer output string. */\n private fmt(\n process: string,\n name: string,\n result: OpResult,\n extra?: { fold?: (node: import(\"@rolexjs/system\").State) => boolean }\n ): string {\n return render({\n process,\n name,\n state: result.state,\n cognitiveHint: this.ctx.cognitiveHint(process) ?? null,\n fold: extra?.fold,\n });\n }\n\n private async save(): Promise<void> {\n await this.api.saveCtx(this.ctx);\n }\n\n // ---- Execution ----\n\n /** Focus: view or switch focused goal. Only accepts goal ids. */\n async focus(goal?: string): Promise<string> {\n const goalId = goal ?? this.ctx.requireGoalId();\n const result = await this.api.ops[\"role.focus\"](goalId);\n if (result.state.name !== \"goal\") {\n throw new Error(\n `\"${goalId}\" is a ${result.state.name}, not a goal. focus only accepts goal ids.`\n );\n }\n const switched = goalId !== this.ctx.focusedGoalId;\n this.ctx.focusedGoalId = goalId;\n if (switched) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"focus\", goalId, result);\n }\n\n /** Want: declare a goal. */\n async want(goal?: string, id?: string, alias?: readonly string[]): Promise<string> {\n const result = await this.api.ops[\"role.want\"](this.roleId, goal, id, alias);\n if (id) this.ctx.focusedGoalId = id;\n this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"want\", id ?? this.roleId, result);\n }\n\n /** Plan: create a plan for the focused goal. */\n async plan(plan?: string, id?: string, after?: string, fallback?: string): Promise<string> {\n const result = await this.api.ops[\"role.plan\"](\n this.ctx.requireGoalId(),\n plan,\n id,\n after,\n fallback\n );\n if (id) this.ctx.focusedPlanId = id;\n await this.save();\n return this.fmt(\"plan\", id ?? \"plan\", result);\n }\n\n /** Todo: add a task to the focused plan. */\n async todo(task?: string, id?: string, alias?: readonly string[]): Promise<string> {\n const result = await this.api.ops[\"role.todo\"](this.ctx.requirePlanId(), task, id, alias);\n return this.fmt(\"todo\", id ?? \"task\", result);\n }\n\n /** Finish: complete a task, optionally record an encounter. */\n async finish(task: string, encounter?: string): Promise<string> {\n const result = await this.api.ops[\"role.finish\"](task, this.roleId, encounter);\n if (encounter && result.state.id) {\n this.ctx.addEncounter(result.state.id);\n }\n return this.fmt(\"finish\", task, result);\n }\n\n /** Complete: close a plan as done, record encounter. */\n async complete(plan?: string, encounter?: string): Promise<string> {\n const planId = plan ?? this.ctx.requirePlanId();\n const result = await this.api.ops[\"role.complete\"](planId, this.roleId, encounter);\n this.ctx.addEncounter(result.state.id ?? planId);\n if (this.ctx.focusedPlanId === planId) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"complete\", planId, result);\n }\n\n /** Abandon: drop a plan, record encounter. */\n async abandon(plan?: string, encounter?: string): Promise<string> {\n const planId = plan ?? this.ctx.requirePlanId();\n const result = await this.api.ops[\"role.abandon\"](planId, this.roleId, encounter);\n this.ctx.addEncounter(result.state.id ?? planId);\n if (this.ctx.focusedPlanId === planId) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"abandon\", planId, result);\n }\n\n // ---- Cognition ----\n\n /** Reflect: consume encounters → experience. Empty encounters = direct creation. */\n async reflect(encounters: string[], experience?: string, id?: string): Promise<string> {\n if (encounters.length > 0) {\n this.ctx.requireEncounterIds(encounters);\n }\n // First encounter goes through ops (creates experience + removes encounter)\n const first = encounters[0] as string | undefined;\n const result = await this.api.ops[\"role.reflect\"](first, this.roleId, experience, id);\n // Remaining encounters are consumed via forget\n for (let i = 1; i < encounters.length; i++) {\n await this.api.ops[\"role.forget\"](encounters[i]);\n }\n if (encounters.length > 0) {\n this.ctx.consumeEncounters(encounters);\n }\n if (id) this.ctx.addExperience(id);\n return this.fmt(\"reflect\", id ?? \"experience\", result);\n }\n\n /** Realize: consume experiences → principle. Empty experiences = direct creation. */\n async realize(experiences: string[], principle?: string, id?: string): Promise<string> {\n if (experiences.length > 0) {\n this.ctx.requireExperienceIds(experiences);\n }\n // First experience goes through ops (creates principle + removes experience)\n const first = experiences[0] as string | undefined;\n const result = await this.api.ops[\"role.realize\"](first, this.roleId, principle, id);\n // Remaining experiences are consumed via forget\n for (let i = 1; i < experiences.length; i++) {\n await this.api.ops[\"role.forget\"](experiences[i]);\n }\n if (experiences.length > 0) {\n this.ctx.consumeExperiences(experiences);\n }\n return this.fmt(\"realize\", id ?? \"principle\", result);\n }\n\n /** Master: create procedure, optionally consuming experiences. */\n async master(procedure: string, id?: string, experiences?: string[]): Promise<string> {\n if (experiences && experiences.length > 0) {\n this.ctx.requireExperienceIds(experiences);\n }\n // First experience goes through ops (creates procedure + removes experience)\n const first = experiences?.[0];\n const result = await this.api.ops[\"role.master\"](this.roleId, procedure, id, first);\n // Remaining experiences are consumed via forget\n if (experiences) {\n for (let i = 1; i < experiences.length; i++) {\n await this.api.ops[\"role.forget\"](experiences[i]);\n }\n this.ctx.consumeExperiences(experiences);\n }\n return this.fmt(\"master\", id ?? \"procedure\", result);\n }\n\n // ---- Knowledge management ----\n\n /** Forget: remove any node under the individual by id. */\n async forget(nodeId: string): Promise<string> {\n const result = await this.api.ops[\"role.forget\"](nodeId);\n if (this.ctx.focusedGoalId === nodeId) this.ctx.focusedGoalId = null;\n if (this.ctx.focusedPlanId === nodeId) this.ctx.focusedPlanId = null;\n await this.save();\n return this.fmt(\"forget\", nodeId, result);\n }\n\n // ---- Skills + unified entry ----\n\n /** Skill: load full skill content by locator. */\n async skill(locator: string): Promise<string> {\n return await this.api.ops[\"role.skill\"](locator);\n }\n\n /** Use: subjective execution — `!ns.method` or ResourceX locator. */\n async use<T = unknown>(locator: string, args?: Record<string, unknown>): Promise<T> {\n const result = await this.api.direct<T>(locator, args);\n // Render issue results as readable text\n if (locator.startsWith(\"!issue.\")) {\n const action = locator.slice(\"!issue.\".length) as IssueAction;\n return (await renderIssueResult(action, result, this.api.resolveLabels)) as T;\n }\n // Render project results as readable text\n if (locator.startsWith(\"!project.\")) {\n const action = locator.slice(\"!project.\".length) as ProjectAction;\n const opResult = result as { state: import(\"@rolexjs/system\").State };\n return renderProjectResult(action, opResult.state) as T;\n }\n return result;\n }\n}\n","/**\n * Rolex — thin API shell.\n *\n * Public API:\n * genesis() — create the world on first run\n * activate(id) — returns a stateful Role handle\n * direct(loc, args) — direct the world to execute an instruction\n *\n * All operation implementations live in @rolexjs/prototype (createOps).\n * Rolex just wires Platform → ops and manages Role lifecycle.\n */\n\nimport type { Platform, PrototypeData, RoleXRepository } from \"@rolexjs/core\";\nimport * as C from \"@rolexjs/core\";\nimport { applyPrototype, createOps, directives, type Ops, toArgs } from \"@rolexjs/prototype\";\nimport type { Initializer, Runtime, Structure } from \"@rolexjs/system\";\nimport { createIssueX, type IssueX } from \"issuexjs\";\nimport type { ResourceX } from \"resourcexjs\";\nimport { createResourceX, setProvider } from \"resourcexjs\";\nimport { RoleContext } from \"./context.js\";\nimport { findInState } from \"./find.js\";\nimport { Role, type RolexInternal } from \"./role.js\";\n\n/** Summary entry returned by census.list. */\nexport interface CensusEntry {\n id?: string;\n name: string;\n tag?: string;\n}\n\nexport class Rolex {\n private rt: Runtime;\n private ops!: Ops;\n private resourcex?: ResourceX;\n private issuex?: IssueX;\n private repo: RoleXRepository;\n private readonly initializer?: Initializer;\n\n private readonly prototypes: readonly PrototypeData[];\n private society!: Structure;\n private past!: Structure;\n\n private constructor(platform: Platform) {\n this.repo = platform.repository;\n this.rt = this.repo.runtime;\n this.initializer = platform.initializer;\n this.prototypes = platform.prototypes ?? [];\n\n // Create ResourceX from injected provider\n if (platform.resourcexProvider) {\n setProvider(platform.resourcexProvider);\n this.resourcex = createResourceX(\n platform.resourcexExecutor\n ? { isolator: \"custom\", executor: platform.resourcexExecutor }\n : undefined\n );\n }\n\n // Create IssueX from injected provider\n if (platform.issuexProvider) {\n this.issuex = createIssueX({ provider: platform.issuexProvider });\n }\n }\n\n /** Create a Rolex instance from a Platform (async due to Runtime initialization). */\n static async create(platform: Platform): Promise<Rolex> {\n const rolex = new Rolex(platform);\n await rolex.init();\n return rolex;\n }\n\n /** Async initialization — called by Rolex.create(). */\n private async init(): Promise<void> {\n // Ensure world roots exist\n const roots = await this.rt.roots();\n this.society =\n roots.find((r) => r.name === \"society\") ?? (await this.rt.create(null, C.society));\n\n const societyState = await this.rt.project(this.society);\n const existingPast = societyState.children?.find((c) => c.name === \"past\");\n this.past = existingPast ?? (await this.rt.create(this.society, C.past));\n\n // Create ops from prototype — all operation implementations\n this.ops = createOps({\n rt: this.rt,\n society: this.society,\n past: this.past,\n resolve: async (id: string) => {\n const node = await this.find(id);\n if (!node) throw new Error(`\"${id}\" not found.`);\n return node;\n },\n find: (id: string) => this.find(id),\n resourcex: this.resourcex,\n issuex: this.issuex,\n prototype: this.repo.prototype,\n direct: (locator: string, args?: Record<string, unknown>) => this.direct(locator, args),\n });\n }\n\n /** Genesis — create the world on first run. Applies built-in prototypes. */\n async genesis(): Promise<void> {\n await this.initializer?.bootstrap();\n\n for (const proto of this.prototypes) {\n await applyPrototype(proto, this.repo.prototype, (op, args) => this.direct(op, args));\n }\n }\n\n /**\n * Activate a role — returns a stateful Role handle.\n *\n * If the individual does not exist in runtime but a prototype is registered,\n * auto-born the individual first.\n */\n async activate(individual: string): Promise<Role> {\n let node = await this.find(individual);\n if (!node) {\n const hasProto = Object.hasOwn(this.repo.prototype.list(), individual);\n if (hasProto) {\n await this.ops[\"individual.born\"](undefined, individual);\n node = (await this.find(individual))!;\n } else {\n throw new Error(`\"${individual}\" not found.`);\n }\n }\n const state = await this.rt.project(node);\n const ctx = new RoleContext(individual);\n ctx.rehydrate(state);\n\n // Restore persisted focus (only override rehydrate default when persisted value is valid)\n const persisted = await this.repo.loadContext(individual);\n if (persisted) {\n if (persisted.focusedGoalId && (await this.find(persisted.focusedGoalId))) {\n ctx.focusedGoalId = persisted.focusedGoalId;\n }\n if (persisted.focusedPlanId && (await this.find(persisted.focusedPlanId))) {\n ctx.focusedPlanId = persisted.focusedPlanId;\n }\n }\n\n // Build internal API for Role — ops + ctx persistence\n const ops = this.ops;\n const repo = this.repo;\n const saveCtx = async (c: RoleContext) => {\n await repo.saveContext(c.roleId, {\n focusedGoalId: c.focusedGoalId,\n focusedPlanId: c.focusedPlanId,\n });\n };\n\n const api: RolexInternal = {\n ops,\n saveCtx,\n direct: this.direct.bind(this),\n resolveLabels: this.issuex\n ? async (ids: string[]) => {\n const names: string[] = [];\n for (const id of ids) {\n const label = await this.issuex!.getLabel(id);\n if (label) names.push(label.name);\n }\n return names;\n }\n : undefined,\n };\n\n return new Role(individual, ctx, api);\n }\n\n /** Find a node by id or alias across the entire society tree. Internal use only. */\n private async find(id: string): Promise<Structure | null> {\n const state = await this.rt.project(this.society);\n return findInState(state, id);\n }\n\n /**\n * Direct the world to execute an instruction.\n *\n * - `!namespace.method` — dispatch to ops\n * - anything else — delegate to ResourceX `ingest`\n */\n async direct<T = unknown>(locator: string, args?: Record<string, unknown>): Promise<T> {\n if (locator.startsWith(\"!\")) {\n const command = locator.slice(1);\n const fn = this.ops[command];\n if (!fn) {\n const hint = directives[\"identity-ethics\"]?.[\"on-unknown-command\"] ?? \"\";\n throw new Error(\n `Unknown command \"${locator}\".\\n\\n` +\n \"You may be guessing the command name. \" +\n \"Load the relevant skill first with skill(locator) to learn the correct syntax.\\n\\n\" +\n hint\n );\n }\n return (await fn(...toArgs(command, args ?? {}))) as T;\n }\n if (!this.resourcex) throw new Error(\"ResourceX is not available.\");\n return this.resourcex.ingest<T>(locator, args);\n }\n}\n\n/** Create a Rolex instance from a Platform. */\nexport async function createRoleX(platform: Platform): Promise<Rolex> {\n return Rolex.create(platform);\n}\n"],"mappings":";AAaA,cAAc;;;ACAP,IAAM,cAAN,MAAkB;AAAA,EACvB;AAAA,EACA,gBAA+B;AAAA,EAC/B,gBAA+B;AAAA,EAEtB,eAAe,oBAAI,IAAY;AAAA,EAC/B,gBAAgB,oBAAI,IAAY;AAAA,EAEzC,YAAY,QAAg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ACA,QAAI,CAAC,KAAK,UAAW,OAAM,IAAI,MAAM,6BAA6B;AAClE,WAAO,KAAK,UAAU,OAAU,SAAS,IAAI;AAAA,EAC/C;AACF;AAGA,eAAsB,YAAY,UAAoC;AACpE,SAAO,MAAM,OAAO,QAAQ;AAC9B;","names":["c","tag","directives","hint","directives"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolexjs",
3
- "version": "1.3.1-dev-20260304123741",
3
+ "version": "2.0.0-dev-20260305000914",
4
4
  "description": "RoleX - AI Agent Role Management Framework",
5
5
  "keywords": [
6
6
  "rolex",
@@ -38,15 +38,15 @@
38
38
  "clean": "rm -rf dist"
39
39
  },
40
40
  "dependencies": {
41
- "@rolexjs/core": "1.3.1-dev-20260304123741",
42
- "@rolexjs/prototype": "1.3.1-dev-20260304123741",
43
- "@rolexjs/system": "1.3.1-dev-20260304123741",
44
- "@rolexjs/parser": "1.3.1-dev-20260304123741",
41
+ "@rolexjs/core": "2.0.0-dev-20260305000914",
42
+ "@rolexjs/prototype": "2.0.0-dev-20260305000914",
43
+ "@rolexjs/system": "2.0.0-dev-20260305000914",
44
+ "@rolexjs/parser": "2.0.0-dev-20260305000914",
45
45
  "issuexjs": "^0.2.0",
46
46
  "resourcexjs": "^2.14.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@rolexjs/local-platform": "1.3.1-dev-20260304123741"
49
+ "@rolexjs/local-platform": "2.0.0-dev-20260305000914"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"