@agimon-ai/style-system 0.1.7 → 0.1.9
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/cli.cjs +95 -12
- package/dist/cli.mjs +95 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +11 -14
- package/dist/index.d.mts +11 -14
- package/dist/index.mjs +1 -1
- package/dist/{stdio-BO6EbC51.cjs → stdio-C2gi8JVm.cjs} +71 -159
- package/dist/{stdio-Be1LWyvL.mjs → stdio-n-SouxK6.mjs} +70 -158
- package/package.json +6 -3
package/dist/cli.cjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_stdio = require("./stdio-
|
|
2
|
+
const require_stdio = require("./stdio-C2gi8JVm.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_stdio.__toESM(node_path, 1);
|
|
6
|
+
let zod = require("zod");
|
|
6
7
|
let _agimon_ai_foundation_exec = require("@agimon-ai/foundation-exec");
|
|
8
|
+
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
7
9
|
require("reflect-metadata");
|
|
8
10
|
let commander = require("commander");
|
|
9
11
|
let chalk = require("chalk");
|
|
10
12
|
chalk = require_stdio.__toESM(chalk, 1);
|
|
13
|
+
let node_http = require("node:http");
|
|
14
|
+
let _modelcontextprotocol_node = require("@modelcontextprotocol/node");
|
|
11
15
|
//#region src/utils/print.ts
|
|
12
16
|
function resolveChalk(value, depth = 0) {
|
|
13
17
|
if (value && (typeof value === "object" || typeof value === "function") && "red" in value && typeof value.red === "function") return value;
|
|
@@ -243,13 +247,80 @@ const listSharedComponentsCommand = new commander.Command("list-shared-component
|
|
|
243
247
|
}
|
|
244
248
|
});
|
|
245
249
|
//#endregion
|
|
250
|
+
//#region src/transports/http.ts
|
|
251
|
+
/** Request-scoped modern Streamable HTTP. No legacy HTTP/SSE endpoint is registered. */
|
|
252
|
+
var HttpTransportHandler = class {
|
|
253
|
+
serverFactory;
|
|
254
|
+
host;
|
|
255
|
+
port;
|
|
256
|
+
server = null;
|
|
257
|
+
handler = null;
|
|
258
|
+
constructor(serverFactory, port, host = "localhost") {
|
|
259
|
+
this.serverFactory = serverFactory;
|
|
260
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error("Invalid HTTP port");
|
|
261
|
+
this.port = port;
|
|
262
|
+
this.host = host;
|
|
263
|
+
}
|
|
264
|
+
async start() {
|
|
265
|
+
if (this.server) throw new Error("MCP HTTP transport already running");
|
|
266
|
+
const handler = (0, _modelcontextprotocol_server.createMcpHandler)(this.serverFactory, { legacy: "reject" });
|
|
267
|
+
const serve = (0, _modelcontextprotocol_node.toNodeHandler)(handler);
|
|
268
|
+
const validateHost = (0, _modelcontextprotocol_node.localhostHostValidation)();
|
|
269
|
+
const validateOrigin = (0, _modelcontextprotocol_node.localhostOriginValidation)();
|
|
270
|
+
const loopback = [
|
|
271
|
+
"localhost",
|
|
272
|
+
"127.0.0.1",
|
|
273
|
+
"::1",
|
|
274
|
+
"[::1]"
|
|
275
|
+
].includes(this.host);
|
|
276
|
+
const server = (0, node_http.createServer)((req, res) => {
|
|
277
|
+
if (req.url?.split("?")[0] !== "/mcp" || ![
|
|
278
|
+
"POST",
|
|
279
|
+
"GET",
|
|
280
|
+
"DELETE"
|
|
281
|
+
].includes(req.method ?? "")) {
|
|
282
|
+
res.writeHead(404).end();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (loopback && (!validateHost(req, res) || !validateOrigin(req, res))) return;
|
|
286
|
+
serve(req, res).catch((error) => {
|
|
287
|
+
process.stderr.write(`MCP HTTP request failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
288
|
+
if (!res.headersSent) res.writeHead(500).end();
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
try {
|
|
292
|
+
await new Promise((resolve, reject) => {
|
|
293
|
+
server.once("error", reject);
|
|
294
|
+
server.listen(this.port, this.host, () => resolve());
|
|
295
|
+
});
|
|
296
|
+
this.server = server;
|
|
297
|
+
this.handler = handler;
|
|
298
|
+
} catch (error) {
|
|
299
|
+
await handler.close();
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async stop() {
|
|
304
|
+
const server = this.server;
|
|
305
|
+
this.server = null;
|
|
306
|
+
const handler = this.handler;
|
|
307
|
+
this.handler = null;
|
|
308
|
+
await handler?.close();
|
|
309
|
+
if (server) await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
|
|
310
|
+
}
|
|
311
|
+
getPort() {
|
|
312
|
+
const address = this.server?.address();
|
|
313
|
+
return address && typeof address !== "string" ? address.port : this.port;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
//#endregion
|
|
246
317
|
//#region src/commands/mcp-serve.ts
|
|
247
318
|
/**
|
|
248
319
|
* MCP Serve Command
|
|
249
320
|
*
|
|
250
321
|
* DESIGN PATTERNS:
|
|
251
322
|
* - Command pattern with Commander for CLI argument parsing
|
|
252
|
-
* - Transport abstraction pattern for
|
|
323
|
+
* - Transport abstraction pattern for modern stdio and HTTP
|
|
253
324
|
* - Factory pattern for creating transport handlers
|
|
254
325
|
* - Graceful shutdown pattern with signal handling
|
|
255
326
|
*
|
|
@@ -283,7 +354,9 @@ async function startServer(handler, bundlerService, devServerPort) {
|
|
|
283
354
|
releasePortOnRelease: false,
|
|
284
355
|
metadata: devServerPort ? { devServerPort } : {}
|
|
285
356
|
});
|
|
286
|
-
} catch {
|
|
357
|
+
} catch (error) {
|
|
358
|
+
console.error("Process registry unavailable:", error);
|
|
359
|
+
}
|
|
287
360
|
const shutdown = async (signal) => {
|
|
288
361
|
console.error(`\nReceived ${signal}, shutting down gracefully...`);
|
|
289
362
|
try {
|
|
@@ -308,27 +381,37 @@ async function startServer(handler, bundlerService, devServerPort) {
|
|
|
308
381
|
* Note: Design system configuration is now app-specific and read from each app's project.json.
|
|
309
382
|
* No global theme configuration is needed at the server level.
|
|
310
383
|
*/
|
|
311
|
-
const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio", "stdio").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
|
|
384
|
+
const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio or http", "stdio").option("-p, --port <port>", "HTTP port (required for HTTP)").option("--host <host>", "HTTP bind host", "localhost").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
|
|
312
385
|
try {
|
|
313
|
-
const
|
|
386
|
+
const parsed = zod.z.object({
|
|
387
|
+
type: zod.z.enum(["stdio", "http"]),
|
|
388
|
+
port: zod.z.coerce.number().int().min(0).max(65535).optional(),
|
|
389
|
+
host: zod.z.string().min(1),
|
|
390
|
+
themePath: zod.z.string().optional(),
|
|
391
|
+
dev: zod.z.boolean().optional(),
|
|
392
|
+
appPath: zod.z.string().optional()
|
|
393
|
+
}).parse(options);
|
|
394
|
+
const transportType = parsed.type;
|
|
314
395
|
let devServerPort;
|
|
315
396
|
const bundlerService = await require_stdio.getBundlerServiceFromConfig();
|
|
316
|
-
if (
|
|
317
|
-
if (!
|
|
397
|
+
if (parsed.dev) {
|
|
398
|
+
if (!parsed.appPath) {
|
|
318
399
|
console.error("Error: --app-path is required when using --dev flag");
|
|
319
400
|
console.error(`Example: ${require_stdio.STYLE_SYSTEM_CLI_NAME} mcp-serve --dev --app-path apps/agiflow-app`);
|
|
320
401
|
process.exit(1);
|
|
321
402
|
}
|
|
322
|
-
const { url, port } = await bundlerService.startDevServer(
|
|
403
|
+
const { url, port } = await bundlerService.startDevServer(parsed.appPath);
|
|
323
404
|
devServerPort = port;
|
|
324
405
|
console.error(`Dev server started at ${url} (port: ${port})`);
|
|
325
406
|
}
|
|
326
407
|
if (transportType === "stdio") {
|
|
327
|
-
const container = require_stdio.createContainer({ defaultThemePath:
|
|
328
|
-
|
|
329
|
-
|
|
408
|
+
const container = require_stdio.createContainer({ defaultThemePath: parsed.themePath });
|
|
409
|
+
await startServer(new require_stdio.StdioTransportHandler(() => require_stdio.createServer(container)), bundlerService, devServerPort);
|
|
410
|
+
} else if (transportType === "http" && parsed.port !== void 0) {
|
|
411
|
+
const container = require_stdio.createContainer({ defaultThemePath: parsed.themePath });
|
|
412
|
+
await startServer(new HttpTransportHandler(() => require_stdio.createServer(container), parsed.port, parsed.host), bundlerService, devServerPort);
|
|
330
413
|
} else {
|
|
331
|
-
console.error(
|
|
414
|
+
console.error("HTTP requires --port");
|
|
332
415
|
process.exit(1);
|
|
333
416
|
}
|
|
334
417
|
} catch (error) {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, L as log, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, a as STYLE_SYSTEM_CLI_NAME, b as getBundlerServiceFromConfig, i as createServer, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler } from "./stdio-
|
|
2
|
+
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, L as log, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, a as STYLE_SYSTEM_CLI_NAME, b as getBundlerServiceFromConfig, i as createServer$1, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler } from "./stdio-n-SouxK6.mjs";
|
|
3
3
|
import { promises } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
5
6
|
import { registerManagedProcess } from "@agimon-ai/foundation-exec";
|
|
7
|
+
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
6
8
|
import "reflect-metadata";
|
|
7
9
|
import { Command } from "commander";
|
|
8
10
|
import * as chalkImport from "chalk";
|
|
11
|
+
import { createServer } from "node:http";
|
|
12
|
+
import { localhostHostValidation, localhostOriginValidation, toNodeHandler } from "@modelcontextprotocol/node";
|
|
9
13
|
//#region src/utils/print.ts
|
|
10
14
|
function resolveChalk(value, depth = 0) {
|
|
11
15
|
if (value && (typeof value === "object" || typeof value === "function") && "red" in value && typeof value.red === "function") return value;
|
|
@@ -241,13 +245,80 @@ const listSharedComponentsCommand = new Command("list-shared-components").descri
|
|
|
241
245
|
}
|
|
242
246
|
});
|
|
243
247
|
//#endregion
|
|
248
|
+
//#region src/transports/http.ts
|
|
249
|
+
/** Request-scoped modern Streamable HTTP. No legacy HTTP/SSE endpoint is registered. */
|
|
250
|
+
var HttpTransportHandler = class {
|
|
251
|
+
serverFactory;
|
|
252
|
+
host;
|
|
253
|
+
port;
|
|
254
|
+
server = null;
|
|
255
|
+
handler = null;
|
|
256
|
+
constructor(serverFactory, port, host = "localhost") {
|
|
257
|
+
this.serverFactory = serverFactory;
|
|
258
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error("Invalid HTTP port");
|
|
259
|
+
this.port = port;
|
|
260
|
+
this.host = host;
|
|
261
|
+
}
|
|
262
|
+
async start() {
|
|
263
|
+
if (this.server) throw new Error("MCP HTTP transport already running");
|
|
264
|
+
const handler = createMcpHandler(this.serverFactory, { legacy: "reject" });
|
|
265
|
+
const serve = toNodeHandler(handler);
|
|
266
|
+
const validateHost = localhostHostValidation();
|
|
267
|
+
const validateOrigin = localhostOriginValidation();
|
|
268
|
+
const loopback = [
|
|
269
|
+
"localhost",
|
|
270
|
+
"127.0.0.1",
|
|
271
|
+
"::1",
|
|
272
|
+
"[::1]"
|
|
273
|
+
].includes(this.host);
|
|
274
|
+
const server = createServer((req, res) => {
|
|
275
|
+
if (req.url?.split("?")[0] !== "/mcp" || ![
|
|
276
|
+
"POST",
|
|
277
|
+
"GET",
|
|
278
|
+
"DELETE"
|
|
279
|
+
].includes(req.method ?? "")) {
|
|
280
|
+
res.writeHead(404).end();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (loopback && (!validateHost(req, res) || !validateOrigin(req, res))) return;
|
|
284
|
+
serve(req, res).catch((error) => {
|
|
285
|
+
process.stderr.write(`MCP HTTP request failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
286
|
+
if (!res.headersSent) res.writeHead(500).end();
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
try {
|
|
290
|
+
await new Promise((resolve, reject) => {
|
|
291
|
+
server.once("error", reject);
|
|
292
|
+
server.listen(this.port, this.host, () => resolve());
|
|
293
|
+
});
|
|
294
|
+
this.server = server;
|
|
295
|
+
this.handler = handler;
|
|
296
|
+
} catch (error) {
|
|
297
|
+
await handler.close();
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
async stop() {
|
|
302
|
+
const server = this.server;
|
|
303
|
+
this.server = null;
|
|
304
|
+
const handler = this.handler;
|
|
305
|
+
this.handler = null;
|
|
306
|
+
await handler?.close();
|
|
307
|
+
if (server) await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
|
|
308
|
+
}
|
|
309
|
+
getPort() {
|
|
310
|
+
const address = this.server?.address();
|
|
311
|
+
return address && typeof address !== "string" ? address.port : this.port;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
//#endregion
|
|
244
315
|
//#region src/commands/mcp-serve.ts
|
|
245
316
|
/**
|
|
246
317
|
* MCP Serve Command
|
|
247
318
|
*
|
|
248
319
|
* DESIGN PATTERNS:
|
|
249
320
|
* - Command pattern with Commander for CLI argument parsing
|
|
250
|
-
* - Transport abstraction pattern for
|
|
321
|
+
* - Transport abstraction pattern for modern stdio and HTTP
|
|
251
322
|
* - Factory pattern for creating transport handlers
|
|
252
323
|
* - Graceful shutdown pattern with signal handling
|
|
253
324
|
*
|
|
@@ -281,7 +352,9 @@ async function startServer(handler, bundlerService, devServerPort) {
|
|
|
281
352
|
releasePortOnRelease: false,
|
|
282
353
|
metadata: devServerPort ? { devServerPort } : {}
|
|
283
354
|
});
|
|
284
|
-
} catch {
|
|
355
|
+
} catch (error) {
|
|
356
|
+
console.error("Process registry unavailable:", error);
|
|
357
|
+
}
|
|
285
358
|
const shutdown = async (signal) => {
|
|
286
359
|
console.error(`\nReceived ${signal}, shutting down gracefully...`);
|
|
287
360
|
try {
|
|
@@ -306,27 +379,37 @@ async function startServer(handler, bundlerService, devServerPort) {
|
|
|
306
379
|
* Note: Design system configuration is now app-specific and read from each app's project.json.
|
|
307
380
|
* No global theme configuration is needed at the server level.
|
|
308
381
|
*/
|
|
309
|
-
const mcpServeCommand = new Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio", "stdio").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
|
|
382
|
+
const mcpServeCommand = new Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio or http", "stdio").option("-p, --port <port>", "HTTP port (required for HTTP)").option("--host <host>", "HTTP bind host", "localhost").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
|
|
310
383
|
try {
|
|
311
|
-
const
|
|
384
|
+
const parsed = z.object({
|
|
385
|
+
type: z.enum(["stdio", "http"]),
|
|
386
|
+
port: z.coerce.number().int().min(0).max(65535).optional(),
|
|
387
|
+
host: z.string().min(1),
|
|
388
|
+
themePath: z.string().optional(),
|
|
389
|
+
dev: z.boolean().optional(),
|
|
390
|
+
appPath: z.string().optional()
|
|
391
|
+
}).parse(options);
|
|
392
|
+
const transportType = parsed.type;
|
|
312
393
|
let devServerPort;
|
|
313
394
|
const bundlerService = await getBundlerServiceFromConfig();
|
|
314
|
-
if (
|
|
315
|
-
if (!
|
|
395
|
+
if (parsed.dev) {
|
|
396
|
+
if (!parsed.appPath) {
|
|
316
397
|
console.error("Error: --app-path is required when using --dev flag");
|
|
317
398
|
console.error(`Example: ${STYLE_SYSTEM_CLI_NAME} mcp-serve --dev --app-path apps/agiflow-app`);
|
|
318
399
|
process.exit(1);
|
|
319
400
|
}
|
|
320
|
-
const { url, port } = await bundlerService.startDevServer(
|
|
401
|
+
const { url, port } = await bundlerService.startDevServer(parsed.appPath);
|
|
321
402
|
devServerPort = port;
|
|
322
403
|
console.error(`Dev server started at ${url} (port: ${port})`);
|
|
323
404
|
}
|
|
324
405
|
if (transportType === "stdio") {
|
|
325
|
-
const container = createContainer({ defaultThemePath:
|
|
326
|
-
|
|
327
|
-
|
|
406
|
+
const container = createContainer({ defaultThemePath: parsed.themePath });
|
|
407
|
+
await startServer(new StdioTransportHandler(() => createServer$1(container)), bundlerService, devServerPort);
|
|
408
|
+
} else if (transportType === "http" && parsed.port !== void 0) {
|
|
409
|
+
const container = createContainer({ defaultThemePath: parsed.themePath });
|
|
410
|
+
await startServer(new HttpTransportHandler(() => createServer$1(container), parsed.port, parsed.host), bundlerService, devServerPort);
|
|
328
411
|
} else {
|
|
329
|
-
console.error(
|
|
412
|
+
console.error("HTTP requires --port");
|
|
330
413
|
process.exit(1);
|
|
331
414
|
}
|
|
332
415
|
} catch (error) {
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_stdio = require("./stdio-
|
|
2
|
+
const require_stdio = require("./stdio-C2gi8JVm.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_stdio.__toESM(node_path, 1);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Container, ContainerModule } from "inversify";
|
|
2
2
|
import "zod";
|
|
3
|
-
import { Server } from "@modelcontextprotocol/
|
|
3
|
+
import { CallToolResult, Server } from "@modelcontextprotocol/server";
|
|
4
4
|
import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
5
|
-
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
6
5
|
//#region src/container/module.d.ts
|
|
7
6
|
interface StyleSystemModuleOptions {
|
|
8
7
|
defaultThemePath?: string;
|
|
@@ -126,12 +125,12 @@ declare class StyleSystemConfigLoader {
|
|
|
126
125
|
* Promises rather than values, so concurrent resolves de-duplicate. Several
|
|
127
126
|
* callers hit config from inside Promise.all/allSettled.
|
|
128
127
|
*/
|
|
129
|
-
private
|
|
128
|
+
private readonly rootPromises;
|
|
130
129
|
private readonly projectCache;
|
|
131
130
|
/** Drop all cached config state. */
|
|
132
131
|
invalidate(): void;
|
|
133
132
|
/** Load and cache the workspace root config. */
|
|
134
|
-
loadRoot(): Promise<StyleSystemRootConfig>;
|
|
133
|
+
loadRoot(workspaceRoot?: string): Promise<StyleSystemRootConfig>;
|
|
135
134
|
/** Resolve the merged configuration for a project. */
|
|
136
135
|
resolveProject(appPath: string): Promise<ResolvedDesignSystemConfig>;
|
|
137
136
|
private readRoot;
|
|
@@ -1620,8 +1619,8 @@ interface ToolDefinition {
|
|
|
1620
1619
|
name: string;
|
|
1621
1620
|
description: string;
|
|
1622
1621
|
inputSchema: {
|
|
1623
|
-
type:
|
|
1624
|
-
properties: Record<string,
|
|
1622
|
+
type: 'object';
|
|
1623
|
+
properties: Record<string, Record<string, unknown>>;
|
|
1625
1624
|
required?: string[];
|
|
1626
1625
|
additionalProperties?: boolean;
|
|
1627
1626
|
};
|
|
@@ -1630,7 +1629,7 @@ interface ToolDefinition {
|
|
|
1630
1629
|
/**
|
|
1631
1630
|
* Base tool interface following MCP SDK patterns
|
|
1632
1631
|
*/
|
|
1633
|
-
interface Tool<TInput =
|
|
1632
|
+
interface Tool<TInput = unknown> {
|
|
1634
1633
|
getDefinition(): ToolDefinition;
|
|
1635
1634
|
execute(input: TInput): Promise<CallToolResult>;
|
|
1636
1635
|
}
|
|
@@ -1998,14 +1997,12 @@ declare class PolishComponentTool implements Tool<PolishComponentInput> {
|
|
|
1998
1997
|
}
|
|
1999
1998
|
//#endregion
|
|
2000
1999
|
//#region src/transports/stdio.d.ts
|
|
2001
|
-
/**
|
|
2002
|
-
* Stdio transport handler for MCP server
|
|
2003
|
-
* Used for command-line and direct integrations
|
|
2004
|
-
*/
|
|
2000
|
+
/** Modern MCP stdio only: reject legacy initialization explicitly. */
|
|
2005
2001
|
declare class StdioTransportHandler {
|
|
2006
|
-
private
|
|
2007
|
-
private
|
|
2008
|
-
|
|
2002
|
+
private readonly factory;
|
|
2003
|
+
private handle;
|
|
2004
|
+
private started;
|
|
2005
|
+
constructor(server: Server | (() => Server));
|
|
2009
2006
|
start(): Promise<void>;
|
|
2010
2007
|
stop(): Promise<void>;
|
|
2011
2008
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Container, ContainerModule } from "inversify";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { Server } from "@modelcontextprotocol/
|
|
4
|
-
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { CallToolResult, Server } from "@modelcontextprotocol/server";
|
|
5
4
|
import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
6
5
|
//#region src/container/module.d.ts
|
|
7
6
|
interface StyleSystemModuleOptions {
|
|
@@ -126,12 +125,12 @@ declare class StyleSystemConfigLoader {
|
|
|
126
125
|
* Promises rather than values, so concurrent resolves de-duplicate. Several
|
|
127
126
|
* callers hit config from inside Promise.all/allSettled.
|
|
128
127
|
*/
|
|
129
|
-
private
|
|
128
|
+
private readonly rootPromises;
|
|
130
129
|
private readonly projectCache;
|
|
131
130
|
/** Drop all cached config state. */
|
|
132
131
|
invalidate(): void;
|
|
133
132
|
/** Load and cache the workspace root config. */
|
|
134
|
-
loadRoot(): Promise<StyleSystemRootConfig>;
|
|
133
|
+
loadRoot(workspaceRoot?: string): Promise<StyleSystemRootConfig>;
|
|
135
134
|
/** Resolve the merged configuration for a project. */
|
|
136
135
|
resolveProject(appPath: string): Promise<ResolvedDesignSystemConfig>;
|
|
137
136
|
private readRoot;
|
|
@@ -1620,8 +1619,8 @@ interface ToolDefinition {
|
|
|
1620
1619
|
name: string;
|
|
1621
1620
|
description: string;
|
|
1622
1621
|
inputSchema: {
|
|
1623
|
-
type:
|
|
1624
|
-
properties: Record<string,
|
|
1622
|
+
type: 'object';
|
|
1623
|
+
properties: Record<string, Record<string, unknown>>;
|
|
1625
1624
|
required?: string[];
|
|
1626
1625
|
additionalProperties?: boolean;
|
|
1627
1626
|
};
|
|
@@ -1630,7 +1629,7 @@ interface ToolDefinition {
|
|
|
1630
1629
|
/**
|
|
1631
1630
|
* Base tool interface following MCP SDK patterns
|
|
1632
1631
|
*/
|
|
1633
|
-
interface Tool<TInput =
|
|
1632
|
+
interface Tool<TInput = unknown> {
|
|
1634
1633
|
getDefinition(): ToolDefinition;
|
|
1635
1634
|
execute(input: TInput): Promise<CallToolResult>;
|
|
1636
1635
|
}
|
|
@@ -1998,14 +1997,12 @@ declare class PolishComponentTool implements Tool<PolishComponentInput> {
|
|
|
1998
1997
|
}
|
|
1999
1998
|
//#endregion
|
|
2000
1999
|
//#region src/transports/stdio.d.ts
|
|
2001
|
-
/**
|
|
2002
|
-
* Stdio transport handler for MCP server
|
|
2003
|
-
* Used for command-line and direct integrations
|
|
2004
|
-
*/
|
|
2000
|
+
/** Modern MCP stdio only: reject legacy initialization explicitly. */
|
|
2005
2001
|
declare class StdioTransportHandler {
|
|
2006
|
-
private
|
|
2007
|
-
private
|
|
2008
|
-
|
|
2002
|
+
private readonly factory;
|
|
2003
|
+
private handle;
|
|
2004
|
+
private started;
|
|
2005
|
+
constructor(server: Server | (() => Server));
|
|
2009
2006
|
start(): Promise<void>;
|
|
2010
2007
|
stop(): Promise<void>;
|
|
2011
2008
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-
|
|
1
|
+
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-n-SouxK6.mjs";
|
|
2
2
|
import { promises } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -50,9 +50,8 @@ let _vitejs_plugin_react = require("@vitejs/plugin-react");
|
|
|
50
50
|
_vitejs_plugin_react = __toESM(_vitejs_plugin_react, 1);
|
|
51
51
|
let node_child_process = require("node:child_process");
|
|
52
52
|
let _agimon_ai_foundation_exec = require("@agimon-ai/foundation-exec");
|
|
53
|
-
let
|
|
54
|
-
let
|
|
55
|
-
let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
53
|
+
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
54
|
+
let _modelcontextprotocol_server_stdio = require("@modelcontextprotocol/server/stdio");
|
|
56
55
|
//#region src/services/ThemeService/BaseThemeService.ts
|
|
57
56
|
/**
|
|
58
57
|
* BaseThemeService
|
|
@@ -1329,8 +1328,9 @@ const EXPO_APP_CONFIG_FILE = "app.json";
|
|
|
1329
1328
|
* values, and warns when it is the one that resolves.
|
|
1330
1329
|
*/
|
|
1331
1330
|
async function resolveStyleSystemThemePath(input) {
|
|
1332
|
-
const
|
|
1333
|
-
const resolvedAppPath = input.appPath ? node_path.default.isAbsolute(input.appPath) ? input.appPath : node_path.default.join(
|
|
1331
|
+
const hostRoot = TemplatesManagerService.getWorkspaceRootSync();
|
|
1332
|
+
const resolvedAppPath = input.appPath ? node_path.default.isAbsolute(input.appPath) ? node_path.default.normalize(input.appPath) : node_path.default.join(hostRoot, input.appPath) : hostRoot;
|
|
1333
|
+
const monorepoRoot = input.appPath ? TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath) : hostRoot;
|
|
1334
1334
|
const workspaceCandidate = node_path.default.join(monorepoRoot, input.themePath);
|
|
1335
1335
|
const candidates = node_path.default.isAbsolute(input.themePath) ? [input.themePath] : [workspaceCandidate, node_path.default.resolve(resolvedAppPath, input.themePath)];
|
|
1336
1336
|
const uniqueCandidates = [...new Set(candidates)];
|
|
@@ -1384,26 +1384,35 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1384
1384
|
* Promises rather than values, so concurrent resolves de-duplicate. Several
|
|
1385
1385
|
* callers hit config from inside Promise.all/allSettled.
|
|
1386
1386
|
*/
|
|
1387
|
-
|
|
1387
|
+
rootPromises = /* @__PURE__ */ new Map();
|
|
1388
1388
|
projectCache = /* @__PURE__ */ new Map();
|
|
1389
1389
|
/** Drop all cached config state. */
|
|
1390
1390
|
invalidate() {
|
|
1391
|
-
this.
|
|
1391
|
+
this.rootPromises.clear();
|
|
1392
1392
|
this.projectCache.clear();
|
|
1393
1393
|
}
|
|
1394
1394
|
/** Load and cache the workspace root config. */
|
|
1395
|
-
async loadRoot() {
|
|
1396
|
-
|
|
1397
|
-
|
|
1395
|
+
async loadRoot(workspaceRoot = TemplatesManagerService.getWorkspaceRootSync()) {
|
|
1396
|
+
let pending = this.rootPromises.get(workspaceRoot);
|
|
1397
|
+
if (!pending) {
|
|
1398
|
+
pending = this.readRoot(workspaceRoot);
|
|
1399
|
+
this.rootPromises.set(workspaceRoot, pending);
|
|
1400
|
+
}
|
|
1401
|
+
try {
|
|
1402
|
+
return await pending;
|
|
1403
|
+
} catch (error) {
|
|
1404
|
+
if (this.rootPromises.get(workspaceRoot) === pending) this.rootPromises.delete(workspaceRoot);
|
|
1405
|
+
throw error;
|
|
1406
|
+
}
|
|
1398
1407
|
}
|
|
1399
1408
|
/** Resolve the merged configuration for a project. */
|
|
1400
1409
|
async resolveProject(appPath) {
|
|
1401
1410
|
if (!appPath || typeof appPath !== "string") throw new Error("appPath is required and must be a non-empty string");
|
|
1402
|
-
const
|
|
1403
|
-
const
|
|
1411
|
+
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? node_path.default.normalize(appPath) : node_path.default.join(TemplatesManagerService.getWorkspaceRootSync(), appPath);
|
|
1412
|
+
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath);
|
|
1404
1413
|
const cached = this.projectCache.get(resolvedAppPath);
|
|
1405
1414
|
if (cached) return cached;
|
|
1406
|
-
const pending = this.readProject(resolvedAppPath);
|
|
1415
|
+
const pending = this.readProject(resolvedAppPath, workspaceRoot);
|
|
1407
1416
|
this.projectCache.set(resolvedAppPath, pending);
|
|
1408
1417
|
try {
|
|
1409
1418
|
return await pending;
|
|
@@ -1412,8 +1421,7 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1412
1421
|
throw error;
|
|
1413
1422
|
}
|
|
1414
1423
|
}
|
|
1415
|
-
async readRoot() {
|
|
1416
|
-
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync();
|
|
1424
|
+
async readRoot(workspaceRoot) {
|
|
1417
1425
|
const configPath = node_path.default.join(workspaceRoot, STYLE_SYSTEM_CONFIG_FILE);
|
|
1418
1426
|
let content;
|
|
1419
1427
|
try {
|
|
@@ -1429,9 +1437,9 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1429
1437
|
log.info(`[Config] Loaded workspace style-system config from ${configPath}`);
|
|
1430
1438
|
return parsed;
|
|
1431
1439
|
}
|
|
1432
|
-
async readProject(resolvedAppPath) {
|
|
1440
|
+
async readProject(resolvedAppPath, workspaceRoot) {
|
|
1433
1441
|
if (!(await node_fs.promises.stat(resolvedAppPath).catch(() => null))?.isDirectory()) throw new Error(`Project directory not found: ${resolvedAppPath}`);
|
|
1434
|
-
const rootConfig = await this.loadRoot();
|
|
1442
|
+
const rootConfig = await this.loadRoot(workspaceRoot);
|
|
1435
1443
|
const projectConfigPath = node_path.default.join(resolvedAppPath, STYLE_SYSTEM_CONFIG_FILE);
|
|
1436
1444
|
const projectName = node_path.default.basename(resolvedAppPath);
|
|
1437
1445
|
let rawProjectConfig = null;
|
|
@@ -4006,26 +4014,6 @@ AppComponentsService = __decorate([
|
|
|
4006
4014
|
], AppComponentsService);
|
|
4007
4015
|
//#endregion
|
|
4008
4016
|
//#region src/tools/ListThemesTool.ts
|
|
4009
|
-
/**
|
|
4010
|
-
* ListThemesTool
|
|
4011
|
-
*
|
|
4012
|
-
* DESIGN PATTERNS:
|
|
4013
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4014
|
-
* - Factory pattern for service creation
|
|
4015
|
-
* - JSON Schema validation for inputs
|
|
4016
|
-
*
|
|
4017
|
-
* CODING STANDARDS:
|
|
4018
|
-
* - Implement Tool interface from ../types
|
|
4019
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'list_themes')
|
|
4020
|
-
* - Return CallToolResult with content array
|
|
4021
|
-
* - Handle errors with isError flag
|
|
4022
|
-
* - Delegate complex logic to services
|
|
4023
|
-
*
|
|
4024
|
-
* AVOID:
|
|
4025
|
-
* - Complex business logic in execute method
|
|
4026
|
-
* - Unhandled promise rejections
|
|
4027
|
-
* - Missing input validation
|
|
4028
|
-
*/
|
|
4029
4017
|
var _ListThemesTool;
|
|
4030
4018
|
let ListThemesTool = class ListThemesTool {
|
|
4031
4019
|
static {
|
|
@@ -4088,26 +4076,6 @@ ListThemesTool = _ListThemesTool = __decorate([
|
|
|
4088
4076
|
], ListThemesTool);
|
|
4089
4077
|
//#endregion
|
|
4090
4078
|
//#region src/tools/GetCSSClassesTool.ts
|
|
4091
|
-
/**
|
|
4092
|
-
* GetCSSClassesTool
|
|
4093
|
-
*
|
|
4094
|
-
* DESIGN PATTERNS:
|
|
4095
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4096
|
-
* - Service delegation for business logic via factory pattern
|
|
4097
|
-
* - JSON Schema validation for inputs
|
|
4098
|
-
*
|
|
4099
|
-
* CODING STANDARDS:
|
|
4100
|
-
* - Implement Tool interface from ../types
|
|
4101
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'get_css_classes')
|
|
4102
|
-
* - Return CallToolResult with content array
|
|
4103
|
-
* - Handle errors with isError flag
|
|
4104
|
-
* - Delegate complex logic to services
|
|
4105
|
-
*
|
|
4106
|
-
* AVOID:
|
|
4107
|
-
* - Complex business logic in execute method
|
|
4108
|
-
* - Unhandled promise rejections
|
|
4109
|
-
* - Missing input validation
|
|
4110
|
-
*/
|
|
4111
4079
|
var _GetCSSClassesTool;
|
|
4112
4080
|
/**
|
|
4113
4081
|
* Valid CSS class category values
|
|
@@ -4380,26 +4348,6 @@ var AntigravityCliService = class {
|
|
|
4380
4348
|
};
|
|
4381
4349
|
//#endregion
|
|
4382
4350
|
//#region src/tools/GetComponentVisualTool.ts
|
|
4383
|
-
/**
|
|
4384
|
-
* GetComponentVisualTool
|
|
4385
|
-
*
|
|
4386
|
-
* DESIGN PATTERNS:
|
|
4387
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4388
|
-
* - Service delegation for business logic
|
|
4389
|
-
* - JSON Schema validation for inputs
|
|
4390
|
-
*
|
|
4391
|
-
* CODING STANDARDS:
|
|
4392
|
-
* - Implement Tool interface from ../types
|
|
4393
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'get_component_visual')
|
|
4394
|
-
* - Return CallToolResult with content array
|
|
4395
|
-
* - Handle errors with isError flag
|
|
4396
|
-
* - Delegate complex logic to services
|
|
4397
|
-
*
|
|
4398
|
-
* AVOID:
|
|
4399
|
-
* - Complex business logic in execute method
|
|
4400
|
-
* - Unhandled promise rejections
|
|
4401
|
-
* - Missing input validation
|
|
4402
|
-
*/
|
|
4403
4351
|
var _GetComponentVisualTool;
|
|
4404
4352
|
/**
|
|
4405
4353
|
* Template for visual review instructions returned with component screenshots.
|
|
@@ -4522,26 +4470,6 @@ GetComponentVisualTool = _GetComponentVisualTool = __decorate([
|
|
|
4522
4470
|
], GetComponentVisualTool);
|
|
4523
4471
|
//#endregion
|
|
4524
4472
|
//#region src/tools/ListSharedComponentsTool.ts
|
|
4525
|
-
/**
|
|
4526
|
-
* ListSharedComponentsTool
|
|
4527
|
-
*
|
|
4528
|
-
* DESIGN PATTERNS:
|
|
4529
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4530
|
-
* - Service delegation for business logic
|
|
4531
|
-
* - JSON Schema validation for inputs
|
|
4532
|
-
*
|
|
4533
|
-
* CODING STANDARDS:
|
|
4534
|
-
* - Implement Tool interface from ../types
|
|
4535
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'list_shared_components')
|
|
4536
|
-
* - Return CallToolResult with content array
|
|
4537
|
-
* - Handle errors with isError flag
|
|
4538
|
-
* - Delegate complex logic to services
|
|
4539
|
-
*
|
|
4540
|
-
* AVOID:
|
|
4541
|
-
* - Complex business logic in execute method
|
|
4542
|
-
* - Unhandled promise rejections
|
|
4543
|
-
* - Missing input validation
|
|
4544
|
-
*/
|
|
4545
4473
|
var _ListSharedComponentsTool;
|
|
4546
4474
|
let ListSharedComponentsTool = class ListSharedComponentsTool {
|
|
4547
4475
|
static {
|
|
@@ -4652,26 +4580,6 @@ ListSharedComponentsTool = _ListSharedComponentsTool = __decorate([
|
|
|
4652
4580
|
], ListSharedComponentsTool);
|
|
4653
4581
|
//#endregion
|
|
4654
4582
|
//#region src/tools/ListAppComponentsTool.ts
|
|
4655
|
-
/**
|
|
4656
|
-
* ListAppComponentsTool
|
|
4657
|
-
*
|
|
4658
|
-
* DESIGN PATTERNS:
|
|
4659
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4660
|
-
* - Service delegation for business logic
|
|
4661
|
-
* - JSON Schema validation for inputs
|
|
4662
|
-
*
|
|
4663
|
-
* CODING STANDARDS:
|
|
4664
|
-
* - Implement Tool interface from ../types
|
|
4665
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'list_app_components')
|
|
4666
|
-
* - Return CallToolResult with content array
|
|
4667
|
-
* - Handle errors with isError flag
|
|
4668
|
-
* - Delegate complex logic to services
|
|
4669
|
-
*
|
|
4670
|
-
* AVOID:
|
|
4671
|
-
* - Complex business logic in execute method
|
|
4672
|
-
* - Unhandled promise rejections
|
|
4673
|
-
* - Missing input validation
|
|
4674
|
-
*/
|
|
4675
4583
|
var _ListAppComponentsTool;
|
|
4676
4584
|
let ListAppComponentsTool = class ListAppComponentsTool {
|
|
4677
4585
|
static {
|
|
@@ -5055,7 +4963,7 @@ function createContainer(options) {
|
|
|
5055
4963
|
}
|
|
5056
4964
|
//#endregion
|
|
5057
4965
|
//#region package.json
|
|
5058
|
-
var version = "0.1.
|
|
4966
|
+
var version = "0.1.8";
|
|
5059
4967
|
//#endregion
|
|
5060
4968
|
//#region src/metadata.ts
|
|
5061
4969
|
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
|
@@ -5077,7 +4985,7 @@ function createServer(containerOrThemePath) {
|
|
|
5077
4985
|
let container;
|
|
5078
4986
|
if (!containerOrThemePath || typeof containerOrThemePath === "string") container = createContainer({ defaultThemePath: containerOrThemePath });
|
|
5079
4987
|
else container = containerOrThemePath;
|
|
5080
|
-
const server = new
|
|
4988
|
+
const server = new _modelcontextprotocol_server.Server({
|
|
5081
4989
|
name: STYLE_SYSTEM_SERVER_NAME,
|
|
5082
4990
|
version: STYLE_SYSTEM_VERSION
|
|
5083
4991
|
}, {
|
|
@@ -5090,7 +4998,7 @@ function createServer(containerOrThemePath) {
|
|
|
5090
4998
|
const listSharedComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListSharedComponentsTool);
|
|
5091
4999
|
const listAppComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListAppComponentsTool);
|
|
5092
5000
|
const polishComponentTool = container.get(STYLE_SYSTEM_TYPES.PolishComponentTool);
|
|
5093
|
-
server.setRequestHandler(
|
|
5001
|
+
server.setRequestHandler("tools/list", async () => {
|
|
5094
5002
|
return { tools: [
|
|
5095
5003
|
withCapabilities(listThemesTool.getDefinition(), [
|
|
5096
5004
|
"themes",
|
|
@@ -5124,23 +5032,45 @@ function createServer(containerOrThemePath) {
|
|
|
5124
5032
|
"polish",
|
|
5125
5033
|
"antigravity"
|
|
5126
5034
|
])
|
|
5127
|
-
]
|
|
5035
|
+
].map((tool) => {
|
|
5036
|
+
if (tool.inputSchema.type !== "object") throw new Error(`Invalid schema for ${tool.name}`);
|
|
5037
|
+
return {
|
|
5038
|
+
...tool,
|
|
5039
|
+
inputSchema: tool.inputSchema
|
|
5040
|
+
};
|
|
5041
|
+
}) };
|
|
5128
5042
|
});
|
|
5129
|
-
server.setRequestHandler(
|
|
5043
|
+
server.setRequestHandler("tools/call", async (request) => {
|
|
5130
5044
|
const { name, arguments: args } = request.params;
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5045
|
+
const tool = [
|
|
5046
|
+
listThemesTool,
|
|
5047
|
+
getCSSClassesTool,
|
|
5048
|
+
getComponentVisualTool,
|
|
5049
|
+
listSharedComponentsTool,
|
|
5050
|
+
listAppComponentsTool,
|
|
5051
|
+
polishComponentTool
|
|
5052
|
+
].find((candidate) => candidate.getDefinition().name === name);
|
|
5053
|
+
if (!tool) return {
|
|
5138
5054
|
content: [{
|
|
5139
5055
|
type: "text",
|
|
5140
|
-
text: `
|
|
5056
|
+
text: `Unknown tool: ${name}`
|
|
5141
5057
|
}],
|
|
5142
5058
|
isError: true
|
|
5143
5059
|
};
|
|
5060
|
+
try {
|
|
5061
|
+
const definition = tool.getDefinition();
|
|
5062
|
+
if (definition.inputSchema.type !== "object") throw new Error(`Invalid schema for ${name}`);
|
|
5063
|
+
const input = zod.z.fromJSONSchema(definition.inputSchema).parse(args ?? {});
|
|
5064
|
+
return await tool.execute(input);
|
|
5065
|
+
} catch (error) {
|
|
5066
|
+
return {
|
|
5067
|
+
content: [{
|
|
5068
|
+
type: "text",
|
|
5069
|
+
text: error instanceof Error ? error.message : String(error)
|
|
5070
|
+
}],
|
|
5071
|
+
isError: true
|
|
5072
|
+
};
|
|
5073
|
+
}
|
|
5144
5074
|
});
|
|
5145
5075
|
return server;
|
|
5146
5076
|
}
|
|
@@ -5284,42 +5214,24 @@ function generateRestrictedClassesConfig(cssResult) {
|
|
|
5284
5214
|
}
|
|
5285
5215
|
//#endregion
|
|
5286
5216
|
//#region src/transports/stdio.ts
|
|
5287
|
-
/**
|
|
5288
|
-
* STDIO Transport
|
|
5289
|
-
*
|
|
5290
|
-
* DESIGN PATTERNS:
|
|
5291
|
-
* - Transport handler pattern implementing TransportHandler interface
|
|
5292
|
-
* - Standard I/O based communication for CLI usage
|
|
5293
|
-
*
|
|
5294
|
-
* CODING STANDARDS:
|
|
5295
|
-
* - Initialize server and transport properly
|
|
5296
|
-
* - Handle cleanup on shutdown with stop() method
|
|
5297
|
-
* - Use async/await for all operations
|
|
5298
|
-
*
|
|
5299
|
-
* AVOID:
|
|
5300
|
-
* - Forgetting to close transport on shutdown
|
|
5301
|
-
* - Missing error handling for connection failures
|
|
5302
|
-
*/
|
|
5303
|
-
/**
|
|
5304
|
-
* Stdio transport handler for MCP server
|
|
5305
|
-
* Used for command-line and direct integrations
|
|
5306
|
-
*/
|
|
5217
|
+
/** Modern MCP stdio only: reject legacy initialization explicitly. */
|
|
5307
5218
|
var StdioTransportHandler = class {
|
|
5308
|
-
|
|
5309
|
-
|
|
5219
|
+
factory;
|
|
5220
|
+
handle = null;
|
|
5221
|
+
started = false;
|
|
5310
5222
|
constructor(server) {
|
|
5311
|
-
this.
|
|
5223
|
+
this.factory = typeof server === "function" ? server : () => server;
|
|
5312
5224
|
}
|
|
5313
5225
|
async start() {
|
|
5314
|
-
this.
|
|
5315
|
-
|
|
5226
|
+
if (this.handle || this.started) throw new Error("style-system stdio server already started");
|
|
5227
|
+
this.handle = (0, _modelcontextprotocol_server_stdio.serveStdio)(this.factory, { legacy: "reject" });
|
|
5228
|
+
this.started = true;
|
|
5316
5229
|
log.info(`${STYLE_SYSTEM_SERVER_NAME} MCP server started on stdio`);
|
|
5317
5230
|
}
|
|
5318
5231
|
async stop() {
|
|
5319
|
-
if (this.
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
}
|
|
5232
|
+
if (!this.handle) return;
|
|
5233
|
+
await this.handle.close();
|
|
5234
|
+
this.handle = null;
|
|
5323
5235
|
}
|
|
5324
5236
|
};
|
|
5325
5237
|
//#endregion
|
|
@@ -21,9 +21,8 @@ import { fileURLToPath } from "node:url";
|
|
|
21
21
|
import react from "@vitejs/plugin-react";
|
|
22
22
|
import { execSync, spawn } from "node:child_process";
|
|
23
23
|
import { registerManagedProcess } from "@agimon-ai/foundation-exec";
|
|
24
|
-
import { Server } from "@modelcontextprotocol/
|
|
25
|
-
import {
|
|
26
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
24
|
+
import { Server } from "@modelcontextprotocol/server";
|
|
25
|
+
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
27
26
|
//#region \0rolldown/runtime.js
|
|
28
27
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
29
28
|
//#endregion
|
|
@@ -1303,8 +1302,9 @@ const EXPO_APP_CONFIG_FILE = "app.json";
|
|
|
1303
1302
|
* values, and warns when it is the one that resolves.
|
|
1304
1303
|
*/
|
|
1305
1304
|
async function resolveStyleSystemThemePath(input) {
|
|
1306
|
-
const
|
|
1307
|
-
const resolvedAppPath = input.appPath ? path.isAbsolute(input.appPath) ? input.appPath : path.join(
|
|
1305
|
+
const hostRoot = TemplatesManagerService.getWorkspaceRootSync();
|
|
1306
|
+
const resolvedAppPath = input.appPath ? path.isAbsolute(input.appPath) ? path.normalize(input.appPath) : path.join(hostRoot, input.appPath) : hostRoot;
|
|
1307
|
+
const monorepoRoot = input.appPath ? TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath) : hostRoot;
|
|
1308
1308
|
const workspaceCandidate = path.join(monorepoRoot, input.themePath);
|
|
1309
1309
|
const candidates = path.isAbsolute(input.themePath) ? [input.themePath] : [workspaceCandidate, path.resolve(resolvedAppPath, input.themePath)];
|
|
1310
1310
|
const uniqueCandidates = [...new Set(candidates)];
|
|
@@ -1358,26 +1358,35 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1358
1358
|
* Promises rather than values, so concurrent resolves de-duplicate. Several
|
|
1359
1359
|
* callers hit config from inside Promise.all/allSettled.
|
|
1360
1360
|
*/
|
|
1361
|
-
|
|
1361
|
+
rootPromises = /* @__PURE__ */ new Map();
|
|
1362
1362
|
projectCache = /* @__PURE__ */ new Map();
|
|
1363
1363
|
/** Drop all cached config state. */
|
|
1364
1364
|
invalidate() {
|
|
1365
|
-
this.
|
|
1365
|
+
this.rootPromises.clear();
|
|
1366
1366
|
this.projectCache.clear();
|
|
1367
1367
|
}
|
|
1368
1368
|
/** Load and cache the workspace root config. */
|
|
1369
|
-
async loadRoot() {
|
|
1370
|
-
|
|
1371
|
-
|
|
1369
|
+
async loadRoot(workspaceRoot = TemplatesManagerService.getWorkspaceRootSync()) {
|
|
1370
|
+
let pending = this.rootPromises.get(workspaceRoot);
|
|
1371
|
+
if (!pending) {
|
|
1372
|
+
pending = this.readRoot(workspaceRoot);
|
|
1373
|
+
this.rootPromises.set(workspaceRoot, pending);
|
|
1374
|
+
}
|
|
1375
|
+
try {
|
|
1376
|
+
return await pending;
|
|
1377
|
+
} catch (error) {
|
|
1378
|
+
if (this.rootPromises.get(workspaceRoot) === pending) this.rootPromises.delete(workspaceRoot);
|
|
1379
|
+
throw error;
|
|
1380
|
+
}
|
|
1372
1381
|
}
|
|
1373
1382
|
/** Resolve the merged configuration for a project. */
|
|
1374
1383
|
async resolveProject(appPath) {
|
|
1375
1384
|
if (!appPath || typeof appPath !== "string") throw new Error("appPath is required and must be a non-empty string");
|
|
1376
|
-
const
|
|
1377
|
-
const
|
|
1385
|
+
const resolvedAppPath = path.isAbsolute(appPath) ? path.normalize(appPath) : path.join(TemplatesManagerService.getWorkspaceRootSync(), appPath);
|
|
1386
|
+
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath);
|
|
1378
1387
|
const cached = this.projectCache.get(resolvedAppPath);
|
|
1379
1388
|
if (cached) return cached;
|
|
1380
|
-
const pending = this.readProject(resolvedAppPath);
|
|
1389
|
+
const pending = this.readProject(resolvedAppPath, workspaceRoot);
|
|
1381
1390
|
this.projectCache.set(resolvedAppPath, pending);
|
|
1382
1391
|
try {
|
|
1383
1392
|
return await pending;
|
|
@@ -1386,8 +1395,7 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1386
1395
|
throw error;
|
|
1387
1396
|
}
|
|
1388
1397
|
}
|
|
1389
|
-
async readRoot() {
|
|
1390
|
-
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync();
|
|
1398
|
+
async readRoot(workspaceRoot) {
|
|
1391
1399
|
const configPath = path.join(workspaceRoot, STYLE_SYSTEM_CONFIG_FILE);
|
|
1392
1400
|
let content;
|
|
1393
1401
|
try {
|
|
@@ -1403,9 +1411,9 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1403
1411
|
log.info(`[Config] Loaded workspace style-system config from ${configPath}`);
|
|
1404
1412
|
return parsed;
|
|
1405
1413
|
}
|
|
1406
|
-
async readProject(resolvedAppPath) {
|
|
1414
|
+
async readProject(resolvedAppPath, workspaceRoot) {
|
|
1407
1415
|
if (!(await promises.stat(resolvedAppPath).catch(() => null))?.isDirectory()) throw new Error(`Project directory not found: ${resolvedAppPath}`);
|
|
1408
|
-
const rootConfig = await this.loadRoot();
|
|
1416
|
+
const rootConfig = await this.loadRoot(workspaceRoot);
|
|
1409
1417
|
const projectConfigPath = path.join(resolvedAppPath, STYLE_SYSTEM_CONFIG_FILE);
|
|
1410
1418
|
const projectName = path.basename(resolvedAppPath);
|
|
1411
1419
|
let rawProjectConfig = null;
|
|
@@ -3980,26 +3988,6 @@ AppComponentsService = __decorate([
|
|
|
3980
3988
|
], AppComponentsService);
|
|
3981
3989
|
//#endregion
|
|
3982
3990
|
//#region src/tools/ListThemesTool.ts
|
|
3983
|
-
/**
|
|
3984
|
-
* ListThemesTool
|
|
3985
|
-
*
|
|
3986
|
-
* DESIGN PATTERNS:
|
|
3987
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
3988
|
-
* - Factory pattern for service creation
|
|
3989
|
-
* - JSON Schema validation for inputs
|
|
3990
|
-
*
|
|
3991
|
-
* CODING STANDARDS:
|
|
3992
|
-
* - Implement Tool interface from ../types
|
|
3993
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'list_themes')
|
|
3994
|
-
* - Return CallToolResult with content array
|
|
3995
|
-
* - Handle errors with isError flag
|
|
3996
|
-
* - Delegate complex logic to services
|
|
3997
|
-
*
|
|
3998
|
-
* AVOID:
|
|
3999
|
-
* - Complex business logic in execute method
|
|
4000
|
-
* - Unhandled promise rejections
|
|
4001
|
-
* - Missing input validation
|
|
4002
|
-
*/
|
|
4003
3991
|
var _ListThemesTool;
|
|
4004
3992
|
let ListThemesTool = class ListThemesTool {
|
|
4005
3993
|
static {
|
|
@@ -4062,26 +4050,6 @@ ListThemesTool = _ListThemesTool = __decorate([
|
|
|
4062
4050
|
], ListThemesTool);
|
|
4063
4051
|
//#endregion
|
|
4064
4052
|
//#region src/tools/GetCSSClassesTool.ts
|
|
4065
|
-
/**
|
|
4066
|
-
* GetCSSClassesTool
|
|
4067
|
-
*
|
|
4068
|
-
* DESIGN PATTERNS:
|
|
4069
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4070
|
-
* - Service delegation for business logic via factory pattern
|
|
4071
|
-
* - JSON Schema validation for inputs
|
|
4072
|
-
*
|
|
4073
|
-
* CODING STANDARDS:
|
|
4074
|
-
* - Implement Tool interface from ../types
|
|
4075
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'get_css_classes')
|
|
4076
|
-
* - Return CallToolResult with content array
|
|
4077
|
-
* - Handle errors with isError flag
|
|
4078
|
-
* - Delegate complex logic to services
|
|
4079
|
-
*
|
|
4080
|
-
* AVOID:
|
|
4081
|
-
* - Complex business logic in execute method
|
|
4082
|
-
* - Unhandled promise rejections
|
|
4083
|
-
* - Missing input validation
|
|
4084
|
-
*/
|
|
4085
4053
|
var _GetCSSClassesTool;
|
|
4086
4054
|
/**
|
|
4087
4055
|
* Valid CSS class category values
|
|
@@ -4354,26 +4322,6 @@ var AntigravityCliService = class {
|
|
|
4354
4322
|
};
|
|
4355
4323
|
//#endregion
|
|
4356
4324
|
//#region src/tools/GetComponentVisualTool.ts
|
|
4357
|
-
/**
|
|
4358
|
-
* GetComponentVisualTool
|
|
4359
|
-
*
|
|
4360
|
-
* DESIGN PATTERNS:
|
|
4361
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4362
|
-
* - Service delegation for business logic
|
|
4363
|
-
* - JSON Schema validation for inputs
|
|
4364
|
-
*
|
|
4365
|
-
* CODING STANDARDS:
|
|
4366
|
-
* - Implement Tool interface from ../types
|
|
4367
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'get_component_visual')
|
|
4368
|
-
* - Return CallToolResult with content array
|
|
4369
|
-
* - Handle errors with isError flag
|
|
4370
|
-
* - Delegate complex logic to services
|
|
4371
|
-
*
|
|
4372
|
-
* AVOID:
|
|
4373
|
-
* - Complex business logic in execute method
|
|
4374
|
-
* - Unhandled promise rejections
|
|
4375
|
-
* - Missing input validation
|
|
4376
|
-
*/
|
|
4377
4325
|
var _GetComponentVisualTool;
|
|
4378
4326
|
/**
|
|
4379
4327
|
* Template for visual review instructions returned with component screenshots.
|
|
@@ -4496,26 +4444,6 @@ GetComponentVisualTool = _GetComponentVisualTool = __decorate([
|
|
|
4496
4444
|
], GetComponentVisualTool);
|
|
4497
4445
|
//#endregion
|
|
4498
4446
|
//#region src/tools/ListSharedComponentsTool.ts
|
|
4499
|
-
/**
|
|
4500
|
-
* ListSharedComponentsTool
|
|
4501
|
-
*
|
|
4502
|
-
* DESIGN PATTERNS:
|
|
4503
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4504
|
-
* - Service delegation for business logic
|
|
4505
|
-
* - JSON Schema validation for inputs
|
|
4506
|
-
*
|
|
4507
|
-
* CODING STANDARDS:
|
|
4508
|
-
* - Implement Tool interface from ../types
|
|
4509
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'list_shared_components')
|
|
4510
|
-
* - Return CallToolResult with content array
|
|
4511
|
-
* - Handle errors with isError flag
|
|
4512
|
-
* - Delegate complex logic to services
|
|
4513
|
-
*
|
|
4514
|
-
* AVOID:
|
|
4515
|
-
* - Complex business logic in execute method
|
|
4516
|
-
* - Unhandled promise rejections
|
|
4517
|
-
* - Missing input validation
|
|
4518
|
-
*/
|
|
4519
4447
|
var _ListSharedComponentsTool;
|
|
4520
4448
|
let ListSharedComponentsTool = class ListSharedComponentsTool {
|
|
4521
4449
|
static {
|
|
@@ -4626,26 +4554,6 @@ ListSharedComponentsTool = _ListSharedComponentsTool = __decorate([
|
|
|
4626
4554
|
], ListSharedComponentsTool);
|
|
4627
4555
|
//#endregion
|
|
4628
4556
|
//#region src/tools/ListAppComponentsTool.ts
|
|
4629
|
-
/**
|
|
4630
|
-
* ListAppComponentsTool
|
|
4631
|
-
*
|
|
4632
|
-
* DESIGN PATTERNS:
|
|
4633
|
-
* - Tool pattern with getDefinition() and execute() methods
|
|
4634
|
-
* - Service delegation for business logic
|
|
4635
|
-
* - JSON Schema validation for inputs
|
|
4636
|
-
*
|
|
4637
|
-
* CODING STANDARDS:
|
|
4638
|
-
* - Implement Tool interface from ../types
|
|
4639
|
-
* - Use TOOL_NAME constant with snake_case (e.g., 'list_app_components')
|
|
4640
|
-
* - Return CallToolResult with content array
|
|
4641
|
-
* - Handle errors with isError flag
|
|
4642
|
-
* - Delegate complex logic to services
|
|
4643
|
-
*
|
|
4644
|
-
* AVOID:
|
|
4645
|
-
* - Complex business logic in execute method
|
|
4646
|
-
* - Unhandled promise rejections
|
|
4647
|
-
* - Missing input validation
|
|
4648
|
-
*/
|
|
4649
4557
|
var _ListAppComponentsTool;
|
|
4650
4558
|
let ListAppComponentsTool = class ListAppComponentsTool {
|
|
4651
4559
|
static {
|
|
@@ -5029,7 +4937,7 @@ function createContainer(options) {
|
|
|
5029
4937
|
}
|
|
5030
4938
|
//#endregion
|
|
5031
4939
|
//#region package.json
|
|
5032
|
-
var version = "0.1.
|
|
4940
|
+
var version = "0.1.8";
|
|
5033
4941
|
//#endregion
|
|
5034
4942
|
//#region src/metadata.ts
|
|
5035
4943
|
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
|
@@ -5064,7 +4972,7 @@ function createServer(containerOrThemePath) {
|
|
|
5064
4972
|
const listSharedComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListSharedComponentsTool);
|
|
5065
4973
|
const listAppComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListAppComponentsTool);
|
|
5066
4974
|
const polishComponentTool = container.get(STYLE_SYSTEM_TYPES.PolishComponentTool);
|
|
5067
|
-
server.setRequestHandler(
|
|
4975
|
+
server.setRequestHandler("tools/list", async () => {
|
|
5068
4976
|
return { tools: [
|
|
5069
4977
|
withCapabilities(listThemesTool.getDefinition(), [
|
|
5070
4978
|
"themes",
|
|
@@ -5098,23 +5006,45 @@ function createServer(containerOrThemePath) {
|
|
|
5098
5006
|
"polish",
|
|
5099
5007
|
"antigravity"
|
|
5100
5008
|
])
|
|
5101
|
-
]
|
|
5009
|
+
].map((tool) => {
|
|
5010
|
+
if (tool.inputSchema.type !== "object") throw new Error(`Invalid schema for ${tool.name}`);
|
|
5011
|
+
return {
|
|
5012
|
+
...tool,
|
|
5013
|
+
inputSchema: tool.inputSchema
|
|
5014
|
+
};
|
|
5015
|
+
}) };
|
|
5102
5016
|
});
|
|
5103
|
-
server.setRequestHandler(
|
|
5017
|
+
server.setRequestHandler("tools/call", async (request) => {
|
|
5104
5018
|
const { name, arguments: args } = request.params;
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5019
|
+
const tool = [
|
|
5020
|
+
listThemesTool,
|
|
5021
|
+
getCSSClassesTool,
|
|
5022
|
+
getComponentVisualTool,
|
|
5023
|
+
listSharedComponentsTool,
|
|
5024
|
+
listAppComponentsTool,
|
|
5025
|
+
polishComponentTool
|
|
5026
|
+
].find((candidate) => candidate.getDefinition().name === name);
|
|
5027
|
+
if (!tool) return {
|
|
5112
5028
|
content: [{
|
|
5113
5029
|
type: "text",
|
|
5114
|
-
text: `
|
|
5030
|
+
text: `Unknown tool: ${name}`
|
|
5115
5031
|
}],
|
|
5116
5032
|
isError: true
|
|
5117
5033
|
};
|
|
5034
|
+
try {
|
|
5035
|
+
const definition = tool.getDefinition();
|
|
5036
|
+
if (definition.inputSchema.type !== "object") throw new Error(`Invalid schema for ${name}`);
|
|
5037
|
+
const input = z.fromJSONSchema(definition.inputSchema).parse(args ?? {});
|
|
5038
|
+
return await tool.execute(input);
|
|
5039
|
+
} catch (error) {
|
|
5040
|
+
return {
|
|
5041
|
+
content: [{
|
|
5042
|
+
type: "text",
|
|
5043
|
+
text: error instanceof Error ? error.message : String(error)
|
|
5044
|
+
}],
|
|
5045
|
+
isError: true
|
|
5046
|
+
};
|
|
5047
|
+
}
|
|
5118
5048
|
});
|
|
5119
5049
|
return server;
|
|
5120
5050
|
}
|
|
@@ -5258,42 +5188,24 @@ function generateRestrictedClassesConfig(cssResult) {
|
|
|
5258
5188
|
}
|
|
5259
5189
|
//#endregion
|
|
5260
5190
|
//#region src/transports/stdio.ts
|
|
5261
|
-
/**
|
|
5262
|
-
* STDIO Transport
|
|
5263
|
-
*
|
|
5264
|
-
* DESIGN PATTERNS:
|
|
5265
|
-
* - Transport handler pattern implementing TransportHandler interface
|
|
5266
|
-
* - Standard I/O based communication for CLI usage
|
|
5267
|
-
*
|
|
5268
|
-
* CODING STANDARDS:
|
|
5269
|
-
* - Initialize server and transport properly
|
|
5270
|
-
* - Handle cleanup on shutdown with stop() method
|
|
5271
|
-
* - Use async/await for all operations
|
|
5272
|
-
*
|
|
5273
|
-
* AVOID:
|
|
5274
|
-
* - Forgetting to close transport on shutdown
|
|
5275
|
-
* - Missing error handling for connection failures
|
|
5276
|
-
*/
|
|
5277
|
-
/**
|
|
5278
|
-
* Stdio transport handler for MCP server
|
|
5279
|
-
* Used for command-line and direct integrations
|
|
5280
|
-
*/
|
|
5191
|
+
/** Modern MCP stdio only: reject legacy initialization explicitly. */
|
|
5281
5192
|
var StdioTransportHandler = class {
|
|
5282
|
-
|
|
5283
|
-
|
|
5193
|
+
factory;
|
|
5194
|
+
handle = null;
|
|
5195
|
+
started = false;
|
|
5284
5196
|
constructor(server) {
|
|
5285
|
-
this.
|
|
5197
|
+
this.factory = typeof server === "function" ? server : () => server;
|
|
5286
5198
|
}
|
|
5287
5199
|
async start() {
|
|
5288
|
-
this.
|
|
5289
|
-
|
|
5200
|
+
if (this.handle || this.started) throw new Error("style-system stdio server already started");
|
|
5201
|
+
this.handle = serveStdio(this.factory, { legacy: "reject" });
|
|
5202
|
+
this.started = true;
|
|
5290
5203
|
log.info(`${STYLE_SYSTEM_SERVER_NAME} MCP server started on stdio`);
|
|
5291
5204
|
}
|
|
5292
5205
|
async stop() {
|
|
5293
|
-
if (this.
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
}
|
|
5206
|
+
if (!this.handle) return;
|
|
5207
|
+
await this.handle.close();
|
|
5208
|
+
this.handle = null;
|
|
5297
5209
|
}
|
|
5298
5210
|
};
|
|
5299
5211
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/style-system",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "MCP server for exploring themes, Tailwind CSS classes, and UI components from Storybook with standalone component rendering capabilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design-system",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@modelcontextprotocol/
|
|
43
|
+
"@modelcontextprotocol/node": "2.1.0",
|
|
44
|
+
"@modelcontextprotocol/server": "2.1.0",
|
|
44
45
|
"@tailwindcss/vite": "4.3.3",
|
|
45
46
|
"@vitejs/plugin-react": "6.0.3",
|
|
46
47
|
"chalk": "5.6.2",
|
|
@@ -60,12 +61,14 @@
|
|
|
60
61
|
"tailwindcss": "4.3.3",
|
|
61
62
|
"vite": "8.1.5",
|
|
62
63
|
"vite-plugin-singlefile": "^2.3.3",
|
|
63
|
-
"@agimon-ai/foundation-exec": "0.26.
|
|
64
|
+
"@agimon-ai/foundation-exec": "0.26.31",
|
|
65
|
+
"@agimon-ai/foundation-validator": "0.26.31"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
68
|
"@babel/parser": "8.0.0",
|
|
67
69
|
"@babel/traverse": "8.0.0",
|
|
68
70
|
"@babel/types": "8.0.0",
|
|
71
|
+
"@modelcontextprotocol/client": "2.1.0",
|
|
69
72
|
"@types/babel__traverse": "7.28.0",
|
|
70
73
|
"@types/node": "26.1.1",
|
|
71
74
|
"@types/react": "19.2.17",
|