@rolexjs/local-platform 0.12.0-dev-20260302114956 → 1.0.0-dev-20260303015041

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
@@ -89,8 +89,8 @@ declare class SqliteRepository implements RoleXRepository {
89
89
  readonly runtime: Runtime;
90
90
  readonly prototype: PrototypeRegistry;
91
91
  constructor(db: DB);
92
- saveContext(roleId: string, data: ContextData): void;
93
- loadContext(roleId: string): ContextData | null;
92
+ saveContext(roleId: string, data: ContextData): Promise<void>;
93
+ loadContext(roleId: string): Promise<ContextData | null>;
94
94
  }
95
95
 
96
96
  export { type FileEntry, type LocalPlatformConfig, type Manifest, type ManifestNode, SqliteRepository, filesToState, localPlatform, stateToFiles };
package/dist/index.js CHANGED
@@ -104,7 +104,7 @@ function removeSubtree(db, ref) {
104
104
  }
105
105
  function createSqliteRuntime(db) {
106
106
  return {
107
- create(parent, type, information, id, alias) {
107
+ async create(parent, type, information, id, alias) {
108
108
  if (id) {
109
109
  const existing = db.select().from(nodes).where(and(eq(nodes.id, id), eq(nodes.parentRef, parent?.ref ?? null))).get();
110
110
  if (existing) return toStructure(existing);
@@ -122,13 +122,13 @@ function createSqliteRuntime(db) {
122
122
  }).run();
123
123
  return toStructure(db.select().from(nodes).where(eq(nodes.ref, ref)).get());
124
124
  },
125
- remove(node) {
125
+ async remove(node) {
126
126
  if (!node.ref) return;
127
127
  const row = db.select().from(nodes).where(eq(nodes.ref, node.ref)).get();
128
128
  if (!row) return;
129
129
  removeSubtree(db, node.ref);
130
130
  },
131
- transform(source, target, information) {
131
+ async transform(source, target, information) {
132
132
  if (!source.ref) throw new Error("Source node has no ref");
133
133
  const row = db.select().from(nodes).where(eq(nodes.ref, source.ref)).get();
134
134
  if (!row) throw new Error(`Source node not found: ${source.ref}`);
@@ -148,7 +148,7 @@ function createSqliteRuntime(db) {
148
148
  }).where(eq(nodes.ref, source.ref)).run();
149
149
  return toStructure(db.select().from(nodes).where(eq(nodes.ref, source.ref)).get());
150
150
  },
151
- link(from, to, relationName, reverseName) {
151
+ async link(from, to, relationName, reverseName) {
152
152
  if (!from.ref) throw new Error("Source node has no ref");
153
153
  if (!to.ref) throw new Error("Target node has no ref");
154
154
  const existsForward = db.select().from(links).where(
@@ -168,7 +168,7 @@ function createSqliteRuntime(db) {
168
168
  db.insert(links).values({ fromRef: to.ref, toRef: from.ref, relation: reverseName }).run();
169
169
  }
170
170
  },
171
- unlink(from, to, relationName, reverseName) {
171
+ async unlink(from, to, relationName, reverseName) {
172
172
  if (!from.ref || !to.ref) return;
173
173
  db.delete(links).where(
174
174
  and(
@@ -181,17 +181,17 @@ function createSqliteRuntime(db) {
181
181
  and(eq(links.fromRef, to.ref), eq(links.toRef, from.ref), eq(links.relation, reverseName))
182
182
  ).run();
183
183
  },
184
- tag(node, tagValue) {
184
+ async tag(node, tagValue) {
185
185
  if (!node.ref) throw new Error("Node has no ref");
186
186
  const row = db.select().from(nodes).where(eq(nodes.ref, node.ref)).get();
187
187
  if (!row) throw new Error(`Node not found: ${node.ref}`);
188
188
  db.update(nodes).set({ tag: tagValue }).where(eq(nodes.ref, node.ref)).run();
189
189
  },
190
- project(node) {
190
+ async project(node) {
191
191
  if (!node.ref) throw new Error(`Node has no ref`);
192
192
  return projectNode(db, node.ref);
193
193
  },
194
- roots() {
194
+ async roots() {
195
195
  const rows = db.select().from(nodes).where(isNull(nodes.parentRef)).all();
196
196
  return rows.map(toStructure);
197
197
  }
@@ -243,13 +243,13 @@ var SqliteRepository = class {
243
243
  }
244
244
  runtime;
245
245
  prototype;
246
- saveContext(roleId, data) {
246
+ async saveContext(roleId, data) {
247
247
  this.db.run(
248
248
  sql`INSERT OR REPLACE INTO contexts (role_id, focused_goal_id, focused_plan_id)
249
249
  VALUES (${roleId}, ${data.focusedGoalId}, ${data.focusedPlanId})`
250
250
  );
251
251
  }
252
- loadContext(roleId) {
252
+ async loadContext(roleId) {
253
253
  const row = this.db.all(
254
254
  sql`SELECT role_id, focused_goal_id, focused_plan_id FROM contexts WHERE role_id = ${roleId}`
255
255
  );
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/LocalPlatform.ts","../src/SqliteRepository.ts","../src/sqliteRuntime.ts","../src/schema.ts","../src/manifest.ts"],"sourcesContent":["/**\n * localPlatform — create a Platform backed by SQLite + local filesystem.\n *\n * Storage:\n * {dataDir}/rolex.db — SQLite database (all state: nodes, links, prototypes, contexts)\n *\n * When dataDir is null, runs with in-memory SQLite (useful for tests).\n */\n\nimport { mkdirSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { drizzle } from \"@deepracticex/drizzle\";\nimport { openDatabase } from \"@deepracticex/sqlite\";\nimport { NodeProvider } from \"@resourcexjs/node-provider\";\nimport type { Platform } from \"@rolexjs/core\";\nimport type { Initializer } from \"@rolexjs/system\";\nimport { SqliteRepository } from \"./SqliteRepository.js\";\n\n// ===== Config =====\n\nexport interface LocalPlatformConfig {\n /** Directory for persistent storage. Defaults to ~/.deepractice/rolex. Set to null for in-memory only. */\n dataDir?: string | null;\n /** Directory for ResourceX storage. Defaults to ~/.deepractice/resourcex. Set to null to disable. */\n resourceDir?: string | null;\n /** Prototype sources to settle on genesis. */\n bootstrap?: string[];\n}\n\n// ===== Factory =====\n\n/** Resolve the DEEPRACTICE_HOME base directory. Env > default (~/.deepractice). */\nfunction deepracticeHome(): string {\n return process.env.DEEPRACTICE_HOME ?? join(homedir(), \".deepractice\");\n}\n\n/** Create a local Platform. Persistent by default ($DEEPRACTICE_HOME/rolex), in-memory if dataDir is null. */\nexport function localPlatform(config: LocalPlatformConfig = {}): Platform {\n const dataDir =\n config.dataDir === null ? undefined : (config.dataDir ?? join(deepracticeHome(), \"rolex\"));\n\n // ===== SQLite database =====\n\n let dbPath: string;\n if (dataDir) {\n mkdirSync(dataDir, { recursive: true });\n dbPath = join(dataDir, \"rolex.db\");\n } else {\n dbPath = \":memory:\";\n }\n\n const rawDb = openDatabase(dbPath);\n const db = drizzle(rawDb);\n\n // ===== Repository (all state in one place) =====\n\n const repository = new SqliteRepository(db);\n\n // ===== ResourceX Provider =====\n\n const resourcexProvider = config.resourceDir !== null ? new NodeProvider() : undefined;\n\n // ===== Initializer =====\n\n const initializer: Initializer = {\n async bootstrap() {},\n };\n\n return {\n repository,\n resourcexProvider,\n initializer,\n bootstrap: config.bootstrap,\n };\n}\n","/**\n * SqliteRepository — RoleXRepository backed by SQLite via Drizzle.\n *\n * Single database, four tables: nodes, links, prototypes, contexts.\n * All state in one place — swap the db connection to go from local to cloud.\n */\n\nimport type { CommonXDatabase } from \"@deepracticex/drizzle\";\nimport type { ContextData, PrototypeRegistry, RoleXRepository } from \"@rolexjs/core\";\nimport type { Runtime } from \"@rolexjs/system\";\nimport { sql } from \"drizzle-orm\";\nimport { createSqliteRuntime } from \"./sqliteRuntime.js\";\n\ntype DB = CommonXDatabase;\n\n// ===== DDL =====\n\nconst DDL = [\n sql`CREATE TABLE IF NOT EXISTS nodes (\n ref TEXT PRIMARY KEY,\n id TEXT,\n alias TEXT,\n name TEXT NOT NULL,\n description TEXT DEFAULT '',\n parent_ref TEXT REFERENCES nodes(ref),\n information TEXT,\n tag TEXT\n )`,\n sql`CREATE TABLE IF NOT EXISTS links (\n from_ref TEXT NOT NULL REFERENCES nodes(ref),\n to_ref TEXT NOT NULL REFERENCES nodes(ref),\n relation TEXT NOT NULL,\n PRIMARY KEY (from_ref, to_ref, relation)\n )`,\n sql`CREATE TABLE IF NOT EXISTS prototypes (\n id TEXT PRIMARY KEY,\n source TEXT NOT NULL\n )`,\n sql`CREATE TABLE IF NOT EXISTS contexts (\n role_id TEXT PRIMARY KEY,\n focused_goal_id TEXT,\n focused_plan_id TEXT\n )`,\n // Indexes\n sql`CREATE INDEX IF NOT EXISTS idx_nodes_id ON nodes(id)`,\n sql`CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name)`,\n sql`CREATE INDEX IF NOT EXISTS idx_nodes_parent_ref ON nodes(parent_ref)`,\n sql`CREATE INDEX IF NOT EXISTS idx_links_from ON links(from_ref)`,\n sql`CREATE INDEX IF NOT EXISTS idx_links_to ON links(to_ref)`,\n];\n\n// ===== Repository =====\n\nexport class SqliteRepository implements RoleXRepository {\n readonly runtime: Runtime;\n readonly prototype: PrototypeRegistry;\n\n constructor(private db: DB) {\n // Ensure all tables exist\n for (const stmt of DDL) {\n db.run(stmt);\n }\n\n this.runtime = createSqliteRuntime(db);\n this.prototype = createPrototypeRegistry(db);\n }\n\n saveContext(roleId: string, data: ContextData): void {\n this.db.run(\n sql`INSERT OR REPLACE INTO contexts (role_id, focused_goal_id, focused_plan_id)\n VALUES (${roleId}, ${data.focusedGoalId}, ${data.focusedPlanId})`\n );\n }\n\n loadContext(roleId: string): ContextData | null {\n const row = this.db.all<{\n role_id: string;\n focused_goal_id: string | null;\n focused_plan_id: string | null;\n }>(\n sql`SELECT role_id, focused_goal_id, focused_plan_id FROM contexts WHERE role_id = ${roleId}`\n );\n if (row.length === 0) return null;\n return {\n focusedGoalId: row[0].focused_goal_id,\n focusedPlanId: row[0].focused_plan_id,\n };\n }\n}\n\n// ===== Prototype Registry (SQLite-backed) =====\n\nfunction createPrototypeRegistry(db: DB): PrototypeRegistry {\n return {\n settle(id: string, source: string) {\n db.run(sql`INSERT OR REPLACE INTO prototypes (id, source) VALUES (${id}, ${source})`);\n },\n\n evict(id: string) {\n db.run(sql`DELETE FROM prototypes WHERE id = ${id}`);\n },\n\n list(): Record<string, string> {\n const rows = db.all<{ id: string; source: string }>(sql`SELECT id, source FROM prototypes`);\n const result: Record<string, string> = {};\n for (const row of rows) {\n result[row.id] = row.source;\n }\n return result;\n },\n };\n}\n","/**\n * SQLite-backed Runtime — single source of truth.\n *\n * Every operation reads/writes directly to SQLite.\n * No in-memory Map, no load/save cycle, no stale refs.\n */\n\nimport type { CommonXDatabase } from \"@deepracticex/drizzle\";\nimport type { Runtime, State, Structure } from \"@rolexjs/system\";\nimport { and, eq, isNull } from \"drizzle-orm\";\nimport { links, nodes } from \"./schema.js\";\n\ntype DB = CommonXDatabase;\n\n// ===== Helpers =====\n\nfunction nextRef(db: DB): string {\n const max = db\n .select({ ref: nodes.ref })\n .from(nodes)\n .all()\n .reduce((max, r) => {\n const n = parseInt(r.ref.slice(1), 10);\n return Number.isNaN(n) ? max : Math.max(max, n);\n }, 0);\n return `n${max + 1}`;\n}\n\nfunction toStructure(row: typeof nodes.$inferSelect): Structure {\n return {\n ref: row.ref,\n ...(row.id ? { id: row.id } : {}),\n ...(row.alias ? { alias: JSON.parse(row.alias) } : {}),\n name: row.name,\n description: row.description ?? \"\",\n parent: null, // Runtime doesn't use parent as Structure; tree is via parentRef\n ...(row.information ? { information: row.information } : {}),\n ...(row.tag ? { tag: row.tag } : {}),\n };\n}\n\n// ===== Projection =====\n\nfunction projectNode(db: DB, ref: string): State {\n const row = db.select().from(nodes).where(eq(nodes.ref, ref)).get();\n if (!row) throw new Error(`Node not found: ${ref}`);\n\n const children = db.select().from(nodes).where(eq(nodes.parentRef, ref)).all();\n\n const nodeLinks = db.select().from(links).where(eq(links.fromRef, ref)).all();\n\n return {\n ...toStructure(row),\n children: children.map((c) => projectNode(db, c.ref)),\n ...(nodeLinks.length > 0\n ? {\n links: nodeLinks.map((l) => ({\n relation: l.relation,\n target: projectLinked(db, l.toRef),\n })),\n }\n : {}),\n };\n}\n\n/** Project a node with full subtree but without following links (prevents cycles). */\nfunction projectLinked(db: DB, ref: string): State {\n const row = db.select().from(nodes).where(eq(nodes.ref, ref)).get();\n if (!row) throw new Error(`Node not found: ${ref}`);\n const children = db.select().from(nodes).where(eq(nodes.parentRef, ref)).all();\n return {\n ...toStructure(row),\n children: children.map((c) => projectLinked(db, c.ref)),\n };\n}\n\n// ===== Subtree removal =====\n\nfunction removeSubtree(db: DB, ref: string): void {\n // Remove children first (depth-first)\n const children = db.select({ ref: nodes.ref }).from(nodes).where(eq(nodes.parentRef, ref)).all();\n for (const child of children) {\n removeSubtree(db, child.ref);\n }\n\n // Remove links from/to this node\n db.delete(links).where(eq(links.fromRef, ref)).run();\n db.delete(links).where(eq(links.toRef, ref)).run();\n\n // Remove the node itself\n db.delete(nodes).where(eq(nodes.ref, ref)).run();\n}\n\n// ===== Runtime factory =====\n\nexport function createSqliteRuntime(db: DB): Runtime {\n return {\n create(parent, type, information, id, alias) {\n // Idempotent: same id under same parent → return existing.\n if (id) {\n const existing = db\n .select()\n .from(nodes)\n .where(and(eq(nodes.id, id), eq(nodes.parentRef, parent?.ref ?? null)))\n .get();\n if (existing) return toStructure(existing);\n }\n const ref = nextRef(db);\n db.insert(nodes)\n .values({\n ref,\n id: id ?? null,\n alias: alias && alias.length > 0 ? JSON.stringify(alias) : null,\n name: type.name,\n description: type.description,\n parentRef: parent?.ref ?? null,\n information: information ?? null,\n tag: null,\n })\n .run();\n return toStructure(db.select().from(nodes).where(eq(nodes.ref, ref)).get()!);\n },\n\n remove(node) {\n if (!node.ref) return;\n const row = db.select().from(nodes).where(eq(nodes.ref, node.ref)).get();\n if (!row) return;\n\n // Detach from parent's children (implicit via parentRef)\n removeSubtree(db, node.ref);\n },\n\n transform(source, target, information) {\n if (!source.ref) throw new Error(\"Source node has no ref\");\n const row = db.select().from(nodes).where(eq(nodes.ref, source.ref)).get();\n if (!row) throw new Error(`Source node not found: ${source.ref}`);\n\n const targetParent = target.parent;\n if (!targetParent) {\n throw new Error(`Cannot transform to root structure: ${target.name}`);\n }\n\n const parentRow = db.select().from(nodes).where(eq(nodes.name, targetParent.name)).get();\n if (!parentRow) {\n throw new Error(`No node found for structure: ${targetParent.name}`);\n }\n\n // Reparent + update type in place — subtree preserved\n db.update(nodes)\n .set({\n parentRef: parentRow.ref,\n name: target.name,\n description: target.description,\n ...(information !== undefined ? { information } : {}),\n })\n .where(eq(nodes.ref, source.ref))\n .run();\n\n return toStructure(db.select().from(nodes).where(eq(nodes.ref, source.ref)).get()!);\n },\n\n link(from, to, relationName, reverseName) {\n if (!from.ref) throw new Error(\"Source node has no ref\");\n if (!to.ref) throw new Error(\"Target node has no ref\");\n\n // Forward: from → to\n const existsForward = db\n .select()\n .from(links)\n .where(\n and(\n eq(links.fromRef, from.ref),\n eq(links.toRef, to.ref),\n eq(links.relation, relationName)\n )\n )\n .get();\n if (!existsForward) {\n db.insert(links).values({ fromRef: from.ref, toRef: to.ref, relation: relationName }).run();\n }\n\n // Reverse: to → from\n const existsReverse = db\n .select()\n .from(links)\n .where(\n and(eq(links.fromRef, to.ref), eq(links.toRef, from.ref), eq(links.relation, reverseName))\n )\n .get();\n if (!existsReverse) {\n db.insert(links).values({ fromRef: to.ref, toRef: from.ref, relation: reverseName }).run();\n }\n },\n\n unlink(from, to, relationName, reverseName) {\n if (!from.ref || !to.ref) return;\n\n db.delete(links)\n .where(\n and(\n eq(links.fromRef, from.ref),\n eq(links.toRef, to.ref),\n eq(links.relation, relationName)\n )\n )\n .run();\n\n db.delete(links)\n .where(\n and(eq(links.fromRef, to.ref), eq(links.toRef, from.ref), eq(links.relation, reverseName))\n )\n .run();\n },\n\n tag(node, tagValue) {\n if (!node.ref) throw new Error(\"Node has no ref\");\n const row = db.select().from(nodes).where(eq(nodes.ref, node.ref)).get();\n if (!row) throw new Error(`Node not found: ${node.ref}`);\n db.update(nodes).set({ tag: tagValue }).where(eq(nodes.ref, node.ref)).run();\n },\n\n project(node) {\n if (!node.ref) throw new Error(`Node has no ref`);\n return projectNode(db, node.ref);\n },\n\n roots() {\n const rows = db.select().from(nodes).where(isNull(nodes.parentRef)).all();\n return rows.map(toStructure);\n },\n };\n}\n","/**\n * Drizzle schema — SQLite tables for the RoleX runtime graph.\n *\n * Two tables:\n * nodes — tree backbone (Structure instances)\n * links — cross-branch relations (bidirectional)\n */\n\nimport { index, primaryKey, sqliteTable, text } from \"drizzle-orm/sqlite-core\";\n\n/**\n * nodes — every node in the society graph.\n *\n * Maps 1:1 to the Structure interface:\n * ref → graph-internal reference (primary key)\n * id → user-facing kebab-case identifier\n * alias → JSON array of alternative names\n * name → structure type (\"individual\", \"goal\", \"task\", etc.)\n * description → what this structure is\n * parent_ref → tree parent (self-referencing foreign key)\n * information → Gherkin Feature source text\n * tag → generic label (\"done\", \"abandoned\")\n */\nexport const nodes = sqliteTable(\n \"nodes\",\n {\n ref: text(\"ref\").primaryKey(),\n id: text(\"id\"),\n alias: text(\"alias\"), // JSON array: '[\"Sean\",\"姜山\"]'\n name: text(\"name\").notNull(),\n description: text(\"description\").default(\"\"),\n parentRef: text(\"parent_ref\").references((): any => nodes.ref),\n information: text(\"information\"),\n tag: text(\"tag\"),\n },\n (table) => [\n index(\"idx_nodes_id\").on(table.id),\n index(\"idx_nodes_name\").on(table.name),\n index(\"idx_nodes_parent_ref\").on(table.parentRef),\n ]\n);\n\n/**\n * links — cross-branch relations between nodes.\n *\n * Bidirectional: if A→B is \"membership\", B→A is \"belong\".\n * Both directions stored as separate rows.\n */\nexport const links = sqliteTable(\n \"links\",\n {\n fromRef: text(\"from_ref\")\n .notNull()\n .references(() => nodes.ref),\n toRef: text(\"to_ref\")\n .notNull()\n .references(() => nodes.ref),\n relation: text(\"relation\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.fromRef, table.toRef, table.relation] }),\n index(\"idx_links_from\").on(table.fromRef),\n index(\"idx_links_to\").on(table.toRef),\n ]\n);\n","/**\n * Manifest — file-based storage format for RoleX entities.\n *\n * Storage layout:\n * role/<id>/\n * individual.json — manifest (tree structure + links)\n * <id>.<type>.feature — node information (Gherkin)\n *\n * organization/<id>/\n * organization.json — manifest (tree structure + links)\n * <id>.<type>.feature — node information (Gherkin)\n *\n * Rules:\n * - Directories: only role/ and organization/ at top level\n * - Files: all [id].[type].feature, flat within the entity directory\n * - Manifest: tree structure in JSON, content in .feature files\n * - Nodes without explicit id default to their type name\n */\n\nimport type { State } from \"@rolexjs/system\";\n\n// ===== Manifest types =====\n\n/** A node in the manifest tree. */\nexport interface ManifestNode {\n readonly type: string;\n readonly ref?: string;\n readonly tag?: string;\n readonly children?: Record<string, ManifestNode>;\n readonly links?: Record<string, string[]>;\n}\n\n/** Root manifest for an entity (individual or organization). */\nexport interface Manifest {\n readonly id: string;\n readonly type: string;\n readonly ref?: string;\n readonly alias?: readonly string[];\n readonly children?: Record<string, ManifestNode>;\n readonly links?: Record<string, string[]>;\n}\n\n// ===== State → files =====\n\nexport interface FileEntry {\n readonly path: string;\n readonly content: string;\n}\n\n/**\n * Convert a State tree to a manifest + feature files.\n * Returns the manifest and a list of file entries (path → content).\n */\nexport function stateToFiles(state: State): { manifest: Manifest; files: FileEntry[] } {\n const files: FileEntry[] = [];\n\n const collectFiles = (node: State, nodeId: string) => {\n if (node.information) {\n files.push({\n path: `${nodeId}.${node.name}.feature`,\n content: node.information,\n });\n }\n if (node.children) {\n for (const child of node.children) {\n const childId = child.id ?? child.name;\n collectFiles(child, childId);\n }\n }\n };\n\n const rootId = state.id ?? state.name;\n collectFiles(state, rootId);\n\n const buildManifestNode = (node: State): ManifestNode => {\n const entry: ManifestNode = {\n type: node.name,\n ...(node.ref ? { ref: node.ref } : {}),\n ...(node.tag ? { tag: node.tag } : {}),\n ...(node.links && node.links.length > 0 ? { links: buildManifestLinks(node.links) } : {}),\n };\n if (node.children && node.children.length > 0) {\n const children: Record<string, ManifestNode> = {};\n for (const child of node.children) {\n const childId = child.id ?? child.name;\n children[childId] = buildManifestNode(child);\n }\n return { ...entry, children };\n }\n return entry;\n };\n\n const manifestNode = buildManifestNode(state);\n\n const manifest: Manifest = {\n id: rootId,\n type: state.name,\n ...(state.ref ? { ref: state.ref } : {}),\n ...(state.alias ? { alias: state.alias } : {}),\n ...(manifestNode.children ? { children: manifestNode.children } : {}),\n ...(state.links && state.links.length > 0\n ? {\n links: buildManifestLinks(state.links),\n }\n : {}),\n };\n\n return { manifest, files };\n}\n\nfunction buildManifestLinks(\n links: readonly { readonly relation: string; readonly target: State }[]\n): Record<string, string[]> {\n const result: Record<string, string[]> = {};\n for (const link of links) {\n const targetId = link.target.id ?? link.target.name;\n if (!result[link.relation]) {\n result[link.relation] = [];\n }\n result[link.relation].push(targetId);\n }\n return result;\n}\n\n// ===== Files → State =====\n\n/**\n * Convert a manifest + feature file contents to a State tree.\n * fileContents maps filename (e.g. \"role-creation.principle.feature\") to Gherkin text.\n */\nexport function filesToState(manifest: Manifest, fileContents: Record<string, string>): State {\n const buildState = (id: string, node: ManifestNode): State => {\n const filename = `${id}.${node.type}.feature`;\n const information = fileContents[filename];\n\n const children: State[] = [];\n if (node.children) {\n for (const [childId, childNode] of Object.entries(node.children)) {\n children.push(buildState(childId, childNode));\n }\n }\n\n const nodeLinks: { relation: string; target: State }[] = [];\n if (node.links) {\n for (const [relation, targetIds] of Object.entries(node.links)) {\n for (const targetId of targetIds) {\n nodeLinks.push({\n relation,\n target: { id: targetId, name: \"\", description: \"\", parent: null },\n });\n }\n }\n }\n\n return {\n ...(node.ref ? { ref: node.ref } : {}),\n id,\n name: node.type,\n description: \"\",\n parent: null,\n ...(node.tag ? { tag: node.tag } : {}),\n ...(information ? { information } : {}),\n ...(children.length > 0 ? { children } : {}),\n ...(nodeLinks.length > 0 ? { links: nodeLinks } : {}),\n };\n };\n\n const rootFilename = `${manifest.id}.${manifest.type}.feature`;\n const rootInformation = fileContents[rootFilename];\n\n const children: State[] = [];\n if (manifest.children) {\n for (const [childId, childNode] of Object.entries(manifest.children)) {\n children.push(buildState(childId, childNode));\n }\n }\n\n const links: { relation: string; target: State }[] = [];\n if (manifest.links) {\n for (const [relation, targetIds] of Object.entries(manifest.links)) {\n for (const targetId of targetIds) {\n links.push({\n relation,\n target: {\n id: targetId,\n name: \"\",\n description: \"\",\n parent: null,\n },\n });\n }\n }\n }\n\n return {\n ...(manifest.ref ? { ref: manifest.ref } : {}),\n id: manifest.id,\n ...(manifest.alias ? { alias: manifest.alias } : {}),\n name: manifest.type,\n description: \"\",\n parent: null,\n ...(rootInformation ? { information: rootInformation } : {}),\n ...(children.length > 0 ? { children } : {}),\n ...(links.length > 0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ntime.ts","../src/schema.ts","../src/manifest.ts"],"sourcesContent":["/**\n * localPlatform — create a Platform backed by SQLite + local filesystem.\n *\n * Storage:\n * {dataDir}/rolex.db — SQLite database (all state: nodes, links, prototypes, contexts)\n *\n * When dataDir is null, runs with in-memory SQLite (useful for tests).\n */\n\nimport { mkdirSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { drizzle } from \"@deepracticex/drizzle\";\nimport { openDatabase } from \"@deepracticex/sqlite\";\nimport { NodeProvider } from \"@resourcexjs/node-provider\";\nimport type { Platform } from \"@rolexjs/core\";\nimport type { Initializer } from \"@rolexjs/system\";\nimport { SqliteRepository } from \"./SqliteRepository.js\";\n\n// ===== Config =====\n\nexport interface LocalPlatformConfig {\n /** Directory for persistent storage. Defaults to ~/.deepractice/rolex. Set to null for in-memory only. */\n dataDir?: string | null;\n /** Directory for ResourceX storage. Defaults to ~/.deepractice/resourcex. Set to null to disable. */\n resourceDir?: string | null;\n /** Prototype sources to settle on genesis. */\n bootstrap?: string[];\n}\n\n// ===== Factory =====\n\n/** Resolve the DEEPRACTICE_HOME base directory. Env > default (~/.deepractice). */\nfunction deepracticeHome(): string {\n return process.env.DEEPRACTICE_HOME ?? join(homedir(), \".deepractice\");\n}\n\n/** Create a local Platform. Persistent by default ($DEEPRACTICE_HOME/rolex), in-memory if dataDir is null. */\nexport function localPlatform(config: LocalPlatformConfig = {}): Platform {\n const dataDir =\n config.dataDir === null ? undefined : (config.dataDir ?? join(deepracticeHome(), \"rolex\"));\n\n // ===== SQLite database =====\n\n let dbPath: string;\n if (dataDir) {\n mkdirSync(dataDir, { recursive: true });\n dbPath = join(dataDir, \"rolex.db\");\n } else {\n dbPath = \":memory:\";\n }\n\n const rawDb = openDatabase(dbPath);\n const db = drizzle(rawDb);\n\n // ===== Repository (all state in one place) =====\n\n const repository = new SqliteRepository(db);\n\n // ===== ResourceX Provider =====\n\n const resourcexProvider = config.resourceDir !== null ? new NodeProvider() : undefined;\n\n // ===== Initializer =====\n\n const initializer: Initializer = {\n async bootstrap() {},\n };\n\n return {\n repository,\n resourcexProvider,\n initializer,\n bootstrap: config.bootstrap,\n };\n}\n","/**\n * SqliteRepository — RoleXRepository backed by SQLite via Drizzle.\n *\n * Single database, four tables: nodes, links, prototypes, contexts.\n * All state in one place — swap the db connection to go from local to cloud.\n */\n\nimport type { CommonXDatabase } from \"@deepracticex/drizzle\";\nimport type { ContextData, PrototypeRegistry, RoleXRepository } from \"@rolexjs/core\";\nimport type { Runtime } from \"@rolexjs/system\";\nimport { sql } from \"drizzle-orm\";\nimport { createSqliteRuntime } from \"./sqliteRuntime.js\";\n\ntype DB = CommonXDatabase;\n\n// ===== DDL =====\n\nconst DDL = [\n sql`CREATE TABLE IF NOT EXISTS nodes (\n ref TEXT PRIMARY KEY,\n id TEXT,\n alias TEXT,\n name TEXT NOT NULL,\n description TEXT DEFAULT '',\n parent_ref TEXT REFERENCES nodes(ref),\n information TEXT,\n tag TEXT\n )`,\n sql`CREATE TABLE IF NOT EXISTS links (\n from_ref TEXT NOT NULL REFERENCES nodes(ref),\n to_ref TEXT NOT NULL REFERENCES nodes(ref),\n relation TEXT NOT NULL,\n PRIMARY KEY (from_ref, to_ref, relation)\n )`,\n sql`CREATE TABLE IF NOT EXISTS prototypes (\n id TEXT PRIMARY KEY,\n source TEXT NOT NULL\n )`,\n sql`CREATE TABLE IF NOT EXISTS contexts (\n role_id TEXT PRIMARY KEY,\n focused_goal_id TEXT,\n focused_plan_id TEXT\n )`,\n // Indexes\n sql`CREATE INDEX IF NOT EXISTS idx_nodes_id ON nodes(id)`,\n sql`CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name)`,\n sql`CREATE INDEX IF NOT EXISTS idx_nodes_parent_ref ON nodes(parent_ref)`,\n sql`CREATE INDEX IF NOT EXISTS idx_links_from ON links(from_ref)`,\n sql`CREATE INDEX IF NOT EXISTS idx_links_to ON links(to_ref)`,\n];\n\n// ===== Repository =====\n\nexport class SqliteRepository implements RoleXRepository {\n readonly runtime: Runtime;\n readonly prototype: PrototypeRegistry;\n\n constructor(private db: DB) {\n // Ensure all tables exist\n for (const stmt of DDL) {\n db.run(stmt);\n }\n\n this.runtime = createSqliteRuntime(db);\n this.prototype = createPrototypeRegistry(db);\n }\n\n async saveContext(roleId: string, data: ContextData): Promise<void> {\n this.db.run(\n sql`INSERT OR REPLACE INTO contexts (role_id, focused_goal_id, focused_plan_id)\n VALUES (${roleId}, ${data.focusedGoalId}, ${data.focusedPlanId})`\n );\n }\n\n async loadContext(roleId: string): Promise<ContextData | null> {\n const row = this.db.all<{\n role_id: string;\n focused_goal_id: string | null;\n focused_plan_id: string | null;\n }>(\n sql`SELECT role_id, focused_goal_id, focused_plan_id FROM contexts WHERE role_id = ${roleId}`\n );\n if (row.length === 0) return null;\n return {\n focusedGoalId: row[0].focused_goal_id,\n focusedPlanId: row[0].focused_plan_id,\n };\n }\n}\n\n// ===== Prototype Registry (SQLite-backed) =====\n\nfunction createPrototypeRegistry(db: DB): PrototypeRegistry {\n return {\n settle(id: string, source: string) {\n db.run(sql`INSERT OR REPLACE INTO prototypes (id, source) VALUES (${id}, ${source})`);\n },\n\n evict(id: string) {\n db.run(sql`DELETE FROM prototypes WHERE id = ${id}`);\n },\n\n list(): Record<string, string> {\n const rows = db.all<{ id: string; source: string }>(sql`SELECT id, source FROM prototypes`);\n const result: Record<string, string> = {};\n for (const row of rows) {\n result[row.id] = row.source;\n }\n return result;\n },\n };\n}\n","/**\n * SQLite-backed Runtime — single source of truth.\n *\n * Every operation reads/writes directly to SQLite.\n * No in-memory Map, no load/save cycle, no stale refs.\n */\n\nimport type { CommonXDatabase } from \"@deepracticex/drizzle\";\nimport type { Runtime, State, Structure } from \"@rolexjs/system\";\nimport { and, eq, isNull } from \"drizzle-orm\";\nimport { links, nodes } from \"./schema.js\";\n\ntype DB = CommonXDatabase;\n\n// ===== Helpers =====\n\nfunction nextRef(db: DB): string {\n const max = db\n .select({ ref: nodes.ref })\n .from(nodes)\n .all()\n .reduce((max, r) => {\n const n = parseInt(r.ref.slice(1), 10);\n return Number.isNaN(n) ? max : Math.max(max, n);\n }, 0);\n return `n${max + 1}`;\n}\n\nfunction toStructure(row: typeof nodes.$inferSelect): Structure {\n return {\n ref: row.ref,\n ...(row.id ? { id: row.id } : {}),\n ...(row.alias ? { alias: JSON.parse(row.alias) } : {}),\n name: row.name,\n description: row.description ?? \"\",\n parent: null, // Runtime doesn't use parent as Structure; tree is via parentRef\n ...(row.information ? { information: row.information } : {}),\n ...(row.tag ? { tag: row.tag } : {}),\n };\n}\n\n// ===== Projection =====\n\nfunction projectNode(db: DB, ref: string): State {\n const row = db.select().from(nodes).where(eq(nodes.ref, ref)).get();\n if (!row) throw new Error(`Node not found: ${ref}`);\n\n const children = db.select().from(nodes).where(eq(nodes.parentRef, ref)).all();\n\n const nodeLinks = db.select().from(links).where(eq(links.fromRef, ref)).all();\n\n return {\n ...toStructure(row),\n children: children.map((c) => projectNode(db, c.ref)),\n ...(nodeLinks.length > 0\n ? {\n links: nodeLinks.map((l) => ({\n relation: l.relation,\n target: projectLinked(db, l.toRef),\n })),\n }\n : {}),\n };\n}\n\n/** Project a node with full subtree but without following links (prevents cycles). */\nfunction projectLinked(db: DB, ref: string): State {\n const row = db.select().from(nodes).where(eq(nodes.ref, ref)).get();\n if (!row) throw new Error(`Node not found: ${ref}`);\n const children = db.select().from(nodes).where(eq(nodes.parentRef, ref)).all();\n return {\n ...toStructure(row),\n children: children.map((c) => projectLinked(db, c.ref)),\n };\n}\n\n// ===== Subtree removal =====\n\nfunction removeSubtree(db: DB, ref: string): void {\n // Remove children first (depth-first)\n const children = db.select({ ref: nodes.ref }).from(nodes).where(eq(nodes.parentRef, ref)).all();\n for (const child of children) {\n removeSubtree(db, child.ref);\n }\n\n // Remove links from/to this node\n db.delete(links).where(eq(links.fromRef, ref)).run();\n db.delete(links).where(eq(links.toRef, ref)).run();\n\n // Remove the node itself\n db.delete(nodes).where(eq(nodes.ref, ref)).run();\n}\n\n// ===== Runtime factory =====\n\nexport function createSqliteRuntime(db: DB): Runtime {\n return {\n async create(parent, type, information, id, alias) {\n // Idempotent: same id under same parent → return existing.\n if (id) {\n const existing = db\n .select()\n .from(nodes)\n .where(and(eq(nodes.id, id), eq(nodes.parentRef, parent?.ref ?? null)))\n .get();\n if (existing) return toStructure(existing);\n }\n const ref = nextRef(db);\n db.insert(nodes)\n .values({\n ref,\n id: id ?? null,\n alias: alias && alias.length > 0 ? JSON.stringify(alias) : null,\n name: type.name,\n description: type.description,\n parentRef: parent?.ref ?? null,\n information: information ?? null,\n tag: null,\n })\n .run();\n return toStructure(db.select().from(nodes).where(eq(nodes.ref, ref)).get()!);\n },\n\n async remove(node) {\n if (!node.ref) return;\n const row = db.select().from(nodes).where(eq(nodes.ref, node.ref)).get();\n if (!row) return;\n\n // Detach from parent's children (implicit via parentRef)\n removeSubtree(db, node.ref);\n },\n\n async transform(source, target, information) {\n if (!source.ref) throw new Error(\"Source node has no ref\");\n const row = db.select().from(nodes).where(eq(nodes.ref, source.ref)).get();\n if (!row) throw new Error(`Source node not found: ${source.ref}`);\n\n const targetParent = target.parent;\n if (!targetParent) {\n throw new Error(`Cannot transform to root structure: ${target.name}`);\n }\n\n const parentRow = db.select().from(nodes).where(eq(nodes.name, targetParent.name)).get();\n if (!parentRow) {\n throw new Error(`No node found for structure: ${targetParent.name}`);\n }\n\n // Reparent + update type in place — subtree preserved\n db.update(nodes)\n .set({\n parentRef: parentRow.ref,\n name: target.name,\n description: target.description,\n ...(information !== undefined ? { information } : {}),\n })\n .where(eq(nodes.ref, source.ref))\n .run();\n\n return toStructure(db.select().from(nodes).where(eq(nodes.ref, source.ref)).get()!);\n },\n\n async link(from, to, relationName, reverseName) {\n if (!from.ref) throw new Error(\"Source node has no ref\");\n if (!to.ref) throw new Error(\"Target node has no ref\");\n\n // Forward: from → to\n const existsForward = db\n .select()\n .from(links)\n .where(\n and(\n eq(links.fromRef, from.ref),\n eq(links.toRef, to.ref),\n eq(links.relation, relationName)\n )\n )\n .get();\n if (!existsForward) {\n db.insert(links).values({ fromRef: from.ref, toRef: to.ref, relation: relationName }).run();\n }\n\n // Reverse: to → from\n const existsReverse = db\n .select()\n .from(links)\n .where(\n and(eq(links.fromRef, to.ref), eq(links.toRef, from.ref), eq(links.relation, reverseName))\n )\n .get();\n if (!existsReverse) {\n db.insert(links).values({ fromRef: to.ref, toRef: from.ref, relation: reverseName }).run();\n }\n },\n\n async unlink(from, to, relationName, reverseName) {\n if (!from.ref || !to.ref) return;\n\n db.delete(links)\n .where(\n and(\n eq(links.fromRef, from.ref),\n eq(links.toRef, to.ref),\n eq(links.relation, relationName)\n )\n )\n .run();\n\n db.delete(links)\n .where(\n and(eq(links.fromRef, to.ref), eq(links.toRef, from.ref), eq(links.relation, reverseName))\n )\n .run();\n },\n\n async tag(node, tagValue) {\n if (!node.ref) throw new Error(\"Node has no ref\");\n const row = db.select().from(nodes).where(eq(nodes.ref, node.ref)).get();\n if (!row) throw new Error(`Node not found: ${node.ref}`);\n db.update(nodes).set({ tag: tagValue }).where(eq(nodes.ref, node.ref)).run();\n },\n\n async project(node) {\n if (!node.ref) throw new Error(`Node has no ref`);\n return projectNode(db, node.ref);\n },\n\n async roots() {\n const rows = db.select().from(nodes).where(isNull(nodes.parentRef)).all();\n return rows.map(toStructure);\n },\n };\n}\n","/**\n * Drizzle schema — SQLite tables for the RoleX runtime graph.\n *\n * Two tables:\n * nodes — tree backbone (Structure instances)\n * links — cross-branch relations (bidirectional)\n */\n\nimport { index, primaryKey, sqliteTable, text } from \"drizzle-orm/sqlite-core\";\n\n/**\n * nodes — every node in the society graph.\n *\n * Maps 1:1 to the Structure interface:\n * ref → graph-internal reference (primary key)\n * id → user-facing kebab-case identifier\n * alias → JSON array of alternative names\n * name → structure type (\"individual\", \"goal\", \"task\", etc.)\n * description → what this structure is\n * parent_ref → tree parent (self-referencing foreign key)\n * information → Gherkin Feature source text\n * tag → generic label (\"done\", \"abandoned\")\n */\nexport const nodes = sqliteTable(\n \"nodes\",\n {\n ref: text(\"ref\").primaryKey(),\n id: text(\"id\"),\n alias: text(\"alias\"), // JSON array: '[\"Sean\",\"姜山\"]'\n name: text(\"name\").notNull(),\n description: text(\"description\").default(\"\"),\n parentRef: text(\"parent_ref\").references((): any => nodes.ref),\n information: text(\"information\"),\n tag: text(\"tag\"),\n },\n (table) => [\n index(\"idx_nodes_id\").on(table.id),\n index(\"idx_nodes_name\").on(table.name),\n index(\"idx_nodes_parent_ref\").on(table.parentRef),\n ]\n);\n\n/**\n * links — cross-branch relations between nodes.\n *\n * Bidirectional: if A→B is \"membership\", B→A is \"belong\".\n * Both directions stored as separate rows.\n */\nexport const links = sqliteTable(\n \"links\",\n {\n fromRef: text(\"from_ref\")\n .notNull()\n .references(() => nodes.ref),\n toRef: text(\"to_ref\")\n .notNull()\n .references(() => nodes.ref),\n relation: text(\"relation\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.fromRef, table.toRef, table.relation] }),\n index(\"idx_links_from\").on(table.fromRef),\n index(\"idx_links_to\").on(table.toRef),\n ]\n);\n","/**\n * Manifest — file-based storage format for RoleX entities.\n *\n * Storage layout:\n * role/<id>/\n * individual.json — manifest (tree structure + links)\n * <id>.<type>.feature — node information (Gherkin)\n *\n * organization/<id>/\n * organization.json — manifest (tree structure + links)\n * <id>.<type>.feature — node information (Gherkin)\n *\n * Rules:\n * - Directories: only role/ and organization/ at top level\n * - Files: all [id].[type].feature, flat within the entity directory\n * - Manifest: tree structure in JSON, content in .feature files\n * - Nodes without explicit id default to their type name\n */\n\nimport type { State } from \"@rolexjs/system\";\n\n// ===== Manifest types =====\n\n/** A node in the manifest tree. */\nexport interface ManifestNode {\n readonly type: string;\n readonly ref?: string;\n readonly tag?: string;\n readonly children?: Record<string, ManifestNode>;\n readonly links?: Record<string, string[]>;\n}\n\n/** Root manifest for an entity (individual or organization). */\nexport interface Manifest {\n readonly id: string;\n readonly type: string;\n readonly ref?: string;\n readonly alias?: readonly string[];\n readonly children?: Record<string, ManifestNode>;\n readonly links?: Record<string, string[]>;\n}\n\n// ===== State → files =====\n\nexport interface FileEntry {\n readonly path: string;\n readonly content: string;\n}\n\n/**\n * Convert a State tree to a manifest + feature files.\n * Returns the manifest and a list of file entries (path → content).\n */\nexport function stateToFiles(state: State): { manifest: Manifest; files: FileEntry[] } {\n const files: FileEntry[] = [];\n\n const collectFiles = (node: State, nodeId: string) => {\n if (node.information) {\n files.push({\n path: `${nodeId}.${node.name}.feature`,\n content: node.information,\n });\n }\n if (node.children) {\n for (const child of node.children) {\n const childId = child.id ?? child.name;\n collectFiles(child, childId);\n }\n }\n };\n\n const rootId = state.id ?? state.name;\n collectFiles(state, rootId);\n\n const buildManifestNode = (node: State): ManifestNode => {\n const entry: ManifestNode = {\n type: node.name,\n ...(node.ref ? { ref: node.ref } : {}),\n ...(node.tag ? { tag: node.tag } : {}),\n ...(node.links && node.links.length > 0 ? { links: buildManifestLinks(node.links) } : {}),\n };\n if (node.children && node.children.length > 0) {\n const children: Record<string, ManifestNode> = {};\n for (const child of node.children) {\n const childId = child.id ?? child.name;\n children[childId] = buildManifestNode(child);\n }\n return { ...entry, children };\n }\n return entry;\n };\n\n const manifestNode = buildManifestNode(state);\n\n const manifest: Manifest = {\n id: rootId,\n type: state.name,\n ...(state.ref ? { ref: state.ref } : {}),\n ...(state.alias ? { alias: state.alias } : {}),\n ...(manifestNode.children ? { children: manifestNode.children } : {}),\n ...(state.links && state.links.length > 0\n ? {\n links: buildManifestLinks(state.links),\n }\n : {}),\n };\n\n return { manifest, files };\n}\n\nfunction buildManifestLinks(\n links: readonly { readonly relation: string; readonly target: State }[]\n): Record<string, string[]> {\n const result: Record<string, string[]> = {};\n for (const link of links) {\n const targetId = link.target.id ?? link.target.name;\n if (!result[link.relation]) {\n result[link.relation] = [];\n }\n result[link.relation].push(targetId);\n }\n return result;\n}\n\n// ===== Files → State =====\n\n/**\n * Convert a manifest + feature file contents to a State tree.\n * fileContents maps filename (e.g. \"role-creation.principle.feature\") to Gherkin text.\n */\nexport function filesToState(manifest: Manifest, fileContents: Record<string, string>): State {\n const buildState = (id: string, node: ManifestNode): State => {\n const filename = `${id}.${node.type}.feature`;\n const information = fileContents[filename];\n\n const children: State[] = [];\n if (node.children) {\n for (const [childId, childNode] of Object.entries(node.children)) {\n children.push(buildState(childId, childNode));\n }\n }\n\n const nodeLinks: { relation: string; target: State }[] = [];\n if (node.links) {\n for (const [relation, targetIds] of Object.entries(node.links)) {\n for (const targetId of targetIds) {\n nodeLinks.push({\n relation,\n target: { id: targetId, name: \"\", description: \"\", parent: null },\n });\n }\n }\n }\n\n return {\n ...(node.ref ? { ref: node.ref } : {}),\n id,\n name: node.type,\n description: \"\",\n parent: null,\n ...(node.tag ? { tag: node.tag } : {}),\n ...(information ? { information } : {}),\n ...(children.length > 0 ? { children } : {}),\n ...(nodeLinks.length > 0 ? { links: nodeLinks } : {}),\n };\n };\n\n const rootFilename = `${manifest.id}.${manifest.type}.feature`;\n const rootInformation = fileContents[rootFilename];\n\n const children: State[] = [];\n if (manifest.children) {\n for (const [childId, childNode] of Object.entries(manifest.children)) {\n children.push(buildState(childId, childNode));\n }\n }\n\n const links: { relation: string; target: State }[] = [];\n if (manifest.links) {\n for (const [relation, targetIds] of Object.entries(manifest.links)) {\n for (const targetId of targetIds) {\n links.push({\n relation,\n target: {\n id: targetId,\n name: \"\",\n description: \"\",\n parent: null,\n },\n });\n }\n }\n }\n\n return {\n ...(manifest.ref ? { ref: manifest.ref } : {}),\n id: manifest.id,\n ...(manifest.alias ? { alias: manifest.alias } : {}),\n name: manifest.type,\n description: \"\",\n parent: null,\n ...(rootInformation ? { information: rootInformation } : {}),\n ...(children.length > 0 ? { children } : {}),\n ...(links.length > 0 ? { links } : {}),\n };\n}\n"],"mappings":";AASA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,oBAAo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AU,IAAI,CAAC;AAAA,IACrD;AAAA,EACF;AAEA,QAAM,eAAe,GAAG,SAAS,EAAE,IAAI,SAAS,IAAI;AACpD,QAAM,kBAAkB,aAAa,YAAY;AAEjD,QAAM,WAAoB,CAAC;AAC3B,MAAI,SAAS,UAAU;AACrB,eAAW,CAAC,SAAS,SAAS,KAAK,OAAO,QAAQ,SAAS,QAAQ,GAAG;AACpE,eAAS,KAAK,WAAW,SAAS,SAAS,CAAC;AAAA,IAC9C;AAAA,EACF;AAEA,QAAMD,SAA+C,CAAC;AACtD,MAAI,SAAS,OAAO;AAClB,eAAW,CAAC,UAAU,SAAS,KAAK,OAAO,QAAQ,SAAS,KAAK,GAAG;AAClE,iBAAW,YAAY,WAAW;AAChC,QAAAA,OAAM,KAAK;AAAA,UACT;AAAA,UACA,QAAQ;AAAA,YACN,IAAI;AAAA,YACJ,MAAM;AAAA,YACN,aAAa;AAAA,YACb,QAAQ;AAAA,UACV;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAI,SAAS,MAAM,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC;AAAA,IAC5C,IAAI,SAAS;AAAA,IACb,GAAI,SAAS,QAAQ,EAAE,OAAO,SAAS,MAAM,IAAI,CAAC;AAAA,IAClD,MAAM,SAAS;AAAA,IACf,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,GAAI,kBAAkB,EAAE,aAAa,gBAAgB,IAAI,CAAC;AAAA,IAC1D,GAAI,SAAS,SAAS,IAAI,EAAE,SAAS,IAAI,CAAC;AAAA,IAC1C,GAAIA,OAAM,SAAS,IAAI,EAAE,OAAAA,OAAM,IAAI,CAAC;AAAA,EACtC;AACF;","names":["max","links","children"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolexjs/local-platform",
3
- "version": "0.12.0-dev-20260302114956",
3
+ "version": "1.0.0-dev-20260303015041",
4
4
  "description": "Local filesystem Platform for RoleX — stores roles in .rolex/ directories",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,8 +23,8 @@
23
23
  "@deepracticex/drizzle": "^0.2.0",
24
24
  "@deepracticex/sqlite": "^0.2.0",
25
25
  "@resourcexjs/node-provider": "^2.14.0",
26
- "@rolexjs/core": "0.12.0-dev-20260302114956",
27
- "@rolexjs/system": "0.12.0-dev-20260302114956",
26
+ "@rolexjs/core": "1.0.0-dev-20260303015041",
27
+ "@rolexjs/system": "1.0.0-dev-20260303015041",
28
28
  "drizzle-orm": "^0.45.1"
29
29
  },
30
30
  "devDependencies": {},