From 1806fb1ada41f9047db43dd45894070850e45f36 Mon Sep 17 00:00:00 2001 From: Abhin Rustagi Date: Fri, 10 Jul 2026 13:10:51 +0530 Subject: [PATCH 1/3] feat: add optional identifier --- .../lang-core/src/__tests__/library.test.ts | 21 +++++++++++++++++++ packages/lang-core/src/library.ts | 4 ++++ packages/lang-core/src/parser/prompt.ts | 1 + 3 files changed, 26 insertions(+) diff --git a/packages/lang-core/src/__tests__/library.test.ts b/packages/lang-core/src/__tests__/library.test.ts index 7c877ccc1..cd5eaaf14 100644 --- a/packages/lang-core/src/__tests__/library.test.ts +++ b/packages/lang-core/src/__tests__/library.test.ts @@ -166,6 +166,27 @@ describe("per-library registry", () => { expect(spec.schema).toEqual(lib.toJSONSchema()); }); + it("toSpec carries the createLibrary identifier, omitted when unset", () => { + const Text = defineComponent({ + name: "TextContent", + props: z.object({ text: z.string() }), + description: "text", + component: Dummy, + }); + + const named = createLibrary({ + components: [Text], + root: "TextContent", + identifier: "acme-support@3", + }); + expect(named.identifier).toBe("acme-support@3"); + expect(named.toSpec().identifier).toBe("acme-support@3"); + + const anonymous = createLibrary({ components: [Text], root: "TextContent" }); + expect(anonymous.identifier).toBeUndefined(); + expect("identifier" in anonymous.toSpec()).toBe(false); + }); + it("toJSONSchema carries defineComponent descriptions on $defs entries", () => { const Text = defineComponent({ name: "TextContent", diff --git a/packages/lang-core/src/library.ts b/packages/lang-core/src/library.ts index 4008ab5bf..1eb6cb488 100644 --- a/packages/lang-core/src/library.ts +++ b/packages/lang-core/src/library.ts @@ -336,6 +336,7 @@ export interface Library { readonly components: Record>; readonly componentGroups: ComponentGroup[] | undefined; readonly root: string | undefined; + readonly identifier: string | undefined; prompt(options?: PromptOptions): string; toSpec(): PromptSpec; @@ -346,6 +347,7 @@ export interface LibraryDefinition { components: DefinedComponent[]; componentGroups?: ComponentGroup[]; root?: string; + identifier?: string; } /** @@ -371,6 +373,7 @@ export function createLibrary(input: LibraryDefinition): Library components: componentsRecord, componentGroups: input.componentGroups, root: input.root, + identifier: input.identifier, prompt(options?: PromptOptions): string { const spec: PromptSpec = { @@ -388,6 +391,7 @@ export function createLibrary(input: LibraryDefinition): Library components: buildComponentSpecs(componentsRecord, reg), componentGroups: input.componentGroups, schema: buildJSONSchema(), + ...(input.identifier !== undefined ? { identifier: input.identifier } : {}), }; }, diff --git a/packages/lang-core/src/parser/prompt.ts b/packages/lang-core/src/parser/prompt.ts index d5dce4907..711590c42 100644 --- a/packages/lang-core/src/parser/prompt.ts +++ b/packages/lang-core/src/parser/prompt.ts @@ -27,6 +27,7 @@ export interface ComponentGroup { } export interface BaseSpec { + identifier?: string; root?: string; components: Record; componentGroups?: ComponentGroup[]; From e2206ffa49490d34dc3da017ec807e3ba0fddc05 Mon Sep 17 00:00:00 2001 From: Abhin Rustagi Date: Fri, 10 Jul 2026 13:12:13 +0530 Subject: [PATCH 2/3] fix: verion bump --- packages/lang-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lang-core/package.json b/packages/lang-core/package.json index c7063a6d0..4773a1223 100644 --- a/packages/lang-core/package.json +++ b/packages/lang-core/package.json @@ -1,6 +1,6 @@ { "name": "@openuidev/lang-core", - "version": "0.2.8", + "version": "0.2.9", "description": "Framework-agnostic core for OpenUI Lang: parser, prompt generation, validation, and type definitions", "license": "MIT", "type": "module", From 22dd7e0f9d8a56c1c831636f04b8a714cea40332 Mon Sep 17 00:00:00 2001 From: Abhin Rustagi Date: Sat, 11 Jul 2026 21:25:07 +0530 Subject: [PATCH 3/3] fix: switch to id --- packages/lang-core/src/__tests__/library.test.ts | 12 ++++++------ packages/lang-core/src/library.ts | 8 ++++---- packages/lang-core/src/parser/prompt.ts | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/lang-core/src/__tests__/library.test.ts b/packages/lang-core/src/__tests__/library.test.ts index cd5eaaf14..fbdbf617b 100644 --- a/packages/lang-core/src/__tests__/library.test.ts +++ b/packages/lang-core/src/__tests__/library.test.ts @@ -166,7 +166,7 @@ describe("per-library registry", () => { expect(spec.schema).toEqual(lib.toJSONSchema()); }); - it("toSpec carries the createLibrary identifier, omitted when unset", () => { + it("toSpec carries the createLibrary id, omitted when unset", () => { const Text = defineComponent({ name: "TextContent", props: z.object({ text: z.string() }), @@ -177,14 +177,14 @@ describe("per-library registry", () => { const named = createLibrary({ components: [Text], root: "TextContent", - identifier: "acme-support@3", + id: "acme-support@3", }); - expect(named.identifier).toBe("acme-support@3"); - expect(named.toSpec().identifier).toBe("acme-support@3"); + expect(named.id).toBe("acme-support@3"); + expect(named.toSpec().id).toBe("acme-support@3"); const anonymous = createLibrary({ components: [Text], root: "TextContent" }); - expect(anonymous.identifier).toBeUndefined(); - expect("identifier" in anonymous.toSpec()).toBe(false); + expect(anonymous.id).toBeUndefined(); + expect("id" in anonymous.toSpec()).toBe(false); }); it("toJSONSchema carries defineComponent descriptions on $defs entries", () => { diff --git a/packages/lang-core/src/library.ts b/packages/lang-core/src/library.ts index 1eb6cb488..98af3bfe3 100644 --- a/packages/lang-core/src/library.ts +++ b/packages/lang-core/src/library.ts @@ -336,7 +336,7 @@ export interface Library { readonly components: Record>; readonly componentGroups: ComponentGroup[] | undefined; readonly root: string | undefined; - readonly identifier: string | undefined; + readonly id: string | undefined; prompt(options?: PromptOptions): string; toSpec(): PromptSpec; @@ -347,7 +347,7 @@ export interface LibraryDefinition { components: DefinedComponent[]; componentGroups?: ComponentGroup[]; root?: string; - identifier?: string; + id?: string; } /** @@ -373,7 +373,7 @@ export function createLibrary(input: LibraryDefinition): Library components: componentsRecord, componentGroups: input.componentGroups, root: input.root, - identifier: input.identifier, + id: input.id, prompt(options?: PromptOptions): string { const spec: PromptSpec = { @@ -391,7 +391,7 @@ export function createLibrary(input: LibraryDefinition): Library components: buildComponentSpecs(componentsRecord, reg), componentGroups: input.componentGroups, schema: buildJSONSchema(), - ...(input.identifier !== undefined ? { identifier: input.identifier } : {}), + ...(input.id !== undefined ? { id: input.id } : {}), }; }, diff --git a/packages/lang-core/src/parser/prompt.ts b/packages/lang-core/src/parser/prompt.ts index 711590c42..302ca80ce 100644 --- a/packages/lang-core/src/parser/prompt.ts +++ b/packages/lang-core/src/parser/prompt.ts @@ -27,7 +27,7 @@ export interface ComponentGroup { } export interface BaseSpec { - identifier?: string; + id?: string; root?: string; components: Record; componentGroups?: ComponentGroup[];