schematex 0.9.10 → 0.9.12
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/ai/ai-sdk.cjs +10 -9
- package/dist/ai/ai-sdk.cjs.map +1 -1
- package/dist/ai/ai-sdk.d.cts +5 -5
- package/dist/ai/ai-sdk.d.ts +5 -5
- package/dist/ai/ai-sdk.js +5 -4
- package/dist/ai/ai-sdk.js.map +1 -1
- package/dist/ai/index.cjs +19 -18
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +4 -4
- package/dist/ai/index.d.ts +4 -4
- package/dist/ai/index.js +6 -5
- package/dist/ai/index.js.map +1 -1
- package/dist/{api-D_d-JklT.d.ts → api-C9ufsgIb.d.ts} +2 -2
- package/dist/{api-DnTyW-6F.d.cts → api-DAUFeETp.d.cts} +2 -2
- package/dist/browser.cjs +11 -10
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +3 -3
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +5 -4
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-IHX6J4HF.js → chunk-32LOZTNP.js} +178 -4
- package/dist/chunk-32LOZTNP.js.map +1 -0
- package/dist/{chunk-CXA45HIT.js → chunk-6KW7XSUR.js} +203 -12
- package/dist/chunk-6KW7XSUR.js.map +1 -0
- package/dist/{chunk-TXWVJAMR.cjs → chunk-HEGDKO2E.cjs} +178 -4
- package/dist/chunk-HEGDKO2E.cjs.map +1 -0
- package/dist/chunk-IBZKIMT5.cjs +826 -0
- package/dist/chunk-IBZKIMT5.cjs.map +1 -0
- package/dist/{chunk-T5QOVX2I.js → chunk-JLLDJCLW.js} +13194 -13037
- package/dist/chunk-JLLDJCLW.js.map +1 -0
- package/dist/{chunk-OY2CXLVY.cjs → chunk-MGMR6V6N.cjs} +13196 -13037
- package/dist/chunk-MGMR6V6N.cjs.map +1 -0
- package/dist/{chunk-MXV3XJFH.cjs → chunk-OGF7QM74.cjs} +80 -17
- package/dist/chunk-OGF7QM74.cjs.map +1 -0
- package/dist/chunk-PGMKMIGM.js +818 -0
- package/dist/chunk-PGMKMIGM.js.map +1 -0
- package/dist/{chunk-MVTYPWHO.js → chunk-Q5MQLUOH.js} +80 -17
- package/dist/chunk-Q5MQLUOH.js.map +1 -0
- package/dist/{chunk-CA54ESRT.cjs → chunk-YLG7S4SM.cjs} +205 -14
- package/dist/chunk-YLG7S4SM.cjs.map +1 -0
- package/dist/{diagnostics-D2qkBfFx.d.cts → diagnostics-DSxLohjY.d.cts} +9 -3
- package/dist/{diagnostics-D2qkBfFx.d.ts → diagnostics-DSxLohjY.d.ts} +9 -3
- package/dist/diagrams/blockdiagram/index.d.cts +1 -1
- package/dist/diagrams/blockdiagram/index.d.ts +1 -1
- package/dist/diagrams/circuit/index.cjs +8 -8
- package/dist/diagrams/circuit/index.d.cts +1 -1
- package/dist/diagrams/circuit/index.d.ts +1 -1
- package/dist/diagrams/circuit/index.js +1 -1
- package/dist/diagrams/ecomap/index.d.cts +1 -1
- package/dist/diagrams/ecomap/index.d.ts +1 -1
- package/dist/diagrams/entity/index.d.cts +1 -1
- package/dist/diagrams/entity/index.d.ts +1 -1
- package/dist/diagrams/fishbone/index.d.cts +1 -1
- package/dist/diagrams/fishbone/index.d.ts +1 -1
- package/dist/diagrams/flowchart/index.d.cts +2 -2
- package/dist/diagrams/flowchart/index.d.ts +2 -2
- package/dist/diagrams/genogram/index.d.cts +1 -1
- package/dist/diagrams/genogram/index.d.ts +1 -1
- package/dist/diagrams/ladder/index.d.cts +1 -1
- package/dist/diagrams/ladder/index.d.ts +1 -1
- package/dist/diagrams/logic/index.d.cts +1 -1
- package/dist/diagrams/logic/index.d.ts +1 -1
- package/dist/diagrams/orgchart/index.d.cts +1 -1
- package/dist/diagrams/orgchart/index.d.ts +1 -1
- package/dist/diagrams/pedigree/index.d.cts +1 -1
- package/dist/diagrams/pedigree/index.d.ts +1 -1
- package/dist/diagrams/phylo/index.d.cts +1 -1
- package/dist/diagrams/phylo/index.d.ts +1 -1
- package/dist/diagrams/siteplan/index.cjs +38 -0
- package/dist/diagrams/siteplan/index.cjs.map +1 -0
- package/dist/diagrams/siteplan/index.d.cts +122 -0
- package/dist/diagrams/siteplan/index.d.ts +122 -0
- package/dist/diagrams/siteplan/index.js +5 -0
- package/dist/diagrams/siteplan/index.js.map +1 -0
- package/dist/diagrams/sld/index.cjs +7 -7
- package/dist/diagrams/sld/index.d.cts +4 -1
- package/dist/diagrams/sld/index.d.ts +4 -1
- package/dist/diagrams/sld/index.js +1 -1
- package/dist/diagrams/sociogram/index.d.cts +1 -1
- package/dist/diagrams/sociogram/index.d.ts +1 -1
- package/dist/diagrams/timing/index.d.cts +1 -1
- package/dist/diagrams/timing/index.d.ts +1 -1
- package/dist/diagrams/venn/index.d.cts +1 -1
- package/dist/diagrams/venn/index.d.ts +1 -1
- package/dist/{index-JZlLiE6K.d.cts → index-CDDfbChc.d.cts} +1 -1
- package/dist/{index-D9u0YRxL.d.ts → index-CZa2pU0T.d.ts} +1 -1
- package/dist/index.cjs +56 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +5 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +4 -3
- package/dist/react.js.map +1 -1
- package/dist/{tools-DAKYNcPv.d.cts → tools-Bvw6dwIR.d.cts} +2 -2
- package/dist/{tools-DM0aLCbc.d.ts → tools-DtuvE-K4.d.ts} +2 -2
- package/package.json +6 -1
- package/dist/chunk-CA54ESRT.cjs.map +0 -1
- package/dist/chunk-CXA45HIT.js.map +0 -1
- package/dist/chunk-IHX6J4HF.js.map +0 -1
- package/dist/chunk-MVTYPWHO.js.map +0 -1
- package/dist/chunk-MXV3XJFH.cjs.map +0 -1
- package/dist/chunk-OY2CXLVY.cjs.map +0 -1
- package/dist/chunk-T5QOVX2I.js.map +0 -1
- package/dist/chunk-TXWVJAMR.cjs.map +0 -1
package/dist/ai/ai-sdk.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkYLG7S4SM_cjs = require('../chunk-YLG7S4SM.cjs');
|
|
4
|
+
require('../chunk-MGMR6V6N.cjs');
|
|
5
5
|
require('../chunk-UHRNFBWY.cjs');
|
|
6
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-IBZKIMT5.cjs');
|
|
7
|
+
require('../chunk-HEGDKO2E.cjs');
|
|
7
8
|
require('../chunk-T55OQILI.cjs');
|
|
8
9
|
require('../chunk-GTCGATOL.cjs');
|
|
9
|
-
require('../chunk-
|
|
10
|
+
require('../chunk-OGF7QM74.cjs');
|
|
10
11
|
require('../chunk-4MANMKQ4.cjs');
|
|
11
12
|
require('../chunk-YFPDZVB7.cjs');
|
|
12
13
|
require('../chunk-3JN4762U.cjs');
|
|
@@ -31,7 +32,7 @@ var schematexTools = {
|
|
|
31
32
|
listDiagrams: ai.tool({
|
|
32
33
|
description: "List every Schematex diagram type with a tagline, 'use when' hint, domain cluster, and authoritative standard. Call this first to discover what's available.",
|
|
33
34
|
inputSchema: zod.z.object({}),
|
|
34
|
-
execute: async () =>
|
|
35
|
+
execute: async () => chunkYLG7S4SM_cjs.listDiagrams()
|
|
35
36
|
}),
|
|
36
37
|
getSyntax: ai.tool({
|
|
37
38
|
description: "Return syntax for one diagram type. Default `detail: canonical` is the compact first-shot generation path: canonical header, preferred forms, rules, and repair checks. Request `detail: reference` only for advanced forms or imported adapters after choosing a type.",
|
|
@@ -46,7 +47,7 @@ var schematexTools = {
|
|
|
46
47
|
execute: async ({
|
|
47
48
|
type,
|
|
48
49
|
detail
|
|
49
|
-
}) =>
|
|
50
|
+
}) => chunkYLG7S4SM_cjs.getSyntax(type, { detail })
|
|
50
51
|
}),
|
|
51
52
|
getExamples: ai.tool({
|
|
52
53
|
description: "Return curated real-world DSL examples for a diagram type, each with scenario notes and tags. Use as few-shot context before generating DSL.",
|
|
@@ -56,7 +57,7 @@ var schematexTools = {
|
|
|
56
57
|
preferFeatured: zod.z.boolean().optional().describe("Rank featured examples first."),
|
|
57
58
|
maxComplexity: zod.z.number().int().min(1).max(5).optional().describe("Only return examples with complexity <= this value (1=simplest).")
|
|
58
59
|
}),
|
|
59
|
-
execute: async (args) =>
|
|
60
|
+
execute: async (args) => chunkYLG7S4SM_cjs.getExamples(args.type, {
|
|
60
61
|
limit: args.limit,
|
|
61
62
|
preferFeatured: args.preferFeatured,
|
|
62
63
|
maxComplexity: args.maxComplexity
|
|
@@ -70,7 +71,7 @@ var schematexTools = {
|
|
|
70
71
|
),
|
|
71
72
|
dsl: zod.z.string().describe("The DSL source text to validate.")
|
|
72
73
|
}),
|
|
73
|
-
execute: async ({ type, dsl }) =>
|
|
74
|
+
execute: async ({ type, dsl }) => chunkYLG7S4SM_cjs.validateDsl(type, dsl)
|
|
74
75
|
}),
|
|
75
76
|
renderDsl: ai.tool({
|
|
76
77
|
description: "Render Schematex DSL to an SVG string. Returns { ok: true, svg } or { ok: false, errors }. Use when the caller needs the actual diagram output, not just validation.",
|
|
@@ -85,7 +86,7 @@ var schematexTools = {
|
|
|
85
86
|
dsl,
|
|
86
87
|
theme,
|
|
87
88
|
padding
|
|
88
|
-
}) =>
|
|
89
|
+
}) => chunkYLG7S4SM_cjs.renderDsl(type, dsl, { theme, padding })
|
|
89
90
|
})
|
|
90
91
|
};
|
|
91
92
|
|
package/dist/ai/ai-sdk.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":["tool","z","listDiagrams","getSyntax","getExamples","validateDsl","renderDsl"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":["tool","z","listDiagrams","getSyntax","getExamples","validateDsl","renderDsl"],"mappings":"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","file":"ai-sdk.cjs","sourcesContent":["/**\n * Vercel AI SDK adapter — ready-to-use `tools` object for `generateText` /\n * `streamText`.\n *\n * @example\n * ```ts\n * import { streamText } from 'ai';\n * import { schematexTools } from 'schematex/ai/sdk';\n *\n * const result = streamText({\n * model: 'anthropic/claude-opus-4-7',\n * tools: schematexTools,\n * maxSteps: 5,\n * system: `You write Schematex DSL. Discover types with listDiagrams,\n * then fetch getSyntax + getExamples before writing. Call validateDsl\n * before returning DSL to the user.`,\n * prompt: userMessage,\n * });\n * ```\n *\n * Peer-deps `ai` and `zod` are optional — this module only loads if both\n * are installed.\n */\nimport { tool } from \"ai\";\nimport { z } from \"zod\";\n\nimport {\n listDiagrams as listDiagramsImpl,\n getSyntax as getSyntaxImpl,\n getExamples as getExamplesImpl,\n validateDsl as validateDslImpl,\n renderDsl as renderDslImpl,\n} from \"./tools\";\n\nexport const schematexTools = {\n listDiagrams: tool({\n description:\n \"List every Schematex diagram type with a tagline, 'use when' hint, domain cluster, and authoritative standard. Call this first to discover what's available.\",\n inputSchema: z.object({}),\n execute: async () => listDiagramsImpl(),\n }),\n\n getSyntax: tool({\n description:\n \"Return syntax for one diagram type. Default `detail: canonical` is the compact first-shot generation path: canonical header, preferred forms, rules, and repair checks. Request `detail: reference` only for advanced forms or imported adapters after choosing a type.\",\n inputSchema: z.object({\n type: z\n .string()\n .describe(\n \"Diagram type id from listDiagrams (e.g. 'genogram', 'sld', 'fishbone').\"\n ),\n detail: z\n .enum([\"canonical\", \"reference\"])\n .optional()\n .describe(\n \"Default `canonical` is best for generation. Use `reference` for the fuller grammar/tutorial.\"\n ),\n }),\n execute: async ({\n type,\n detail,\n }: {\n type: string;\n detail?: \"canonical\" | \"reference\";\n }) => getSyntaxImpl(type, { detail }),\n }),\n\n getExamples: tool({\n description:\n \"Return curated real-world DSL examples for a diagram type, each with scenario notes and tags. Use as few-shot context before generating DSL.\",\n inputSchema: z.object({\n type: z.string().describe(\"Diagram type id.\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe(\"Max examples to return (default 5).\"),\n preferFeatured: z\n .boolean()\n .optional()\n .describe(\"Rank featured examples first.\"),\n maxComplexity: z\n .number()\n .int()\n .min(1)\n .max(5)\n .optional()\n .describe(\"Only return examples with complexity <= this value (1=simplest).\"),\n }),\n execute: async (args: {\n type: string;\n limit?: number;\n preferFeatured?: boolean;\n maxComplexity?: number;\n }) =>\n getExamplesImpl(args.type, {\n limit: args.limit,\n preferFeatured: args.preferFeatured,\n maxComplexity: args.maxComplexity,\n }),\n }),\n\n validateDsl: tool({\n description:\n \"Validate Schematex DSL. Pass the selected diagram `type` whenever you know it. Returns { ok: true } or { ok: false, errors: [{line, column, message, source, hint}] }. Call before returning DSL and self-correct on errors.\",\n inputSchema: z.object({\n type: z\n .string()\n .optional()\n .describe(\n \"Selected diagram type. Optional for adapters/autodetect, but explicit canonical types are more robust.\"\n ),\n dsl: z.string().describe(\"The DSL source text to validate.\"),\n }),\n execute: async ({ type, dsl }: { type?: string; dsl: string }) =>\n validateDslImpl(type, dsl),\n }),\n\n renderDsl: tool({\n description:\n \"Render Schematex DSL to an SVG string. Returns { ok: true, svg } or { ok: false, errors }. Use when the caller needs the actual diagram output, not just validation.\",\n inputSchema: z.object({\n type: z\n .string()\n .optional()\n .describe(\"Selected diagram type. Prefer passing it once chosen.\"),\n dsl: z.string().describe(\"The DSL source text to render.\"),\n theme: z.string().optional().describe(\"Theme name, e.g. 'default' or 'dark'.\"),\n padding: z.number().optional().describe(\"Outer padding in pixels.\"),\n }),\n execute: async ({\n type,\n dsl,\n theme,\n padding,\n }: {\n type?: string;\n dsl: string;\n theme?: string;\n padding?: number;\n }) => renderDslImpl(type, dsl, { theme, padding }),\n }),\n} as const;\n\nexport type SchematexTools = typeof schematexTools;\n"]}
|
package/dist/ai/ai-sdk.d.cts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
|
-
import { c as DiagramListItem, g as GetSyntaxResult, e as GetExamplesResult, V as ValidateDslResult, R as RenderDslResult } from '../tools-
|
|
3
|
-
import '../api-
|
|
4
|
-
import '../diagnostics-
|
|
2
|
+
import { c as DiagramListItem, g as GetSyntaxResult, e as GetExamplesResult, V as ValidateDslResult, R as RenderDslResult } from '../tools-Bvw6dwIR.cjs';
|
|
3
|
+
import '../api-DAUFeETp.cjs';
|
|
4
|
+
import '../diagnostics-DSxLohjY.cjs';
|
|
5
5
|
|
|
6
6
|
declare const schematexTools: {
|
|
7
7
|
readonly listDiagrams: ai.Tool<{}, DiagramListItem[]>;
|
|
8
8
|
readonly getSyntax: ai.Tool<{
|
|
9
9
|
type: string;
|
|
10
|
-
detail?: "
|
|
10
|
+
detail?: "reference" | "canonical" | undefined;
|
|
11
11
|
}, GetSyntaxResult>;
|
|
12
12
|
readonly getExamples: ai.Tool<{
|
|
13
13
|
type: string;
|
|
14
14
|
limit?: number | undefined;
|
|
15
|
-
preferFeatured?: boolean | undefined;
|
|
16
15
|
maxComplexity?: number | undefined;
|
|
16
|
+
preferFeatured?: boolean | undefined;
|
|
17
17
|
}, GetExamplesResult>;
|
|
18
18
|
readonly validateDsl: ai.Tool<{
|
|
19
19
|
dsl: string;
|
package/dist/ai/ai-sdk.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
|
-
import { c as DiagramListItem, g as GetSyntaxResult, e as GetExamplesResult, V as ValidateDslResult, R as RenderDslResult } from '../tools-
|
|
3
|
-
import '../api-
|
|
4
|
-
import '../diagnostics-
|
|
2
|
+
import { c as DiagramListItem, g as GetSyntaxResult, e as GetExamplesResult, V as ValidateDslResult, R as RenderDslResult } from '../tools-DtuvE-K4.js';
|
|
3
|
+
import '../api-C9ufsgIb.js';
|
|
4
|
+
import '../diagnostics-DSxLohjY.js';
|
|
5
5
|
|
|
6
6
|
declare const schematexTools: {
|
|
7
7
|
readonly listDiagrams: ai.Tool<{}, DiagramListItem[]>;
|
|
8
8
|
readonly getSyntax: ai.Tool<{
|
|
9
9
|
type: string;
|
|
10
|
-
detail?: "
|
|
10
|
+
detail?: "reference" | "canonical" | undefined;
|
|
11
11
|
}, GetSyntaxResult>;
|
|
12
12
|
readonly getExamples: ai.Tool<{
|
|
13
13
|
type: string;
|
|
14
14
|
limit?: number | undefined;
|
|
15
|
-
preferFeatured?: boolean | undefined;
|
|
16
15
|
maxComplexity?: number | undefined;
|
|
16
|
+
preferFeatured?: boolean | undefined;
|
|
17
17
|
}, GetExamplesResult>;
|
|
18
18
|
readonly validateDsl: ai.Tool<{
|
|
19
19
|
dsl: string;
|
package/dist/ai/ai-sdk.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-6KW7XSUR.js';
|
|
2
|
+
import '../chunk-JLLDJCLW.js';
|
|
3
3
|
import '../chunk-EB7T5SEO.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-PGMKMIGM.js';
|
|
5
|
+
import '../chunk-32LOZTNP.js';
|
|
5
6
|
import '../chunk-P4U565XH.js';
|
|
6
7
|
import '../chunk-W4UVDMUC.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
+
import '../chunk-Q5MQLUOH.js';
|
|
8
9
|
import '../chunk-2IRYXK4M.js';
|
|
9
10
|
import '../chunk-NP7N3DZG.js';
|
|
10
11
|
import '../chunk-KUSW5I2P.js';
|
package/dist/ai/ai-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":[],"mappings":"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","file":"ai-sdk.js","sourcesContent":["/**\n * Vercel AI SDK adapter — ready-to-use `tools` object for `generateText` /\n * `streamText`.\n *\n * @example\n * ```ts\n * import { streamText } from 'ai';\n * import { schematexTools } from 'schematex/ai/sdk';\n *\n * const result = streamText({\n * model: 'anthropic/claude-opus-4-7',\n * tools: schematexTools,\n * maxSteps: 5,\n * system: `You write Schematex DSL. Discover types with listDiagrams,\n * then fetch getSyntax + getExamples before writing. Call validateDsl\n * before returning DSL to the user.`,\n * prompt: userMessage,\n * });\n * ```\n *\n * Peer-deps `ai` and `zod` are optional — this module only loads if both\n * are installed.\n */\nimport { tool } from \"ai\";\nimport { z } from \"zod\";\n\nimport {\n listDiagrams as listDiagramsImpl,\n getSyntax as getSyntaxImpl,\n getExamples as getExamplesImpl,\n validateDsl as validateDslImpl,\n renderDsl as renderDslImpl,\n} from \"./tools\";\n\nexport const schematexTools = {\n listDiagrams: tool({\n description:\n \"List every Schematex diagram type with a tagline, 'use when' hint, domain cluster, and authoritative standard. Call this first to discover what's available.\",\n inputSchema: z.object({}),\n execute: async () => listDiagramsImpl(),\n }),\n\n getSyntax: tool({\n description:\n \"Return syntax for one diagram type. Default `detail: canonical` is the compact first-shot generation path: canonical header, preferred forms, rules, and repair checks. Request `detail: reference` only for advanced forms or imported adapters after choosing a type.\",\n inputSchema: z.object({\n type: z\n .string()\n .describe(\n \"Diagram type id from listDiagrams (e.g. 'genogram', 'sld', 'fishbone').\"\n ),\n detail: z\n .enum([\"canonical\", \"reference\"])\n .optional()\n .describe(\n \"Default `canonical` is best for generation. Use `reference` for the fuller grammar/tutorial.\"\n ),\n }),\n execute: async ({\n type,\n detail,\n }: {\n type: string;\n detail?: \"canonical\" | \"reference\";\n }) => getSyntaxImpl(type, { detail }),\n }),\n\n getExamples: tool({\n description:\n \"Return curated real-world DSL examples for a diagram type, each with scenario notes and tags. Use as few-shot context before generating DSL.\",\n inputSchema: z.object({\n type: z.string().describe(\"Diagram type id.\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe(\"Max examples to return (default 5).\"),\n preferFeatured: z\n .boolean()\n .optional()\n .describe(\"Rank featured examples first.\"),\n maxComplexity: z\n .number()\n .int()\n .min(1)\n .max(5)\n .optional()\n .describe(\"Only return examples with complexity <= this value (1=simplest).\"),\n }),\n execute: async (args: {\n type: string;\n limit?: number;\n preferFeatured?: boolean;\n maxComplexity?: number;\n }) =>\n getExamplesImpl(args.type, {\n limit: args.limit,\n preferFeatured: args.preferFeatured,\n maxComplexity: args.maxComplexity,\n }),\n }),\n\n validateDsl: tool({\n description:\n \"Validate Schematex DSL. Pass the selected diagram `type` whenever you know it. Returns { ok: true } or { ok: false, errors: [{line, column, message, source, hint}] }. Call before returning DSL and self-correct on errors.\",\n inputSchema: z.object({\n type: z\n .string()\n .optional()\n .describe(\n \"Selected diagram type. Optional for adapters/autodetect, but explicit canonical types are more robust.\"\n ),\n dsl: z.string().describe(\"The DSL source text to validate.\"),\n }),\n execute: async ({ type, dsl }: { type?: string; dsl: string }) =>\n validateDslImpl(type, dsl),\n }),\n\n renderDsl: tool({\n description:\n \"Render Schematex DSL to an SVG string. Returns { ok: true, svg } or { ok: false, errors }. Use when the caller needs the actual diagram output, not just validation.\",\n inputSchema: z.object({\n type: z\n .string()\n .optional()\n .describe(\"Selected diagram type. Prefer passing it once chosen.\"),\n dsl: z.string().describe(\"The DSL source text to render.\"),\n theme: z.string().optional().describe(\"Theme name, e.g. 'default' or 'dark'.\"),\n padding: z.number().optional().describe(\"Outer padding in pixels.\"),\n }),\n execute: async ({\n type,\n dsl,\n theme,\n padding,\n }: {\n type?: string;\n dsl: string;\n theme?: string;\n padding?: number;\n }) => renderDslImpl(type, dsl, { theme, padding }),\n }),\n} as const;\n\nexport type SchematexTools = typeof schematexTools;\n"]}
|
package/dist/ai/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkYLG7S4SM_cjs = require('../chunk-YLG7S4SM.cjs');
|
|
4
|
+
require('../chunk-MGMR6V6N.cjs');
|
|
5
5
|
require('../chunk-UHRNFBWY.cjs');
|
|
6
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-IBZKIMT5.cjs');
|
|
7
|
+
require('../chunk-HEGDKO2E.cjs');
|
|
7
8
|
require('../chunk-T55OQILI.cjs');
|
|
8
9
|
require('../chunk-GTCGATOL.cjs');
|
|
9
|
-
require('../chunk-
|
|
10
|
+
require('../chunk-OGF7QM74.cjs');
|
|
10
11
|
require('../chunk-4MANMKQ4.cjs');
|
|
11
12
|
require('../chunk-YFPDZVB7.cjs');
|
|
12
13
|
require('../chunk-3JN4762U.cjs');
|
|
@@ -27,10 +28,10 @@ require('../chunk-3WNW5Y7P.cjs');
|
|
|
27
28
|
|
|
28
29
|
// src/ai/prompt-context.ts
|
|
29
30
|
function buildPromptContext(type, opts = {}) {
|
|
30
|
-
const resolved =
|
|
31
|
+
const resolved = chunkYLG7S4SM_cjs.resolveDiagramType(type) ?? type;
|
|
31
32
|
const detail = opts.detail ?? "canonical";
|
|
32
33
|
const limit = opts.examples ?? 2;
|
|
33
|
-
const { type: canonical, name, standard, syntax } =
|
|
34
|
+
const { type: canonical, name, standard, syntax } = chunkYLG7S4SM_cjs.getSyntax(resolved, {
|
|
34
35
|
detail
|
|
35
36
|
});
|
|
36
37
|
const parts = [
|
|
@@ -41,7 +42,7 @@ function buildPromptContext(type, opts = {}) {
|
|
|
41
42
|
];
|
|
42
43
|
let exampleCount = 0;
|
|
43
44
|
if (limit > 0) {
|
|
44
|
-
const examples =
|
|
45
|
+
const examples = chunkYLG7S4SM_cjs.getExamples(canonical, {
|
|
45
46
|
preferFeatured: opts.preferFeatured ?? true,
|
|
46
47
|
limit,
|
|
47
48
|
maxComplexity: opts.maxComplexity
|
|
@@ -67,47 +68,47 @@ function buildPromptContext(type, opts = {}) {
|
|
|
67
68
|
|
|
68
69
|
Object.defineProperty(exports, "DIAGRAM_REGISTRY", {
|
|
69
70
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
71
|
+
get: function () { return chunkYLG7S4SM_cjs.DIAGRAM_REGISTRY; }
|
|
71
72
|
});
|
|
72
73
|
Object.defineProperty(exports, "DIAGRAM_SINCE", {
|
|
73
74
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
75
|
+
get: function () { return chunkYLG7S4SM_cjs.DIAGRAM_SINCE; }
|
|
75
76
|
});
|
|
76
77
|
Object.defineProperty(exports, "getAllDiagramTypes", {
|
|
77
78
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
79
|
+
get: function () { return chunkYLG7S4SM_cjs.getAllDiagramTypes; }
|
|
79
80
|
});
|
|
80
81
|
Object.defineProperty(exports, "getDiagramMeta", {
|
|
81
82
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
83
|
+
get: function () { return chunkYLG7S4SM_cjs.getDiagramMeta; }
|
|
83
84
|
});
|
|
84
85
|
Object.defineProperty(exports, "getDiagramSince", {
|
|
85
86
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
87
|
+
get: function () { return chunkYLG7S4SM_cjs.getDiagramSince; }
|
|
87
88
|
});
|
|
88
89
|
Object.defineProperty(exports, "getExamples", {
|
|
89
90
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
91
|
+
get: function () { return chunkYLG7S4SM_cjs.getExamples; }
|
|
91
92
|
});
|
|
92
93
|
Object.defineProperty(exports, "getSyntax", {
|
|
93
94
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
95
|
+
get: function () { return chunkYLG7S4SM_cjs.getSyntax; }
|
|
95
96
|
});
|
|
96
97
|
Object.defineProperty(exports, "listDiagrams", {
|
|
97
98
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
99
|
+
get: function () { return chunkYLG7S4SM_cjs.listDiagrams; }
|
|
99
100
|
});
|
|
100
101
|
Object.defineProperty(exports, "renderDsl", {
|
|
101
102
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
103
|
+
get: function () { return chunkYLG7S4SM_cjs.renderDsl; }
|
|
103
104
|
});
|
|
104
105
|
Object.defineProperty(exports, "resolveDiagramType", {
|
|
105
106
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
107
|
+
get: function () { return chunkYLG7S4SM_cjs.resolveDiagramType; }
|
|
107
108
|
});
|
|
108
109
|
Object.defineProperty(exports, "validateDsl", {
|
|
109
110
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
111
|
+
get: function () { return chunkYLG7S4SM_cjs.validateDsl; }
|
|
111
112
|
});
|
|
112
113
|
exports.buildPromptContext = buildPromptContext;
|
|
113
114
|
//# sourceMappingURL=index.cjs.map
|
package/dist/ai/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/prompt-context.ts"],"names":["resolveDiagramType","getSyntax","getExamples"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ai/prompt-context.ts"],"names":["resolveDiagramType","getSyntax","getExamples"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CO,SAAS,kBAAA,CACd,IAAA,EACA,IAAA,GAAkC,EAAC,EACpB;AACf,EAAA,MAAM,QAAA,GAAWA,oCAAA,CAAmB,IAAI,CAAA,IAAK,IAAA;AAC7C,EAAA,MAAM,MAAA,GAAuB,KAAK,MAAA,IAAU,WAAA;AAC5C,EAAA,MAAM,KAAA,GAAQ,KAAK,QAAA,IAAY,CAAA;AAE/B,EAAA,MAAM,EAAE,MAAM,SAAA,EAAW,IAAA,EAAM,UAAU,MAAA,EAAO,GAAIC,4BAAU,QAAA,EAAU;AAAA,IACtE;AAAA,GACD,CAAA;AAED,EAAA,MAAM,KAAA,GAAkB;AAAA,IACtB,CAAA,EAAA,EAAK,IAAI,CAAA,EAAA,EAAK,SAAS,CAAA,CAAA,CAAA;AAAA,IACvB,aAAa,QAAQ,CAAA,CAAA;AAAA,IACrB,EAAA;AAAA,IACA,MAAA,CAAO;AAAA,GACT;AAEA,EAAA,IAAI,YAAA,GAAe,CAAA;AACnB,EAAA,IAAI,QAAQ,CAAA,EAAG;AACb,IAAA,MAAM,QAAA,GAAWC,8BAAY,SAAA,EAAW;AAAA,MACtC,cAAA,EAAgB,KAAK,cAAA,IAAkB,IAAA;AAAA,MACvC,KAAA;AAAA,MACA,eAAe,IAAA,CAAK;AAAA,KACrB,CAAA,CAAE,QAAA;AACH,IAAA,YAAA,GAAe,QAAA,CAAS,MAAA;AACxB,IAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,MAAA,KAAA,CAAM,IAAA,CAAK,IAAI,oBAAoB,CAAA;AACnC,MAAA,KAAA,MAAW,MAAM,QAAA,EAAU;AACzB,QAAA,KAAA,CAAM,IAAA,CAAK,EAAA,EAAI,CAAA,IAAA,EAAO,EAAA,CAAG,KAAK,CAAA,CAAE,CAAA;AAChC,QAAA,IAAI,EAAA,CAAG,WAAA,EAAa,KAAA,CAAM,IAAA,CAAK,GAAG,WAAW,CAAA;AAC7C,QAAA,KAAA,CAAM,KAAK,KAAA,EAAO,EAAA,CAAG,GAAA,CAAI,IAAA,IAAQ,KAAK,CAAA;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,SAAA;AAAA,IACN,IAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA,EAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AAAA,IACrB;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * Prompt-context builder — a convenience wrapper for single-shot LLM callers.\n *\n * Agentic callers can keep using `getSyntax` + `getExamples` as separate tool\n * round-trips. But a high-volume single-shot caller (e.g. a product backend\n * generating DSL with one model call, no tool loop) just wants ONE inject-ready\n * block: the canonical grammar card plus a couple of worked few-shot examples.\n *\n * This adds no new knowledge — it stitches `getSyntax(detail: \"canonical\")` and\n * `getExamples(preferFeatured)` into one string so the caller doesn't have to\n * know the recipe. Both primitives remain exported and usable on their own.\n */\nimport { resolveDiagramType } from \"./registry\";\nimport { getExamples, getSyntax } from \"./tools\";\nimport type { SyntaxDetail } from \"./syntax\";\n\nexport interface BuildPromptContextOptions {\n /** How many few-shot examples to embed. Default 2. Set 0 to omit examples. */\n examples?: number;\n /** Syntax detail level. Default `\"canonical\"` (the compact first-shot card). */\n detail?: SyntaxDetail;\n /** Prefer `featured: true` examples first. Default true. */\n preferFeatured?: boolean;\n /** Cap embedded example complexity (1–5). */\n maxComplexity?: number;\n}\n\nexport interface PromptContext {\n type: string;\n name: string;\n standard: string;\n /** One inject-ready markdown block: grammar card + worked examples. */\n text: string;\n /** Number of examples embedded in `text`. */\n exampleCount: number;\n}\n\n/**\n * Build a single inject-ready prompt block for one diagram type.\n *\n * @example\n * const ctx = buildPromptContext(\"genogram\");\n * const systemPrompt = `Generate Schematex DSL.\\n\\n${ctx.text}`;\n */\nexport function buildPromptContext(\n type: string,\n opts: BuildPromptContextOptions = {}\n): PromptContext {\n const resolved = resolveDiagramType(type) ?? type;\n const detail: SyntaxDetail = opts.detail ?? \"canonical\";\n const limit = opts.examples ?? 2;\n\n const { type: canonical, name, standard, syntax } = getSyntax(resolved, {\n detail,\n });\n\n const parts: string[] = [\n `# ${name} (${canonical})`,\n `Standard: ${standard}`,\n \"\",\n syntax.content,\n ];\n\n let exampleCount = 0;\n if (limit > 0) {\n const examples = getExamples(canonical, {\n preferFeatured: opts.preferFeatured ?? true,\n limit,\n maxComplexity: opts.maxComplexity,\n }).examples;\n exampleCount = examples.length;\n if (examples.length > 0) {\n parts.push(\"\", \"## Worked examples\");\n for (const ex of examples) {\n parts.push(\"\", `### ${ex.title}`);\n if (ex.description) parts.push(ex.description);\n parts.push(\"```\", ex.dsl.trim(), \"```\");\n }\n }\n }\n\n return {\n type: canonical,\n name,\n standard,\n text: parts.join(\"\\n\"),\n exampleCount,\n };\n}\n"]}
|
package/dist/ai/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as SyntaxDetail } from '../tools-
|
|
2
|
-
export { D as DIAGRAM_REGISTRY, a as DIAGRAM_SINCE, b as DiagramCluster, c as DiagramListItem, d as DiagramMeta, E as Example, G as GetExamplesOptions, e as GetExamplesResult, f as GetSyntaxOptions, g as GetSyntaxResult, R as RenderDslResult, h as SchematexValidationError, i as SyntaxDoc, V as ValidateDslResult, j as getAllDiagramTypes, k as getDiagramMeta, l as getDiagramSince, m as getExamples, n as getSyntax, o as listDiagrams, r as renderDsl, p as resolveDiagramType, v as validateDsl } from '../tools-
|
|
3
|
-
import { a as DiagramType } from '../diagnostics-
|
|
4
|
-
import '../api-
|
|
1
|
+
import { S as SyntaxDetail } from '../tools-Bvw6dwIR.cjs';
|
|
2
|
+
export { D as DIAGRAM_REGISTRY, a as DIAGRAM_SINCE, b as DiagramCluster, c as DiagramListItem, d as DiagramMeta, E as Example, G as GetExamplesOptions, e as GetExamplesResult, f as GetSyntaxOptions, g as GetSyntaxResult, R as RenderDslResult, h as SchematexValidationError, i as SyntaxDoc, V as ValidateDslResult, j as getAllDiagramTypes, k as getDiagramMeta, l as getDiagramSince, m as getExamples, n as getSyntax, o as listDiagrams, r as renderDsl, p as resolveDiagramType, v as validateDsl } from '../tools-Bvw6dwIR.cjs';
|
|
3
|
+
import { a as DiagramType } from '../diagnostics-DSxLohjY.cjs';
|
|
4
|
+
import '../api-DAUFeETp.cjs';
|
|
5
5
|
|
|
6
6
|
interface BuildPromptContextOptions {
|
|
7
7
|
/** How many few-shot examples to embed. Default 2. Set 0 to omit examples. */
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as SyntaxDetail } from '../tools-
|
|
2
|
-
export { D as DIAGRAM_REGISTRY, a as DIAGRAM_SINCE, b as DiagramCluster, c as DiagramListItem, d as DiagramMeta, E as Example, G as GetExamplesOptions, e as GetExamplesResult, f as GetSyntaxOptions, g as GetSyntaxResult, R as RenderDslResult, h as SchematexValidationError, i as SyntaxDoc, V as ValidateDslResult, j as getAllDiagramTypes, k as getDiagramMeta, l as getDiagramSince, m as getExamples, n as getSyntax, o as listDiagrams, r as renderDsl, p as resolveDiagramType, v as validateDsl } from '../tools-
|
|
3
|
-
import { a as DiagramType } from '../diagnostics-
|
|
4
|
-
import '../api-
|
|
1
|
+
import { S as SyntaxDetail } from '../tools-DtuvE-K4.js';
|
|
2
|
+
export { D as DIAGRAM_REGISTRY, a as DIAGRAM_SINCE, b as DiagramCluster, c as DiagramListItem, d as DiagramMeta, E as Example, G as GetExamplesOptions, e as GetExamplesResult, f as GetSyntaxOptions, g as GetSyntaxResult, R as RenderDslResult, h as SchematexValidationError, i as SyntaxDoc, V as ValidateDslResult, j as getAllDiagramTypes, k as getDiagramMeta, l as getDiagramSince, m as getExamples, n as getSyntax, o as listDiagrams, r as renderDsl, p as resolveDiagramType, v as validateDsl } from '../tools-DtuvE-K4.js';
|
|
3
|
+
import { a as DiagramType } from '../diagnostics-DSxLohjY.js';
|
|
4
|
+
import '../api-C9ufsgIb.js';
|
|
5
5
|
|
|
6
6
|
interface BuildPromptContextOptions {
|
|
7
7
|
/** How many few-shot examples to embed. Default 2. Set 0 to omit examples. */
|
package/dist/ai/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { resolveDiagramType, getSyntax, getExamples } from '../chunk-
|
|
2
|
-
export { DIAGRAM_REGISTRY, DIAGRAM_SINCE, getAllDiagramTypes, getDiagramMeta, getDiagramSince, getExamples, getSyntax, listDiagrams, renderDsl, resolveDiagramType, validateDsl } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { resolveDiagramType, getSyntax, getExamples } from '../chunk-6KW7XSUR.js';
|
|
2
|
+
export { DIAGRAM_REGISTRY, DIAGRAM_SINCE, getAllDiagramTypes, getDiagramMeta, getDiagramSince, getExamples, getSyntax, listDiagrams, renderDsl, resolveDiagramType, validateDsl } from '../chunk-6KW7XSUR.js';
|
|
3
|
+
import '../chunk-JLLDJCLW.js';
|
|
4
4
|
import '../chunk-EB7T5SEO.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PGMKMIGM.js';
|
|
6
|
+
import '../chunk-32LOZTNP.js';
|
|
6
7
|
import '../chunk-P4U565XH.js';
|
|
7
8
|
import '../chunk-W4UVDMUC.js';
|
|
8
|
-
import '../chunk-
|
|
9
|
+
import '../chunk-Q5MQLUOH.js';
|
|
9
10
|
import '../chunk-2IRYXK4M.js';
|
|
10
11
|
import '../chunk-NP7N3DZG.js';
|
|
11
12
|
import '../chunk-KUSW5I2P.js';
|
package/dist/ai/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/prompt-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ai/prompt-context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CO,SAAS,kBAAA,CACd,IAAA,EACA,IAAA,GAAkC,EAAC,EACpB;AACf,EAAA,MAAM,QAAA,GAAW,kBAAA,CAAmB,IAAI,CAAA,IAAK,IAAA;AAC7C,EAAA,MAAM,MAAA,GAAuB,KAAK,MAAA,IAAU,WAAA;AAC5C,EAAA,MAAM,KAAA,GAAQ,KAAK,QAAA,IAAY,CAAA;AAE/B,EAAA,MAAM,EAAE,MAAM,SAAA,EAAW,IAAA,EAAM,UAAU,MAAA,EAAO,GAAI,UAAU,QAAA,EAAU;AAAA,IACtE;AAAA,GACD,CAAA;AAED,EAAA,MAAM,KAAA,GAAkB;AAAA,IACtB,CAAA,EAAA,EAAK,IAAI,CAAA,EAAA,EAAK,SAAS,CAAA,CAAA,CAAA;AAAA,IACvB,aAAa,QAAQ,CAAA,CAAA;AAAA,IACrB,EAAA;AAAA,IACA,MAAA,CAAO;AAAA,GACT;AAEA,EAAA,IAAI,YAAA,GAAe,CAAA;AACnB,EAAA,IAAI,QAAQ,CAAA,EAAG;AACb,IAAA,MAAM,QAAA,GAAW,YAAY,SAAA,EAAW;AAAA,MACtC,cAAA,EAAgB,KAAK,cAAA,IAAkB,IAAA;AAAA,MACvC,KAAA;AAAA,MACA,eAAe,IAAA,CAAK;AAAA,KACrB,CAAA,CAAE,QAAA;AACH,IAAA,YAAA,GAAe,QAAA,CAAS,MAAA;AACxB,IAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,MAAA,KAAA,CAAM,IAAA,CAAK,IAAI,oBAAoB,CAAA;AACnC,MAAA,KAAA,MAAW,MAAM,QAAA,EAAU;AACzB,QAAA,KAAA,CAAM,IAAA,CAAK,EAAA,EAAI,CAAA,IAAA,EAAO,EAAA,CAAG,KAAK,CAAA,CAAE,CAAA;AAChC,QAAA,IAAI,EAAA,CAAG,WAAA,EAAa,KAAA,CAAM,IAAA,CAAK,GAAG,WAAW,CAAA;AAC7C,QAAA,KAAA,CAAM,KAAK,KAAA,EAAO,EAAA,CAAG,GAAA,CAAI,IAAA,IAAQ,KAAK,CAAA;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,SAAA;AAAA,IACN,IAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA,EAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AAAA,IACrB;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * Prompt-context builder — a convenience wrapper for single-shot LLM callers.\n *\n * Agentic callers can keep using `getSyntax` + `getExamples` as separate tool\n * round-trips. But a high-volume single-shot caller (e.g. a product backend\n * generating DSL with one model call, no tool loop) just wants ONE inject-ready\n * block: the canonical grammar card plus a couple of worked few-shot examples.\n *\n * This adds no new knowledge — it stitches `getSyntax(detail: \"canonical\")` and\n * `getExamples(preferFeatured)` into one string so the caller doesn't have to\n * know the recipe. Both primitives remain exported and usable on their own.\n */\nimport { resolveDiagramType } from \"./registry\";\nimport { getExamples, getSyntax } from \"./tools\";\nimport type { SyntaxDetail } from \"./syntax\";\n\nexport interface BuildPromptContextOptions {\n /** How many few-shot examples to embed. Default 2. Set 0 to omit examples. */\n examples?: number;\n /** Syntax detail level. Default `\"canonical\"` (the compact first-shot card). */\n detail?: SyntaxDetail;\n /** Prefer `featured: true` examples first. Default true. */\n preferFeatured?: boolean;\n /** Cap embedded example complexity (1–5). */\n maxComplexity?: number;\n}\n\nexport interface PromptContext {\n type: string;\n name: string;\n standard: string;\n /** One inject-ready markdown block: grammar card + worked examples. */\n text: string;\n /** Number of examples embedded in `text`. */\n exampleCount: number;\n}\n\n/**\n * Build a single inject-ready prompt block for one diagram type.\n *\n * @example\n * const ctx = buildPromptContext(\"genogram\");\n * const systemPrompt = `Generate Schematex DSL.\\n\\n${ctx.text}`;\n */\nexport function buildPromptContext(\n type: string,\n opts: BuildPromptContextOptions = {}\n): PromptContext {\n const resolved = resolveDiagramType(type) ?? type;\n const detail: SyntaxDetail = opts.detail ?? \"canonical\";\n const limit = opts.examples ?? 2;\n\n const { type: canonical, name, standard, syntax } = getSyntax(resolved, {\n detail,\n });\n\n const parts: string[] = [\n `# ${name} (${canonical})`,\n `Standard: ${standard}`,\n \"\",\n syntax.content,\n ];\n\n let exampleCount = 0;\n if (limit > 0) {\n const examples = getExamples(canonical, {\n preferFeatured: opts.preferFeatured ?? true,\n limit,\n maxComplexity: opts.maxComplexity,\n }).examples;\n exampleCount = examples.length;\n if (examples.length > 0) {\n parts.push(\"\", \"## Worked examples\");\n for (const ex of examples) {\n parts.push(\"\", `### ${ex.title}`);\n if (ex.description) parts.push(ex.description);\n parts.push(\"```\", ex.dsl.trim(), \"```\");\n }\n }\n }\n\n return {\n type: canonical,\n name,\n standard,\n text: parts.join(\"\\n\"),\n exampleCount,\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as SchematexParseResult, c as SchematexRenderResult } from './diagnostics-
|
|
1
|
+
import { b as SchematexParseResult, c as SchematexRenderResult } from './diagnostics-DSxLohjY.js';
|
|
2
2
|
|
|
3
3
|
interface SchematexConfig {
|
|
4
|
-
type?: "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc" | "prisma" | "usecase" | "pert" | "sequence" | "petri" | "network" | "umlclass" | "faulttree" | "bowtie" | "rbd" | "floorplan" | "playbook";
|
|
4
|
+
type?: "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc" | "prisma" | "usecase" | "pert" | "sequence" | "petri" | "network" | "umlclass" | "faulttree" | "bowtie" | "rbd" | "floorplan" | "siteplan" | "playbook";
|
|
5
5
|
width?: number;
|
|
6
6
|
height?: number;
|
|
7
7
|
padding?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as SchematexParseResult, c as SchematexRenderResult } from './diagnostics-
|
|
1
|
+
import { b as SchematexParseResult, c as SchematexRenderResult } from './diagnostics-DSxLohjY.cjs';
|
|
2
2
|
|
|
3
3
|
interface SchematexConfig {
|
|
4
|
-
type?: "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc" | "prisma" | "usecase" | "pert" | "sequence" | "petri" | "network" | "umlclass" | "faulttree" | "bowtie" | "rbd" | "floorplan" | "playbook";
|
|
4
|
+
type?: "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc" | "prisma" | "usecase" | "pert" | "sequence" | "petri" | "network" | "umlclass" | "faulttree" | "bowtie" | "rbd" | "floorplan" | "siteplan" | "playbook";
|
|
5
5
|
width?: number;
|
|
6
6
|
height?: number;
|
|
7
7
|
padding?: number;
|
package/dist/browser.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMGMR6V6N_cjs = require('./chunk-MGMR6V6N.cjs');
|
|
4
4
|
require('./chunk-UHRNFBWY.cjs');
|
|
5
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-IBZKIMT5.cjs');
|
|
6
|
+
require('./chunk-HEGDKO2E.cjs');
|
|
6
7
|
require('./chunk-T55OQILI.cjs');
|
|
7
8
|
require('./chunk-GTCGATOL.cjs');
|
|
8
|
-
require('./chunk-
|
|
9
|
+
require('./chunk-OGF7QM74.cjs');
|
|
9
10
|
require('./chunk-4MANMKQ4.cjs');
|
|
10
11
|
require('./chunk-YFPDZVB7.cjs');
|
|
11
12
|
require('./chunk-3JN4762U.cjs');
|
|
@@ -26,10 +27,10 @@ require('./chunk-3WNW5Y7P.cjs');
|
|
|
26
27
|
|
|
27
28
|
// src/browser.ts
|
|
28
29
|
function renderToElement(text, config) {
|
|
29
|
-
return svgStringToElement(
|
|
30
|
+
return svgStringToElement(chunkMGMR6V6N_cjs.render(text, config));
|
|
30
31
|
}
|
|
31
32
|
function renderPreviewToElement(text, config) {
|
|
32
|
-
return svgStringToElement(
|
|
33
|
+
return svgStringToElement(chunkMGMR6V6N_cjs.renderPreview(text, config));
|
|
33
34
|
}
|
|
34
35
|
function svgStringToElement(svgString) {
|
|
35
36
|
const parser = new DOMParser();
|
|
@@ -42,23 +43,23 @@ function svgStringToElement(svgString) {
|
|
|
42
43
|
return el;
|
|
43
44
|
}
|
|
44
45
|
function renderToContainer(text, container, config) {
|
|
45
|
-
container.innerHTML =
|
|
46
|
+
container.innerHTML = chunkMGMR6V6N_cjs.render(text, config);
|
|
46
47
|
}
|
|
47
48
|
function renderPreviewToContainer(text, container, config) {
|
|
48
|
-
container.innerHTML =
|
|
49
|
+
container.innerHTML = chunkMGMR6V6N_cjs.renderPreview(text, config);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
Object.defineProperty(exports, "render", {
|
|
52
53
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkMGMR6V6N_cjs.render; }
|
|
54
55
|
});
|
|
55
56
|
Object.defineProperty(exports, "renderPreview", {
|
|
56
57
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkMGMR6V6N_cjs.renderPreview; }
|
|
58
59
|
});
|
|
59
60
|
Object.defineProperty(exports, "renderResult", {
|
|
60
61
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkMGMR6V6N_cjs.renderResult; }
|
|
62
63
|
});
|
|
63
64
|
exports.renderPreviewToContainer = renderPreviewToContainer;
|
|
64
65
|
exports.renderPreviewToElement = renderPreviewToElement;
|
package/dist/browser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/browser.ts"],"names":["render","renderPreview"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/browser.ts"],"names":["render","renderPreview"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBO,SAAS,eAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmBA,wBAAA,CAAO,IAAA,EAAM,MAAM,CAAC,CAAA;AAChD;AAOO,SAAS,sBAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmBC,+BAAA,CAAc,IAAA,EAAM,MAAM,CAAC,CAAA;AACvD;AAEA,SAAS,mBAAmB,SAAA,EAAkC;AAC5D,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,eAAA,CAAgB,SAAA,EAAW,eAAe,CAAA;AAC7D,EAAA,MAAM,KAAK,GAAA,CAAI,eAAA;AACf,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,aAAA,CAAc,aAAa,CAAA;AAClD,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,UAAA,CAAW,WAAW,CAAA,CAAE,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,EAAA;AACT;AAKO,SAAS,iBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAYD,wBAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AAC3C;AAGO,SAAS,wBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAYC,+BAAA,CAAc,IAAA,EAAM,MAAM,CAAA;AAClD","file":"browser.cjs","sourcesContent":["/**\n * Browser-specific utilities for Schematex.\n *\n * These APIs require a DOM environment. Do not import in SSR/Node contexts.\n *\n * @example\n * ```ts\n * import { renderToElement, renderToContainer } from 'schematex/browser';\n *\n * const svg = renderToElement('genogram\\n alice [female]');\n * document.getElementById('diagram')!.appendChild(svg);\n * ```\n */\n\nimport {\n render,\n renderPreview,\n type SchematexConfig,\n} from \"./core/api\";\n\n/**\n * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.\n */\nexport function renderToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(render(text, config));\n}\n\n/**\n * Render a live SVG element for an editing/AI-preview surface.\n *\n * Invalid DSL is represented as a diagnostic SVG instead of an empty surface.\n */\nexport function renderPreviewToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(renderPreview(text, config));\n}\n\nfunction svgStringToElement(svgString: string): SVGSVGElement {\n const parser = new DOMParser();\n const doc = parser.parseFromString(svgString, \"image/svg+xml\");\n const el = doc.documentElement;\n const parseError = doc.querySelector(\"parsererror\");\n if (parseError) {\n throw new Error(`SVG parse error: ${parseError.textContent}`);\n }\n return el as unknown as SVGSVGElement;\n}\n\n/**\n * Render DSL text and inject SVG into a container element (replaces innerHTML).\n */\nexport function renderToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = render(text, config);\n}\n\n/** Replace a preview container with an SVG or a visible diagnostic fallback. */\nexport function renderPreviewToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = renderPreview(text, config);\n}\n\nexport {\n render,\n renderPreview,\n renderResult,\n type SchematexConfig,\n} from \"./core/api\";\n"]}
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SchematexConfig } from './api-
|
|
2
|
-
export { r as render, b as renderPreview, c as renderResult } from './api-
|
|
3
|
-
import './diagnostics-
|
|
1
|
+
import { S as SchematexConfig } from './api-DAUFeETp.cjs';
|
|
2
|
+
export { r as render, b as renderPreview, c as renderResult } from './api-DAUFeETp.cjs';
|
|
3
|
+
import './diagnostics-DSxLohjY.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Browser-specific utilities for Schematex.
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SchematexConfig } from './api-
|
|
2
|
-
export { r as render, b as renderPreview, c as renderResult } from './api-
|
|
3
|
-
import './diagnostics-
|
|
1
|
+
import { S as SchematexConfig } from './api-C9ufsgIb.js';
|
|
2
|
+
export { r as render, b as renderPreview, c as renderResult } from './api-C9ufsgIb.js';
|
|
3
|
+
import './diagnostics-DSxLohjY.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Browser-specific utilities for Schematex.
|
package/dist/browser.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { render, renderPreview } from './chunk-
|
|
2
|
-
export { render, renderPreview, renderResult } from './chunk-
|
|
1
|
+
import { render, renderPreview } from './chunk-JLLDJCLW.js';
|
|
2
|
+
export { render, renderPreview, renderResult } from './chunk-JLLDJCLW.js';
|
|
3
3
|
import './chunk-EB7T5SEO.js';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-PGMKMIGM.js';
|
|
5
|
+
import './chunk-32LOZTNP.js';
|
|
5
6
|
import './chunk-P4U565XH.js';
|
|
6
7
|
import './chunk-W4UVDMUC.js';
|
|
7
|
-
import './chunk-
|
|
8
|
+
import './chunk-Q5MQLUOH.js';
|
|
8
9
|
import './chunk-2IRYXK4M.js';
|
|
9
10
|
import './chunk-NP7N3DZG.js';
|
|
10
11
|
import './chunk-KUSW5I2P.js';
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBO,SAAS,eAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmB,MAAA,CAAO,IAAA,EAAM,MAAM,CAAC,CAAA;AAChD;AAOO,SAAS,sBAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmB,aAAA,CAAc,IAAA,EAAM,MAAM,CAAC,CAAA;AACvD;AAEA,SAAS,mBAAmB,SAAA,EAAkC;AAC5D,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,eAAA,CAAgB,SAAA,EAAW,eAAe,CAAA;AAC7D,EAAA,MAAM,KAAK,GAAA,CAAI,eAAA;AACf,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,aAAA,CAAc,aAAa,CAAA;AAClD,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,UAAA,CAAW,WAAW,CAAA,CAAE,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,EAAA;AACT;AAKO,SAAS,iBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAY,MAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AAC3C;AAGO,SAAS,wBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAY,aAAA,CAAc,IAAA,EAAM,MAAM,CAAA;AAClD","file":"browser.js","sourcesContent":["/**\n * Browser-specific utilities for Schematex.\n *\n * These APIs require a DOM environment. Do not import in SSR/Node contexts.\n *\n * @example\n * ```ts\n * import { renderToElement, renderToContainer } from 'schematex/browser';\n *\n * const svg = renderToElement('genogram\\n alice [female]');\n * document.getElementById('diagram')!.appendChild(svg);\n * ```\n */\n\nimport {\n render,\n renderPreview,\n type SchematexConfig,\n} from \"./core/api\";\n\n/**\n * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.\n */\nexport function renderToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(render(text, config));\n}\n\n/**\n * Render a live SVG element for an editing/AI-preview surface.\n *\n * Invalid DSL is represented as a diagnostic SVG instead of an empty surface.\n */\nexport function renderPreviewToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(renderPreview(text, config));\n}\n\nfunction svgStringToElement(svgString: string): SVGSVGElement {\n const parser = new DOMParser();\n const doc = parser.parseFromString(svgString, \"image/svg+xml\");\n const el = doc.documentElement;\n const parseError = doc.querySelector(\"parsererror\");\n if (parseError) {\n throw new Error(`SVG parse error: ${parseError.textContent}`);\n }\n return el as unknown as SVGSVGElement;\n}\n\n/**\n * Render DSL text and inject SVG into a container element (replaces innerHTML).\n */\nexport function renderToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = render(text, config);\n}\n\n/** Replace a preview container with an SVG or a visible diagnostic fallback. */\nexport function renderPreviewToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = renderPreview(text, config);\n}\n\nexport {\n render,\n renderPreview,\n renderResult,\n type SchematexConfig,\n} from \"./core/api\";\n"]}
|