@golemui/gui-mcp 1.0.3 → 1.1.1-rc.0

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 CHANGED
@@ -1,3 +1,23 @@
1
+ ## 1.1.0 (2026-07-21)
2
+
3
+ ### 🚀 Features
4
+
5
+ - `$fn` host functions for reactive expressions ([#227](https://github.com/golemui/golemui/pull/227))
6
+ - range time and range date time inputs ([#225](https://github.com/golemui/golemui/pull/225))
7
+ - add $item / $index scope to repeater templates ([#222](https://github.com/golemui/golemui/pull/222))
8
+ - add time and date-time inputs and input error localizable messages ([#220](https://github.com/golemui/golemui/pull/220))
9
+ - add date time input ([#218](https://github.com/golemui/golemui/pull/218))
10
+ - add time input ([#217](https://github.com/golemui/golemui/pull/217))
11
+
12
+ ### ❤️ Thank You
13
+
14
+ - Mud Scientist @mudscientist
15
+ - Raúl Jiménez @Elecash
16
+
17
+ ## 1.0.3 (2026-07-02)
18
+
19
+ This was a version bump only for gui-mcp to align it with other projects, there were no code changes.
20
+
1
21
  ## 1.0.2 (2026-06-26)
2
22
 
3
23
  ### 🩹 Fixes
package/README.md CHANGED
@@ -68,6 +68,22 @@ npx -y @golemui/gui-mcp < /dev/null
68
68
  # → @golemui/gui-mcp v0.0.1 ready on stdio
69
69
  ```
70
70
 
71
+ ## CLI (no MCP client needed)
72
+
73
+ The two terminal checks are also plain subcommands of the same bin, so any shell — a CI
74
+ step, a git hook, or an AI agent without an MCP connector — can verify a form:
75
+
76
+ ```bash
77
+ npx -y @golemui/gui-mcp validate-json signup-form.json # JSON definition → bundled schemas
78
+ npx -y @golemui/gui-mcp check-dx src/forms/signup.ts # gui.* code → real @golemui types
79
+ npx -y @golemui/gui-mcp --help
80
+ ```
81
+
82
+ Each prints a single JSON result on stdout (the same shape as the corresponding MCP tool)
83
+ and exits `0` on pass, `1` when problems were found, `2` on usage or file errors. In
84
+ restricted environments, install it as a devDependency (`npm i -D @golemui/gui-mcp`) and the
85
+ same commands resolve the project-local bin with no network at run time.
86
+
71
87
  ## Tools
72
88
 
73
89
  ### `json_validate_form_definition`
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The `golemui-mcp` CLI subcommands — the same two terminal checks the MCP serves
3
+ * (`json_validate_form_definition`, `dx_check_code`), runnable as one-off shell
4
+ * commands (`npx -y @golemui/gui-mcp <cmd> <file>`) so agents can verify a form
5
+ * without an MCP connector. Designed for agentic use: non-interactive, structured
6
+ * JSON on stdout, diagnostics on stderr, documented exit codes.
7
+ *
8
+ * Exit codes: 0 = check passed · 1 = check found problems · 2 = usage/file error.
9
+ */
10
+ export interface CliIo {
11
+ out: (line: string) => void;
12
+ err: (line: string) => void;
13
+ }
14
+ /**
15
+ * Run one CLI subcommand. Returns the process exit code; never throws.
16
+ * `argv` is `process.argv.slice(2)`.
17
+ */
18
+ export declare function runCli(argv: string[], io?: CliIo): Promise<number>;
package/cli.js CHANGED
@@ -5,8 +5,89 @@ import { fileURLToPath } from "node:url";
5
5
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
6
6
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
7
  import { ListToolsRequestSchema, CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
8
- import { r as resolveDxFramework, f as listDxFactoriesCatalog, b as DX_LIST_FACTORIES_TOOL, g as getDxSpec, a as DX_GET_SPEC_TOOL, d as checkDxCode, D as DX_CHECK_CODE_TOOL } from "./list-dx-factories-C-Z5Sc5E.js";
9
- import { v as validateFormDefinition, c as JSON_VALIDATE_FORM_DEFINITION_TOOL, g as generateFromJsonSchema, a as JSON_GENERATE_FROM_SCHEMA_TOOL, d as generateFromOpenapi, J as JSON_GENERATE_FROM_OPENAPI_TOOL, f as getWidgetSpec, b as JSON_GET_WIDGET_SPEC_TOOL, e as getConcept, G as GET_CONCEPT_TOOL } from "./get-concept-Py3iLVmb.js";
8
+ import { d as checkDxCode, r as resolveDxFramework, f as listDxFactoriesCatalog, b as DX_LIST_FACTORIES_TOOL, g as getDxSpec, a as DX_GET_SPEC_TOOL, D as DX_CHECK_CODE_TOOL } from "./list-dx-factories-Dwy_BYZi.js";
9
+ import { v as validateFormDefinition, c as JSON_VALIDATE_FORM_DEFINITION_TOOL, g as generateFromJsonSchema, a as JSON_GENERATE_FROM_SCHEMA_TOOL, d as generateFromOpenapi, J as JSON_GENERATE_FROM_OPENAPI_TOOL, f as getWidgetSpec, b as JSON_GET_WIDGET_SPEC_TOOL, e as getConcept, G as GET_CONCEPT_TOOL } from "./get-concept-DRFSt-XX.js";
10
+ const USAGE = `Usage: golemui-mcp [command]
11
+
12
+ Validate GolemUI forms from the command line (no MCP client needed).
13
+ With no command, starts the MCP server on stdio.
14
+
15
+ Commands:
16
+ validate-json <file.json> Validate a JSON form definition ({ "form": [...] })
17
+ against the bundled GolemUI JSON Schemas.
18
+ check-dx <file.ts> Type-check a gui.* TypeScript snippet against the
19
+ real @golemui type declarations.
20
+ help, --help, -h Show this help.
21
+
22
+ Output: a single JSON result on stdout.
23
+ validate-json → { valid, errors, warnings, expressionWarnings, interpolationWarnings }
24
+ check-dx → { ok, diagnostics, expressionWarnings }
25
+
26
+ Exit codes: 0 = valid/ok · 1 = invalid (fix the reported problems and re-run) ·
27
+ 2 = usage or file error.
28
+
29
+ Examples:
30
+ npx -y @golemui/gui-mcp validate-json signup-form.json
31
+ npx -y @golemui/gui-mcp check-dx src/forms/signup.ts`;
32
+ function readFileOr2(path, what, io) {
33
+ if (!path) {
34
+ io.err(`Error: missing <file> argument — the path of the ${what} to check.`);
35
+ io.err(USAGE);
36
+ return 2;
37
+ }
38
+ try {
39
+ return readFileSync(path, "utf-8");
40
+ } catch (e) {
41
+ io.err(`Error: cannot read ${path}: ${e.message}`);
42
+ return 2;
43
+ }
44
+ }
45
+ const defaultIo = {
46
+ out: (line) => process.stdout.write(line + "\n"),
47
+ err: (line) => process.stderr.write(line + "\n")
48
+ };
49
+ async function runCli(argv, io = defaultIo) {
50
+ const [command, fileArg] = argv;
51
+ switch (command) {
52
+ case "help":
53
+ case "--help":
54
+ case "-h": {
55
+ io.out(USAGE);
56
+ return 0;
57
+ }
58
+ case "validate-json": {
59
+ const raw = readFileOr2(fileArg, "JSON form definition", io);
60
+ if (typeof raw === "number") return raw;
61
+ let formDefinition;
62
+ try {
63
+ formDefinition = JSON.parse(raw);
64
+ } catch (e) {
65
+ io.err(`Error: ${fileArg} is not valid JSON: ${e.message}`);
66
+ return 2;
67
+ }
68
+ const result = validateFormDefinition({ formDefinition });
69
+ io.out(JSON.stringify(result, null, 2));
70
+ return result.valid ? 0 : 1;
71
+ }
72
+ case "check-dx": {
73
+ const code = readFileOr2(fileArg, "gui.* TypeScript snippet", io);
74
+ if (typeof code === "number") return code;
75
+ try {
76
+ const result = await checkDxCode({ code });
77
+ io.out(JSON.stringify(result, null, 2));
78
+ return result.ok ? 0 : 1;
79
+ } catch (e) {
80
+ io.err(`Error: ${e.message}`);
81
+ return 2;
82
+ }
83
+ }
84
+ default: {
85
+ io.err(`Error: unknown command "${command}". Valid commands: validate-json, check-dx, help.`);
86
+ io.err(USAGE);
87
+ return 2;
88
+ }
89
+ }
90
+ }
10
91
  const DX_INSTRUCTIONS = "Writing GolemUI as DX code (the `gui.*` fluent builder in TypeScript) instead of a JSON definition? GolemUI is not in any model training data, so `gui.*` code is easy to fabricate — do NOT guess the API. FIRST call `dx_list_factories` once: it is the COMPLETE reference — every factory with its signature, a compile-verified example, and its gotchas, plus the cross-cutting patterns and common rules. Its imports + render snippet are tailored to your target framework (" + resolveDxFramework() + ") — use them verbatim; import `gui` ONLY from `@golemui/gui-shared`, never hand-write raw `{ kind, type, path }` widget JSON or cast to `any`. Keep it in context and write your whole form from it; it is self-sufficient for most forms. `dx_get_spec` is only a rare single-factory deep-dive — you usually will not need it, and you do NOT need `json_get_widget_spec` here (that is the JSON surface). Then ALWAYS finish by calling `dx_check_code` with the snippet — it type-checks against the real `@golemui` declarations and returns `{ ok, diagnostics }` (each with a fix `hint` for recognized mistakes). Treat `ok: false` as blocking: apply the fixes and re-check until `ok` is true. Use `dx_check_code` for `gui.*` *code* and `json_validate_form_definition` for a JSON *definition object* — they are not interchangeable.\n\n";
11
92
  function defineTool(tool, handler) {
12
93
  return { tool, run: (args) => handler(args) };
@@ -72,6 +153,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
72
153
  }
73
154
  });
74
155
  async function main() {
156
+ const argv = process.argv.slice(2);
157
+ if (argv.length > 0) {
158
+ process.exit(await runCli(argv));
159
+ }
75
160
  const transport = new StdioServerTransport();
76
161
  await server.connect(transport);
77
162
  process.stderr.write(`${PKG_NAME} v${PKG_VERSION} ready on stdio
package/dx/dx-specs.d.ts CHANGED
@@ -9,10 +9,13 @@
9
9
  * compile gate is the cure.)
10
10
  */
11
11
  export type DxNamespace = 'inputs' | 'actions' | 'displays' | 'layouts';
12
+ /** Widgets-reference URL group per namespace: `widgets-reference/<group>/<docSlug>.md`. */
13
+ export declare const DOC_GROUP: Record<DxNamespace, string>;
12
14
  export interface DxSpec {
13
15
  /** Factory name, e.g. `textInput`. */
14
16
  factory: string;
15
17
  namespace: DxNamespace;
18
+ docSlug: string;
16
19
  /** Human-readable calling convention. */
17
20
  call: string;
18
21
  /** A compiling `gui.*` snippet (verified by the suite). */
@@ -20,6 +23,8 @@ export interface DxSpec {
20
23
  /** Authoring notes and gotchas. */
21
24
  notes: string[];
22
25
  }
26
+ /** The absolute widgets-reference page URL for a factory (dx or json flavor). */
27
+ export declare function dxDocUrl(spec: DxSpec, dsl?: 'dx' | 'json'): string;
23
28
  /**
24
29
  * A cross-cutting authoring pattern that is NOT a single factory — e.g. conditional
25
30
  * visibility, which is a common field available on every `gui.*` item. Same compile
@@ -67,4 +72,11 @@ export interface DxCatalog {
67
72
  */
68
73
  export declare function dxCatalog(framework?: DxFramework): DxCatalog;
69
74
  export declare function dxCommonNote(framework?: DxFramework): string;
75
+ /**
76
+ * The per-framework host-wiring lines (imports + render + submit event), keyed by framework.
77
+ * The MCP serves one (selected by `GOLEMUI_FRAMEWORK`); the skill generator prints all five,
78
+ * since an installed skill serves whatever framework the host project uses.
79
+ */
80
+ export declare function dxFrameworkSetup(): Record<DxFramework, string>;
81
+ export declare function listDxFrameworks(): readonly DxFramework[];
70
82
  export declare function dxPatterns(): DxPattern[];