@golemui/gui-mcp 0.16.0 → 0.16.2
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/CHANGELOG.md +26 -0
- package/README.md +49 -5
- package/cli.js +76 -0
- package/{index.js → get-concept-CHgtnDXr.js} +1480 -1543
- package/lib.d.ts +7 -0
- package/lib.js +13 -0
- package/lint/reactive-expressions.d.ts +18 -0
- package/lint/string-interpolation.d.ts +16 -0
- package/mapping/json-schema-to-gui.d.ts +56 -0
- package/mapping/validator.d.ts +29 -0
- package/package.json +21 -11
- package/schemas/ajv.d.ts +5 -0
- package/schemas/index.d.ts +16 -0
- package/schemas/shallow-validators.d.ts +13 -0
- package/tools/generate-from-json-schema.d.ts +48 -0
- package/tools/generate-from-openapi.d.ts +81 -0
- package/tools/get-concept.d.ts +30 -0
- package/tools/get-widget-spec.d.ts +28 -0
- package/tools/validate-form-definition.d.ts +29 -0
- package/utils/errors.d.ts +28 -0
- /package/{index.d.ts → cli.d.ts} +0 -0
package/lib.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { validateFormDefinition, VALIDATE_FORM_DEFINITION_TOOL, } from './tools/validate-form-definition';
|
|
2
|
+
export type { ValidateInput, ValidateResult } from './tools/validate-form-definition';
|
|
3
|
+
export { generateFromJsonSchema, GENERATE_FROM_JSON_SCHEMA_TOOL, } from './tools/generate-from-json-schema';
|
|
4
|
+
export type { GenerateFromJsonSchemaInput, GenerateFromJsonSchemaResult, } from './tools/generate-from-json-schema';
|
|
5
|
+
export { generateFromOpenapi, GENERATE_FROM_OPENAPI_TOOL } from './tools/generate-from-openapi';
|
|
6
|
+
export { getWidgetSpec, GET_WIDGET_SPEC_TOOL } from './tools/get-widget-spec';
|
|
7
|
+
export { getConcept, GET_CONCEPT_TOOL } from './tools/get-concept';
|
package/lib.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { G, b, f, d, V, g, a, e, c, v } from "./get-concept-CHgtnDXr.js";
|
|
2
|
+
export {
|
|
3
|
+
G as GENERATE_FROM_JSON_SCHEMA_TOOL,
|
|
4
|
+
b as GENERATE_FROM_OPENAPI_TOOL,
|
|
5
|
+
f as GET_CONCEPT_TOOL,
|
|
6
|
+
d as GET_WIDGET_SPEC_TOOL,
|
|
7
|
+
V as VALIDATE_FORM_DEFINITION_TOOL,
|
|
8
|
+
g as generateFromJsonSchema,
|
|
9
|
+
a as generateFromOpenapi,
|
|
10
|
+
e as getConcept,
|
|
11
|
+
c as getWidgetSpec,
|
|
12
|
+
v as validateFormDefinition
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ExpressionFinding = {
|
|
2
|
+
path: string;
|
|
3
|
+
expression: string;
|
|
4
|
+
message: string;
|
|
5
|
+
suggestion?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Lints reactive expressions inside a form definition without executing them.
|
|
9
|
+
* GolemUI expressions are evaluated by the `subscript` package; here we only catch
|
|
10
|
+
* mistakes that are obvious from the syntax:
|
|
11
|
+
* - empty expressions
|
|
12
|
+
* - unbalanced parentheses / brackets / braces
|
|
13
|
+
* - missing `$form` prefix (LLMs sometimes write bare property names)
|
|
14
|
+
* - common operator typos (`=` instead of `===`, `&` instead of `&&`)
|
|
15
|
+
*
|
|
16
|
+
* We deliberately don't try to fully parse: too easy to get false positives, too little gain.
|
|
17
|
+
*/
|
|
18
|
+
export declare function lintReactiveExpressions(formDefinition: unknown): ExpressionFinding[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type InterpolationFinding = {
|
|
2
|
+
path: string;
|
|
3
|
+
slot: string;
|
|
4
|
+
message: string;
|
|
5
|
+
suggestion?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Lints `{{...}}` string interpolation templates inside a form definition without executing them.
|
|
9
|
+
* Catches mistakes that are obvious from the syntax:
|
|
10
|
+
* - empty slots
|
|
11
|
+
* - slots with no scope reference ($form, $meta, $errors, $formIsInvalid)
|
|
12
|
+
* - unbalanced `{{` / `}}` delimiters
|
|
13
|
+
* - assignment operator inside a slot (likely meant `===`)
|
|
14
|
+
* - nested `{{` inside a slot (copy-paste error)
|
|
15
|
+
*/
|
|
16
|
+
export declare function lintStringInterpolations(formDefinition: unknown): InterpolationFinding[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic mapping from a JSON Schema (the form-data shape) to a GolemUI form definition.
|
|
3
|
+
*
|
|
4
|
+
* Handles the practical 80% of API/Zod-derived schemas:
|
|
5
|
+
* - primitive properties (string/number/integer/boolean) with formats and constraints
|
|
6
|
+
* - enum strings as `select` (≤ 6 options) or `dropdown` (more)
|
|
7
|
+
* - nested objects rendered inline as `flex` layouts
|
|
8
|
+
* - arrays of objects as `repeater` with a `flex` template
|
|
9
|
+
*
|
|
10
|
+
* Constructs unmapped: anything we can't cleanly express. They're returned as `unmapped[]`
|
|
11
|
+
* so the caller (and any LLM) can surface a partial form rather than a hard failure.
|
|
12
|
+
*/
|
|
13
|
+
export type JsonSchemaLike = {
|
|
14
|
+
type?: string | string[];
|
|
15
|
+
format?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
enum?: unknown[];
|
|
19
|
+
const?: unknown;
|
|
20
|
+
minLength?: number;
|
|
21
|
+
maxLength?: number;
|
|
22
|
+
pattern?: string;
|
|
23
|
+
minimum?: number;
|
|
24
|
+
maximum?: number;
|
|
25
|
+
exclusiveMinimum?: number;
|
|
26
|
+
exclusiveMaximum?: number;
|
|
27
|
+
multipleOf?: number;
|
|
28
|
+
minItems?: number;
|
|
29
|
+
maxItems?: number;
|
|
30
|
+
uniqueItems?: boolean;
|
|
31
|
+
default?: unknown;
|
|
32
|
+
required?: string[];
|
|
33
|
+
properties?: Record<string, JsonSchemaLike>;
|
|
34
|
+
items?: JsonSchemaLike;
|
|
35
|
+
oneOf?: JsonSchemaLike[];
|
|
36
|
+
anyOf?: JsonSchemaLike[];
|
|
37
|
+
$ref?: string;
|
|
38
|
+
[k: string]: unknown;
|
|
39
|
+
};
|
|
40
|
+
export type MapOptions = {
|
|
41
|
+
submitAction?: boolean;
|
|
42
|
+
submitLabel?: string;
|
|
43
|
+
layout?: 'vertical' | 'horizontal' | 'grid';
|
|
44
|
+
};
|
|
45
|
+
export type Unmapped = {
|
|
46
|
+
path: string;
|
|
47
|
+
reason: string;
|
|
48
|
+
};
|
|
49
|
+
export type MapResult = {
|
|
50
|
+
formDefinition: {
|
|
51
|
+
$schema: string;
|
|
52
|
+
form: unknown[];
|
|
53
|
+
};
|
|
54
|
+
unmapped: Unmapped[];
|
|
55
|
+
};
|
|
56
|
+
export declare function jsonSchemaToGui(schema: JsonSchemaLike, opts?: MapOptions): MapResult;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { JsonSchemaLike } from './json-schema-to-gui';
|
|
2
|
+
export type StringValidator = {
|
|
3
|
+
type: 'string';
|
|
4
|
+
required?: boolean;
|
|
5
|
+
minLength?: number;
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
pattern?: string;
|
|
8
|
+
format?: string;
|
|
9
|
+
const?: unknown;
|
|
10
|
+
enum?: unknown[];
|
|
11
|
+
};
|
|
12
|
+
export type NumberValidator = {
|
|
13
|
+
type: 'number' | 'integer';
|
|
14
|
+
required?: boolean;
|
|
15
|
+
minimum?: number;
|
|
16
|
+
maximum?: number;
|
|
17
|
+
exclusiveMinimum?: number;
|
|
18
|
+
exclusiveMaximum?: number;
|
|
19
|
+
multipleOf?: number;
|
|
20
|
+
};
|
|
21
|
+
export type BooleanValidator = {
|
|
22
|
+
type: 'boolean';
|
|
23
|
+
required?: boolean;
|
|
24
|
+
const?: unknown;
|
|
25
|
+
};
|
|
26
|
+
export type Validator = StringValidator | NumberValidator | BooleanValidator;
|
|
27
|
+
export declare function buildStringValidator(s: JsonSchemaLike, required: boolean): StringValidator | undefined;
|
|
28
|
+
export declare function buildNumberValidator(s: JsonSchemaLike, required: boolean, t: 'number' | 'integer'): NumberValidator | undefined;
|
|
29
|
+
export declare function buildBooleanValidator(s: JsonSchemaLike, required: boolean): BooleanValidator | undefined;
|
package/package.json
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemui/gui-mcp",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Model Context Protocol server for GolemUI — gives AI coding assistants deterministic schema validation and form generation for GolemUI form definitions.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./
|
|
7
|
-
"module": "./
|
|
8
|
-
"types": "./
|
|
6
|
+
"main": "./lib.js",
|
|
7
|
+
"module": "./lib.js",
|
|
8
|
+
"types": "./lib.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./
|
|
12
|
-
"import": "./
|
|
11
|
+
"types": "./lib.d.ts",
|
|
12
|
+
"import": "./lib.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
|
-
"golemui-mcp": "./
|
|
16
|
+
"golemui-mcp": "./cli.js"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"*.js",
|
|
20
|
+
"*.d.ts",
|
|
21
|
+
"tools",
|
|
22
|
+
"mapping",
|
|
23
|
+
"schemas",
|
|
24
|
+
"utils",
|
|
25
|
+
"lint",
|
|
21
26
|
"*.md"
|
|
22
27
|
],
|
|
23
28
|
"keywords": [
|
|
@@ -29,10 +34,15 @@
|
|
|
29
34
|
"json-schema"
|
|
30
35
|
],
|
|
31
36
|
"dependencies": {
|
|
32
|
-
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
33
37
|
"ajv": "^8.17.1",
|
|
34
38
|
"ajv-formats": "^3.0.1",
|
|
35
|
-
"@golemui/gui-schemas": "0.16.
|
|
39
|
+
"@golemui/gui-schemas": "0.16.2"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
36
46
|
},
|
|
37
47
|
"engines": {
|
|
38
48
|
"node": ">=18.0.0"
|
package/schemas/ajv.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { default as Ajv2020 } from 'ajv/dist/2020.js';
|
|
2
|
+
export type AjvInstance = Ajv2020;
|
|
3
|
+
export declare function getAjv(): AjvInstance;
|
|
4
|
+
export declare function getFormValidator(): import('ajv/dist/types').AnyValidateFunction<unknown>;
|
|
5
|
+
export declare function getWidgetValidator(widgetSchemaId: string): import('ajv/dist/types').AnyValidateFunction<unknown> | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type WidgetSchema = {
|
|
2
|
+
$id: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
properties?: Record<string, unknown>;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const COMMON_SCHEMA: WidgetSchema;
|
|
8
|
+
export declare const FORM_SCHEMA: WidgetSchema;
|
|
9
|
+
export declare const LAYOUT_WIDGET_SCHEMA: WidgetSchema;
|
|
10
|
+
export declare const VALIDATORS_SCHEMA: WidgetSchema;
|
|
11
|
+
/**
|
|
12
|
+
* Component schemas, keyed by their widget `type` constant (the value of `properties.type.const`
|
|
13
|
+
* in each schema). These keys match the literal string a user puts in `type: '...'`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const COMPONENT_SCHEMAS: Record<string, WidgetSchema>;
|
|
16
|
+
export declare const ALL_SCHEMAS: WidgetSchema[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ValidateFunction } from 'ajv';
|
|
2
|
+
export declare function getValidatorBranches(): readonly string[];
|
|
3
|
+
/**
|
|
4
|
+
* Returns a validator that checks a GolemUI `validator` field against the branch corresponding
|
|
5
|
+
* to its `type` value (e.g. `type: 'string'` → stringValidator branch). Returns null if the
|
|
6
|
+
* validator's type isn't a known branch.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getValidatorBranchValidator(validatorType: string): ValidateFunction | null;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a validator for the given widget type that checks the widget's own properties without
|
|
11
|
+
* recursing into nested widgets. Returns null if the widget type is unknown.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getShallowWidgetValidator(widgetType: string): ValidateFunction | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { JsonSchemaLike } from '../mapping/json-schema-to-gui';
|
|
2
|
+
import { validateFormDefinition } from './validate-form-definition';
|
|
3
|
+
export type GenerateFromJsonSchemaInput = {
|
|
4
|
+
jsonSchema: JsonSchemaLike;
|
|
5
|
+
submitAction?: boolean;
|
|
6
|
+
submitLabel?: string;
|
|
7
|
+
layout?: 'vertical' | 'horizontal' | 'grid';
|
|
8
|
+
};
|
|
9
|
+
export type GenerateFromJsonSchemaResult = {
|
|
10
|
+
formDefinition: {
|
|
11
|
+
$schema: string;
|
|
12
|
+
form: unknown[];
|
|
13
|
+
};
|
|
14
|
+
unmapped: {
|
|
15
|
+
path: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
}[];
|
|
18
|
+
validation: ReturnType<typeof validateFormDefinition>;
|
|
19
|
+
};
|
|
20
|
+
export declare function generateFromJsonSchema(input: GenerateFromJsonSchemaInput): GenerateFromJsonSchemaResult;
|
|
21
|
+
export declare const GENERATE_FROM_JSON_SCHEMA_TOOL: {
|
|
22
|
+
readonly name: "generate_from_json_schema";
|
|
23
|
+
readonly description: string;
|
|
24
|
+
readonly inputSchema: {
|
|
25
|
+
readonly type: "object";
|
|
26
|
+
readonly properties: {
|
|
27
|
+
readonly jsonSchema: {
|
|
28
|
+
readonly type: "object";
|
|
29
|
+
readonly additionalProperties: true;
|
|
30
|
+
readonly description: string;
|
|
31
|
+
};
|
|
32
|
+
readonly submitAction: {
|
|
33
|
+
readonly type: "boolean";
|
|
34
|
+
readonly description: "Append a submit button. Defaults to true.";
|
|
35
|
+
};
|
|
36
|
+
readonly submitLabel: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly description: "Label for the submit button when `submitAction` is true. Defaults to \"Submit\".";
|
|
39
|
+
};
|
|
40
|
+
readonly layout: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
readonly enum: readonly ["vertical", "horizontal", "grid"];
|
|
43
|
+
readonly description: "Top-level layout. Defaults to vertical (one field per row).";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly required: readonly ["jsonSchema"];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { JsonSchemaLike } from '../mapping/json-schema-to-gui';
|
|
2
|
+
import { validateFormDefinition } from './validate-form-definition';
|
|
3
|
+
type OpenAPIDoc = {
|
|
4
|
+
openapi?: string;
|
|
5
|
+
components?: {
|
|
6
|
+
schemas?: Record<string, JsonSchemaLike>;
|
|
7
|
+
};
|
|
8
|
+
paths?: Record<string, Record<string, OpenAPIOperation>>;
|
|
9
|
+
};
|
|
10
|
+
type OpenAPIOperation = {
|
|
11
|
+
operationId?: string;
|
|
12
|
+
summary?: string;
|
|
13
|
+
requestBody?: {
|
|
14
|
+
content?: Record<string, {
|
|
15
|
+
schema?: JsonSchemaLike;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
parameters?: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
in: string;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
schema?: JsonSchemaLike;
|
|
23
|
+
description?: string;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
export type GenerateFromOpenapiInput = {
|
|
27
|
+
document?: OpenAPIDoc;
|
|
28
|
+
documentUrl?: string;
|
|
29
|
+
operation: string;
|
|
30
|
+
submitAction?: boolean;
|
|
31
|
+
submitLabel?: string;
|
|
32
|
+
};
|
|
33
|
+
export type GenerateFromOpenapiResult = {
|
|
34
|
+
resolvedOperation: {
|
|
35
|
+
method: string;
|
|
36
|
+
path: string;
|
|
37
|
+
operationId?: string;
|
|
38
|
+
};
|
|
39
|
+
formDefinition: {
|
|
40
|
+
$schema: string;
|
|
41
|
+
form: unknown[];
|
|
42
|
+
};
|
|
43
|
+
unmapped: {
|
|
44
|
+
path: string;
|
|
45
|
+
reason: string;
|
|
46
|
+
}[];
|
|
47
|
+
validation: ReturnType<typeof validateFormDefinition>;
|
|
48
|
+
};
|
|
49
|
+
export declare function generateFromOpenapi(input: GenerateFromOpenapiInput): Promise<GenerateFromOpenapiResult>;
|
|
50
|
+
export declare const GENERATE_FROM_OPENAPI_TOOL: {
|
|
51
|
+
readonly name: "generate_from_openapi";
|
|
52
|
+
readonly description: string;
|
|
53
|
+
readonly inputSchema: {
|
|
54
|
+
readonly type: "object";
|
|
55
|
+
readonly properties: {
|
|
56
|
+
readonly documentUrl: {
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
readonly description: "URL of a JSON OpenAPI document. Either this or `document` is required.";
|
|
59
|
+
};
|
|
60
|
+
readonly document: {
|
|
61
|
+
readonly type: "object";
|
|
62
|
+
readonly additionalProperties: true;
|
|
63
|
+
readonly description: "Parsed OpenAPI document (JSON object). Either this or `documentUrl` is required.";
|
|
64
|
+
};
|
|
65
|
+
readonly operation: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
readonly description: string;
|
|
68
|
+
};
|
|
69
|
+
readonly submitAction: {
|
|
70
|
+
readonly type: "boolean";
|
|
71
|
+
readonly description: "Append a submit button. Defaults to true.";
|
|
72
|
+
};
|
|
73
|
+
readonly submitLabel: {
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
readonly description: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly required: readonly ["operation"];
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type GetConceptInput = {
|
|
2
|
+
concept: string;
|
|
3
|
+
};
|
|
4
|
+
export type ConceptPattern = {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
example: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type GetConceptResult = {
|
|
10
|
+
concept: string;
|
|
11
|
+
summary: string;
|
|
12
|
+
patterns: ConceptPattern[];
|
|
13
|
+
rules: string[];
|
|
14
|
+
};
|
|
15
|
+
export declare function getConcept(input: GetConceptInput): GetConceptResult;
|
|
16
|
+
export declare const GET_CONCEPT_TOOL: {
|
|
17
|
+
readonly name: "get_concept";
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly inputSchema: {
|
|
20
|
+
readonly type: "object";
|
|
21
|
+
readonly properties: {
|
|
22
|
+
readonly concept: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "The concept to explain. Currently supported: `\"states\"`, `\"string-interpolation\"`.";
|
|
25
|
+
readonly enum: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly required: readonly ["concept"];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WidgetSchema } from '../schemas/index';
|
|
2
|
+
export type GetWidgetSpecInput = {
|
|
3
|
+
widgetType: string;
|
|
4
|
+
};
|
|
5
|
+
export type GetWidgetSpecResult = {
|
|
6
|
+
widgetType: string;
|
|
7
|
+
schema: WidgetSchema;
|
|
8
|
+
kind: string;
|
|
9
|
+
example: Record<string, unknown>;
|
|
10
|
+
notes: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function getWidgetSpec(input: GetWidgetSpecInput): GetWidgetSpecResult;
|
|
13
|
+
export declare function listWidgetTypes(): string[];
|
|
14
|
+
export declare function getValidatorsSchema(): WidgetSchema;
|
|
15
|
+
export declare const GET_WIDGET_SPEC_TOOL: {
|
|
16
|
+
readonly name: "get_widget_spec";
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly inputSchema: {
|
|
19
|
+
readonly type: "object";
|
|
20
|
+
readonly properties: {
|
|
21
|
+
readonly widgetType: {
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
readonly description: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly required: readonly ["widgetType"];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FormattedError } from '../utils/errors';
|
|
2
|
+
import { ExpressionFinding } from '../lint/reactive-expressions';
|
|
3
|
+
import { InterpolationFinding } from '../lint/string-interpolation';
|
|
4
|
+
export type ValidateInput = {
|
|
5
|
+
formDefinition: unknown;
|
|
6
|
+
};
|
|
7
|
+
export type ValidateResult = {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
errors: FormattedError[];
|
|
10
|
+
warnings: FormattedError[];
|
|
11
|
+
expressionWarnings: ExpressionFinding[];
|
|
12
|
+
interpolationWarnings: InterpolationFinding[];
|
|
13
|
+
};
|
|
14
|
+
export declare function validateFormDefinition(input: ValidateInput): ValidateResult;
|
|
15
|
+
export declare const VALIDATE_FORM_DEFINITION_TOOL: {
|
|
16
|
+
readonly name: "validate_form_definition";
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly inputSchema: {
|
|
19
|
+
readonly type: "object";
|
|
20
|
+
readonly properties: {
|
|
21
|
+
readonly formDefinition: {
|
|
22
|
+
readonly type: "object";
|
|
23
|
+
readonly additionalProperties: true;
|
|
24
|
+
readonly description: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly required: readonly ["formDefinition"];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ErrorObject } from 'ajv';
|
|
2
|
+
export type FormattedError = {
|
|
3
|
+
path: string;
|
|
4
|
+
message: string;
|
|
5
|
+
suggestion?: string;
|
|
6
|
+
keyword: string;
|
|
7
|
+
params?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export type FormattedResult = {
|
|
10
|
+
errors: FormattedError[];
|
|
11
|
+
warnings: FormattedError[];
|
|
12
|
+
};
|
|
13
|
+
declare const STRING_FORMATS: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Formats ajv error objects into AI-friendly messages with concrete fix suggestions.
|
|
16
|
+
* Designed for the case where an LLM produced the form and needs to self-correct on next turn.
|
|
17
|
+
*
|
|
18
|
+
* When `dataRoot` is provided, `oneOf` branches at widget positions are collapsed to just the
|
|
19
|
+
* closest-matching branch — without this, a single `type: 'buton'` typo emits ~30 errors (one per
|
|
20
|
+
* non-matching branch + a summary), most of which are noise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatAjvErrors(errors: ErrorObject[] | null | undefined, dataRoot?: unknown): FormattedResult;
|
|
23
|
+
/**
|
|
24
|
+
* Best-effort widget context: given a JSON Pointer path into a form definition, returns the
|
|
25
|
+
* widget's `type` if discoverable. Used to add "in widget X" context to error messages.
|
|
26
|
+
*/
|
|
27
|
+
export declare function describePath(path: string): string;
|
|
28
|
+
export { STRING_FORMATS };
|
/package/{index.d.ts → cli.d.ts}
RENAMED
|
File without changes
|