@master/css-mcp 2.0.0-rc.87 → 2.0.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/README.md +47 -22
- package/dist/bin/index.js +4 -5
- package/dist/classes.js +153 -168
- package/dist/compare.js +99 -83
- package/dist/context.d.ts +5 -10
- package/dist/context.js +28 -10
- package/dist/design-system-schema.js +97 -0
- package/dist/directives.js +59 -109
- package/dist/document.js +2 -10
- package/dist/format.js +67 -56
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -3
- package/dist/internal/src/workspace.js +70 -0
- package/dist/language.js +27 -23
- package/dist/lint.js +86 -96
- package/dist/manifest-query.js +40 -100
- package/dist/manifest-summary.js +15 -35
- package/dist/output-schema.js +207 -0
- package/dist/preview-write-lock.js +90 -0
- package/dist/project-comparison-schema.js +59 -0
- package/dist/project.js +77 -18
- package/dist/result.js +67 -8
- package/dist/scan.js +93 -73
- package/dist/semantic-schema.js +286 -0
- package/dist/server.d.ts +10 -9
- package/dist/server.js +123 -111
- package/dist/setup.js +28 -29
- package/dist/source-schema.js +141 -0
- package/dist/suggest.js +22 -0
- package/dist/tooling-session.js +27 -0
- package/package.json +63 -73
- package/LICENSE +0 -21
- package/dist/classes.d.ts +0 -236
- package/dist/compare.d.ts +0 -70
- package/dist/contributor.d.ts +0 -149
- package/dist/contributor.js +0 -499
- package/dist/directives.d.ts +0 -132
- package/dist/document.d.ts +0 -24
- package/dist/format.d.ts +0 -56
- package/dist/language.d.ts +0 -24
- package/dist/lint.d.ts +0 -55
- package/dist/manifest-query.d.ts +0 -148
- package/dist/manifest-summary.d.ts +0 -47
- package/dist/project.d.ts +0 -31
- package/dist/result.d.ts +0 -8
- package/dist/scan.d.ts +0 -156
- package/dist/setup.d.ts +0 -67
package/dist/server.js
CHANGED
|
@@ -1,23 +1,47 @@
|
|
|
1
|
-
import
|
|
1
|
+
import MasterCSSMCPContext from "./context.js";
|
|
2
|
+
import { executeTool, jsonResourceResult } from "./result.js";
|
|
2
3
|
import { getWorkspaceInfo, loadWorkspaceManifest } from "./project.js";
|
|
3
4
|
import { inspectClass, previewGeneratedCSS, renderCSS, scanProject } from "./scan.js";
|
|
4
|
-
import { extractClasses, traceClass } from "./classes.js";
|
|
5
|
-
import { compareCSS } from "./compare.js";
|
|
6
|
-
import MasterCSSMCPContext from "./context.js";
|
|
7
|
-
import { getChangeImpact, getPackageGraph, getRepoContext, getTestRouter } from "./contributor.js";
|
|
8
|
-
import { inspectDirectives } from "./directives.js";
|
|
9
|
-
import { previewDirectiveFormat } from "./format.js";
|
|
10
5
|
import { suggestSyntax } from "./language.js";
|
|
11
6
|
import { lintContent, lintProject, previewLintFixes } from "./lint.js";
|
|
12
7
|
import { auditSetup } from "./setup.js";
|
|
8
|
+
import { inspectDirectives } from "./directives.js";
|
|
9
|
+
import { extractClasses, traceClass } from "./classes.js";
|
|
13
10
|
import { queryManifest } from "./manifest-query.js";
|
|
11
|
+
import { previewDirectiveFormat } from "./format.js";
|
|
12
|
+
import { compareCSS } from "./compare.js";
|
|
13
|
+
import { projectSnapshot } from "./project-comparison-schema.js";
|
|
14
|
+
import { designSystemOptions } from "./design-system-schema.js";
|
|
15
|
+
import { toolOutputSchema } from "./output-schema.js";
|
|
16
|
+
import { suggestClasses } from "./suggest.js";
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
14
18
|
import { dirname, resolve } from "node:path";
|
|
15
19
|
import { fileURLToPath } from "node:url";
|
|
16
|
-
import { readFileSync } from "node:fs";
|
|
17
20
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
18
21
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
19
22
|
import * as z from "zod/v4";
|
|
20
|
-
|
|
23
|
+
// src/server.ts
|
|
24
|
+
var MasterCSSMCPServer = class {
|
|
25
|
+
#server;
|
|
26
|
+
#context;
|
|
27
|
+
#disposed = false;
|
|
28
|
+
constructor(server, context) {
|
|
29
|
+
this.#server = server;
|
|
30
|
+
this.#context = context;
|
|
31
|
+
}
|
|
32
|
+
connect(transport) {
|
|
33
|
+
return this.#server.connect(transport);
|
|
34
|
+
}
|
|
35
|
+
async dispose() {
|
|
36
|
+
if (this.#disposed) return;
|
|
37
|
+
this.#disposed = true;
|
|
38
|
+
this.#context.dispose();
|
|
39
|
+
await this.#server.close();
|
|
40
|
+
}
|
|
41
|
+
[Symbol.asyncDispose]() {
|
|
42
|
+
return this.dispose();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
21
45
|
function readPackageVersion() {
|
|
22
46
|
const directory = dirname(fileURLToPath(import.meta.url));
|
|
23
47
|
try {
|
|
@@ -48,7 +72,8 @@ function registerResources(server, context) {
|
|
|
48
72
|
description: "Resolved Master CSS package locations for this workspace.",
|
|
49
73
|
mimeType: "application/json"
|
|
50
74
|
}, async (uri) => {
|
|
51
|
-
|
|
75
|
+
const info = await getWorkspaceInfo(context);
|
|
76
|
+
return jsonResourceResult(uri, info.packages);
|
|
52
77
|
});
|
|
53
78
|
}
|
|
54
79
|
function registerPrompts(server) {
|
|
@@ -74,21 +99,39 @@ function registerPrompts(server) {
|
|
|
74
99
|
}] }));
|
|
75
100
|
server.registerPrompt("migrate-to-mastercss", {
|
|
76
101
|
title: "Migrate To Master CSS",
|
|
77
|
-
description: "Plan a
|
|
102
|
+
description: "Plan a conversion from an external styling system to current Master CSS."
|
|
78
103
|
}, () => ({ messages: [{
|
|
79
104
|
role: "user",
|
|
80
105
|
content: {
|
|
81
106
|
type: "text",
|
|
82
107
|
text: [
|
|
83
|
-
"Use the Master CSS MCP tools to plan
|
|
108
|
+
"Use the Master CSS MCP tools to plan a migration from CSS, CSS Modules, Sass, Tailwind CSS, CSS-in-JS, or component-library styling to current Master CSS before editing.",
|
|
109
|
+
"This workflow accepts external styling systems only. A project whose only styling system is Master CSS is outside its scope. Do not propose Master CSS version upgrades or invoke a version-conversion command.",
|
|
110
|
+
"Named tokens use hyphens; native declarations use a parenthesized (property:value) head with full native CSS properties and explicit var() references. Verify target syntax against the current project manifest, preserve cascade behavior, and leave uncertain dynamic or custom syntax for manual review.",
|
|
84
111
|
"Inspect the workspace, identify the framework, package manager, current styling systems, stylesheet entries, source extraction coverage, existing theme tokens, component classes, and available validation commands.",
|
|
85
112
|
"Produce a migration plan with the recommended rendering mode, the first reviewable migration batch, CSS output risks, manual visual checks, and the formatter, lint, type-check, test, or build commands to run.",
|
|
113
|
+
"Define utility tokens as direct custom properties in top-level @theme, with optional static retention or inline substitution. Keep selectors and conditions in native CSS outside @theme. Native custom properties do not register utility names.",
|
|
86
114
|
"Preserve CSS output unless a deliberate behavior change is requested, keep vendor or generated CSS in place, and use write previews only for safe, scoped changes."
|
|
87
115
|
].join("\n")
|
|
88
116
|
}
|
|
89
117
|
}] }));
|
|
90
118
|
}
|
|
91
119
|
function registerTools(server, context) {
|
|
120
|
+
server.registerTool("mastercss_suggest_classes", {
|
|
121
|
+
title: "Suggest Master CSS Classes",
|
|
122
|
+
description: "Suggest project-aware classes for an isolated CSS declaration block. Preserves the complete block when conversion needs review. Checks declaration output, not surrounding cascade or browser rendering. Does not write files.",
|
|
123
|
+
inputSchema: {
|
|
124
|
+
declarations: z.string().max(32768),
|
|
125
|
+
context: z.enum(["project", "preset"]).optional()
|
|
126
|
+
},
|
|
127
|
+
outputSchema: toolOutputSchema("mastercss_suggest_classes"),
|
|
128
|
+
annotations: {
|
|
129
|
+
readOnlyHint: true,
|
|
130
|
+
destructiveHint: false,
|
|
131
|
+
idempotentHint: true,
|
|
132
|
+
openWorldHint: false
|
|
133
|
+
}
|
|
134
|
+
}, async (input) => executeTool(() => suggestClasses(context, input)));
|
|
92
135
|
const rangeSchema = z.object({
|
|
93
136
|
start: z.object({
|
|
94
137
|
line: z.number().int().min(0),
|
|
@@ -102,249 +145,216 @@ function registerTools(server, context) {
|
|
|
102
145
|
server.registerTool("mastercss_workspace_info", {
|
|
103
146
|
title: "Master CSS Workspace Info",
|
|
104
147
|
description: "Report workspace roots, resolved Master CSS packages, and project manifest status.",
|
|
148
|
+
outputSchema: toolOutputSchema("mastercss_workspace_info"),
|
|
105
149
|
annotations: {
|
|
106
150
|
readOnlyHint: true,
|
|
107
151
|
destructiveHint: false,
|
|
108
152
|
idempotentHint: true,
|
|
109
153
|
openWorldHint: false
|
|
110
154
|
}
|
|
111
|
-
}, async () =>
|
|
155
|
+
}, async () => executeTool(() => getWorkspaceInfo(context)));
|
|
112
156
|
server.registerTool("mastercss_setup_audit", {
|
|
113
157
|
title: "Audit Master CSS Setup",
|
|
114
158
|
description: "Audit package, entry stylesheet, manifest, integration, and package-resolution setup for a workspace.",
|
|
159
|
+
outputSchema: toolOutputSchema("mastercss_setup_audit"),
|
|
115
160
|
annotations: {
|
|
116
161
|
readOnlyHint: true,
|
|
117
162
|
destructiveHint: false,
|
|
118
163
|
idempotentHint: true,
|
|
119
164
|
openWorldHint: false
|
|
120
165
|
}
|
|
121
|
-
}, async () =>
|
|
166
|
+
}, async () => executeTool(() => auditSetup(context)));
|
|
122
167
|
server.registerTool("mastercss_inspect_class", {
|
|
123
168
|
title: "Inspect Master CSS Class",
|
|
124
169
|
description: "Inspect one Master CSS class and return semantic parts, generated rules, variables, and CSS text.",
|
|
125
170
|
inputSchema: {
|
|
126
|
-
|
|
127
|
-
|
|
171
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
172
|
+
className: z.string().min(1)
|
|
128
173
|
},
|
|
174
|
+
outputSchema: toolOutputSchema("mastercss_inspect_class"),
|
|
129
175
|
annotations: {
|
|
130
176
|
readOnlyHint: true,
|
|
131
177
|
destructiveHint: false,
|
|
132
178
|
idempotentHint: true,
|
|
133
179
|
openWorldHint: false
|
|
134
180
|
}
|
|
135
|
-
}, async (input) =>
|
|
181
|
+
}, async (input) => executeTool(() => inspectClass(context, input)));
|
|
136
182
|
server.registerTool("mastercss_trace_class", {
|
|
137
183
|
title: "Trace Master CSS Class",
|
|
138
184
|
description: "Trace one class from project extraction through generated CSS, missing CSS classification, and engine inspection.",
|
|
139
185
|
inputSchema: {
|
|
186
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
140
187
|
className: z.string().min(1),
|
|
141
188
|
patterns: z.array(z.string()).optional(),
|
|
142
|
-
includeCss: z.boolean().optional()
|
|
143
|
-
mode: z.string().optional()
|
|
189
|
+
includeCss: z.boolean().optional()
|
|
144
190
|
},
|
|
191
|
+
outputSchema: toolOutputSchema("mastercss_trace_class"),
|
|
145
192
|
annotations: {
|
|
146
193
|
readOnlyHint: true,
|
|
147
194
|
destructiveHint: false,
|
|
148
195
|
idempotentHint: true,
|
|
149
196
|
openWorldHint: false
|
|
150
197
|
}
|
|
151
|
-
}, async (input) =>
|
|
198
|
+
}, async (input) => executeTool(() => traceClass(context, input)));
|
|
152
199
|
server.registerTool("mastercss_extract_classes", {
|
|
153
200
|
title: "Extract Master CSS Classes",
|
|
154
201
|
description: "Extract class positions and validation summaries from project files or an in-memory source buffer.",
|
|
155
202
|
inputSchema: {
|
|
203
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
156
204
|
content: z.string().optional(),
|
|
157
205
|
filePath: z.string().optional(),
|
|
158
206
|
patterns: z.array(z.string()).optional(),
|
|
159
207
|
includeRules: z.boolean().optional()
|
|
160
208
|
},
|
|
209
|
+
outputSchema: toolOutputSchema("mastercss_extract_classes"),
|
|
161
210
|
annotations: {
|
|
162
211
|
readOnlyHint: true,
|
|
163
212
|
destructiveHint: false,
|
|
164
213
|
idempotentHint: true,
|
|
165
214
|
openWorldHint: false
|
|
166
215
|
}
|
|
167
|
-
}, async (input) =>
|
|
216
|
+
}, async (input) => executeTool(() => extractClasses(context, input)));
|
|
168
217
|
server.registerTool("mastercss_inspect_directives", {
|
|
169
218
|
title: "Inspect Master CSS Directives",
|
|
170
219
|
description: "Inspect CSS-first directives from a stylesheet entry or in-memory CSS content and report manifest/CSS effects.",
|
|
171
220
|
inputSchema: {
|
|
221
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
172
222
|
content: z.string().optional(),
|
|
173
223
|
filePath: z.string().optional(),
|
|
174
224
|
entryPath: z.string().optional(),
|
|
175
225
|
preserveNativeCSS: z.boolean().optional()
|
|
176
226
|
},
|
|
227
|
+
outputSchema: toolOutputSchema("mastercss_inspect_directives"),
|
|
177
228
|
annotations: {
|
|
178
229
|
readOnlyHint: true,
|
|
179
230
|
destructiveHint: false,
|
|
180
231
|
idempotentHint: true,
|
|
181
232
|
openWorldHint: false
|
|
182
233
|
}
|
|
183
|
-
}, async (input) =>
|
|
234
|
+
}, async (input) => executeTool(() => inspectDirectives(context, input)));
|
|
184
235
|
server.registerTool("mastercss_render_css", {
|
|
185
236
|
title: "Render Master CSS",
|
|
186
237
|
description: "Generate CSS from an HTML fragment or a whitespace-separated class list.",
|
|
187
238
|
inputSchema: {
|
|
239
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
188
240
|
html: z.string().optional(),
|
|
189
241
|
classList: z.string().optional()
|
|
190
242
|
},
|
|
243
|
+
outputSchema: toolOutputSchema("mastercss_render_css"),
|
|
191
244
|
annotations: {
|
|
192
245
|
readOnlyHint: true,
|
|
193
246
|
destructiveHint: false,
|
|
194
247
|
idempotentHint: true,
|
|
195
248
|
openWorldHint: false
|
|
196
249
|
}
|
|
197
|
-
}, async (input) =>
|
|
250
|
+
}, async (input) => executeTool(() => renderCSS(context, input)));
|
|
198
251
|
server.registerTool("mastercss_scan_project", {
|
|
199
252
|
title: "Scan Master CSS Project",
|
|
200
|
-
description: "Scan source files
|
|
253
|
+
description: "Scan source files and stylesheet entries. Set includeSnapshot to capture a resolved project state for later impact comparison. Pass designSystem to inspect stylesheet token references and design policies; add routeStylesheets globs for stylesheets imported from JavaScript.",
|
|
201
254
|
inputSchema: {
|
|
255
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
202
256
|
patterns: z.array(z.string()).optional(),
|
|
203
257
|
classes: z.array(z.string()).optional(),
|
|
204
|
-
includeCss: z.boolean().optional()
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
destructiveHint: false,
|
|
209
|
-
idempotentHint: true,
|
|
210
|
-
openWorldHint: false
|
|
211
|
-
}
|
|
212
|
-
}, async (input) => jsonToolResult(await scanProject(context, input)));
|
|
213
|
-
server.registerTool("mastercss_repo_context", {
|
|
214
|
-
title: "Master CSS Repository Context",
|
|
215
|
-
description: "Route Master CSS repository contributor work to affected packages, required context files, risks, and validation commands.",
|
|
216
|
-
inputSchema: {
|
|
217
|
-
task: z.string().optional(),
|
|
218
|
-
paths: z.array(z.string()).optional(),
|
|
219
|
-
diff: z.string().optional()
|
|
220
|
-
},
|
|
221
|
-
annotations: {
|
|
222
|
-
readOnlyHint: true,
|
|
223
|
-
destructiveHint: false,
|
|
224
|
-
idempotentHint: true,
|
|
225
|
-
openWorldHint: false
|
|
226
|
-
}
|
|
227
|
-
}, async (input) => jsonToolResult(await getRepoContext(context, input)));
|
|
228
|
-
server.registerTool("mastercss_change_impact", {
|
|
229
|
-
title: "Master CSS Change Impact",
|
|
230
|
-
description: "Classify contributor change risk for CSS output, runtime, extraction, language, ESLint, docs, and package boundaries.",
|
|
231
|
-
inputSchema: {
|
|
232
|
-
task: z.string().optional(),
|
|
233
|
-
paths: z.array(z.string()).optional(),
|
|
234
|
-
diff: z.string().optional()
|
|
235
|
-
},
|
|
236
|
-
annotations: {
|
|
237
|
-
readOnlyHint: true,
|
|
238
|
-
destructiveHint: false,
|
|
239
|
-
idempotentHint: true,
|
|
240
|
-
openWorldHint: false
|
|
241
|
-
}
|
|
242
|
-
}, async (input) => jsonToolResult(await getChangeImpact(context, input)));
|
|
243
|
-
server.registerTool("mastercss_test_router", {
|
|
244
|
-
title: "Master CSS Test Router",
|
|
245
|
-
description: "Return focused validation commands for Master CSS repository contributor changes.",
|
|
246
|
-
inputSchema: {
|
|
247
|
-
task: z.string().optional(),
|
|
248
|
-
paths: z.array(z.string()).optional(),
|
|
249
|
-
diff: z.string().optional()
|
|
250
|
-
},
|
|
251
|
-
annotations: {
|
|
252
|
-
readOnlyHint: true,
|
|
253
|
-
destructiveHint: false,
|
|
254
|
-
idempotentHint: true,
|
|
255
|
-
openWorldHint: false
|
|
256
|
-
}
|
|
257
|
-
}, async (input) => jsonToolResult(await getTestRouter(context, input)));
|
|
258
|
-
server.registerTool("mastercss_package_graph", {
|
|
259
|
-
title: "Master CSS Package Graph",
|
|
260
|
-
description: "Report Master CSS workspace package ownership, scripts, exports, workspace dependencies, and dependents.",
|
|
261
|
-
inputSchema: {
|
|
262
|
-
packageName: z.string().optional(),
|
|
263
|
-
includeExamples: z.boolean().optional()
|
|
258
|
+
includeCss: z.boolean().optional(),
|
|
259
|
+
includeSnapshot: z.boolean().optional(),
|
|
260
|
+
designSystem: designSystemOptions.optional(),
|
|
261
|
+
routeStylesheets: z.array(z.string()).optional()
|
|
264
262
|
},
|
|
263
|
+
outputSchema: toolOutputSchema("mastercss_scan_project"),
|
|
265
264
|
annotations: {
|
|
266
265
|
readOnlyHint: true,
|
|
267
266
|
destructiveHint: false,
|
|
268
267
|
idempotentHint: true,
|
|
269
268
|
openWorldHint: false
|
|
270
269
|
}
|
|
271
|
-
}, async (input) =>
|
|
270
|
+
}, async (input) => executeTool(() => scanProject(context, input)));
|
|
272
271
|
server.registerTool("mastercss_manifest_query", {
|
|
273
272
|
title: "Query Master CSS Manifest",
|
|
274
|
-
description: "Query active manifest tokens, utilities,
|
|
273
|
+
description: "Query active manifest tokens, utilities, mixins, custom media, custom containers, and token families.",
|
|
275
274
|
inputSchema: {
|
|
275
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
276
276
|
query: z.string().optional(),
|
|
277
277
|
kind: z.enum([
|
|
278
278
|
"all",
|
|
279
279
|
"token",
|
|
280
280
|
"utility",
|
|
281
|
-
"
|
|
282
|
-
"
|
|
283
|
-
"
|
|
284
|
-
"
|
|
281
|
+
"mixin",
|
|
282
|
+
"custom-media",
|
|
283
|
+
"custom-container",
|
|
284
|
+
"family"
|
|
285
285
|
]).optional(),
|
|
286
286
|
namespace: z.string().optional(),
|
|
287
287
|
limit: z.number().int().min(1).max(500).optional()
|
|
288
288
|
},
|
|
289
|
+
outputSchema: toolOutputSchema("mastercss_manifest_query"),
|
|
289
290
|
annotations: {
|
|
290
291
|
readOnlyHint: true,
|
|
291
292
|
destructiveHint: false,
|
|
292
293
|
idempotentHint: true,
|
|
293
294
|
openWorldHint: false
|
|
294
295
|
}
|
|
295
|
-
}, async (input) =>
|
|
296
|
+
}, async (input) => executeTool(() => queryManifest(context, input)));
|
|
296
297
|
server.registerTool("mastercss_css_compare", {
|
|
297
298
|
title: "Compare Master CSS Output",
|
|
298
|
-
description: "Compare
|
|
299
|
+
description: "Compare class lists or source buffers under one manifest, or pass beforeSnapshot and afterSnapshot to compare resolved projects, including changed definitions and known consumers. Does not verify browser rendering.",
|
|
299
300
|
inputSchema: {
|
|
301
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
300
302
|
beforeClassList: z.string().optional(),
|
|
301
303
|
afterClassList: z.string().optional(),
|
|
302
304
|
beforeHtml: z.string().optional(),
|
|
303
305
|
afterHtml: z.string().optional(),
|
|
304
306
|
beforeContent: z.string().optional(),
|
|
305
307
|
afterContent: z.string().optional(),
|
|
308
|
+
beforeSnapshot: projectSnapshot.optional(),
|
|
309
|
+
afterSnapshot: projectSnapshot.optional(),
|
|
306
310
|
filePath: z.string().optional()
|
|
307
311
|
},
|
|
312
|
+
outputSchema: toolOutputSchema("mastercss_css_compare"),
|
|
308
313
|
annotations: {
|
|
309
314
|
readOnlyHint: true,
|
|
310
315
|
destructiveHint: false,
|
|
311
316
|
idempotentHint: true,
|
|
312
317
|
openWorldHint: false
|
|
313
318
|
}
|
|
314
|
-
}, async (input) =>
|
|
319
|
+
}, async (input) => executeTool(() => compareCSS(context, input)));
|
|
315
320
|
server.registerTool("mastercss_lint_project", {
|
|
316
321
|
title: "Lint Master CSS Project",
|
|
317
322
|
description: "Run Master CSS class-list diagnostics and return fix proposals without writing files.",
|
|
318
323
|
inputSchema: {
|
|
324
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
319
325
|
patterns: z.array(z.string()).optional(),
|
|
320
326
|
rules: z.string().optional()
|
|
321
327
|
},
|
|
328
|
+
outputSchema: toolOutputSchema("mastercss_lint_project"),
|
|
322
329
|
annotations: {
|
|
323
330
|
readOnlyHint: true,
|
|
324
331
|
destructiveHint: false,
|
|
325
332
|
idempotentHint: true,
|
|
326
333
|
openWorldHint: false
|
|
327
334
|
}
|
|
328
|
-
}, async (input) =>
|
|
335
|
+
}, async (input) => executeTool(() => lintProject(context, input)));
|
|
329
336
|
server.registerTool("mastercss_lint_content", {
|
|
330
337
|
title: "Lint Master CSS Content",
|
|
331
338
|
description: "Run Master CSS class-list diagnostics on an in-memory source buffer without writing files.",
|
|
332
339
|
inputSchema: {
|
|
340
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
333
341
|
content: z.string(),
|
|
334
342
|
filePath: z.string(),
|
|
335
343
|
rules: z.string().optional()
|
|
336
344
|
},
|
|
345
|
+
outputSchema: toolOutputSchema("mastercss_lint_content"),
|
|
337
346
|
annotations: {
|
|
338
347
|
readOnlyHint: true,
|
|
339
348
|
destructiveHint: false,
|
|
340
349
|
idempotentHint: true,
|
|
341
350
|
openWorldHint: false
|
|
342
351
|
}
|
|
343
|
-
}, async (input) =>
|
|
352
|
+
}, async (input) => executeTool(() => lintContent(context, input)));
|
|
344
353
|
server.registerTool("mastercss_suggest_syntax", {
|
|
345
354
|
title: "Suggest Master CSS Syntax",
|
|
346
355
|
description: "Return language-service completions and hover context for a document position.",
|
|
347
356
|
inputSchema: {
|
|
357
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
348
358
|
content: z.string(),
|
|
349
359
|
filePath: z.string(),
|
|
350
360
|
position: z.object({
|
|
@@ -354,24 +364,26 @@ function registerTools(server, context) {
|
|
|
354
364
|
triggerCharacter: z.string().optional(),
|
|
355
365
|
limit: z.number().int().min(1).max(200).optional()
|
|
356
366
|
},
|
|
367
|
+
outputSchema: toolOutputSchema("mastercss_suggest_syntax"),
|
|
357
368
|
annotations: {
|
|
358
369
|
readOnlyHint: true,
|
|
359
370
|
destructiveHint: false,
|
|
360
371
|
idempotentHint: true,
|
|
361
372
|
openWorldHint: false
|
|
362
373
|
}
|
|
363
|
-
}, async (input) =>
|
|
374
|
+
}, async (input) => executeTool(() => suggestSyntax(context, input)));
|
|
364
375
|
server.registerTool("mastercss_preview_fixes", {
|
|
365
376
|
title: "Preview Master CSS Fixes",
|
|
366
377
|
description: "Create a diff preview for lint fixes or generated CSS output and return a confirmation token.",
|
|
367
378
|
inputSchema: {
|
|
379
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
368
380
|
mode: z.enum(["lint-fixes", "generated-css"]).optional(),
|
|
369
381
|
patterns: z.array(z.string()).optional(),
|
|
370
382
|
rules: z.string().optional(),
|
|
371
|
-
includeDirectiveFixes: z.boolean().optional(),
|
|
372
383
|
outputPath: z.string().optional(),
|
|
373
|
-
ttlMs: z.number().int().min(1e3).max(
|
|
384
|
+
ttlMs: z.number().int().min(1e3).max(36e5).optional()
|
|
374
385
|
},
|
|
386
|
+
outputSchema: toolOutputSchema("mastercss_preview_fixes"),
|
|
375
387
|
annotations: {
|
|
376
388
|
readOnlyHint: false,
|
|
377
389
|
destructiveHint: false,
|
|
@@ -381,43 +393,47 @@ function registerTools(server, context) {
|
|
|
381
393
|
}, async (input) => {
|
|
382
394
|
if (input.mode === "generated-css") {
|
|
383
395
|
if (!input.outputPath) throw new Error("outputPath is required when mode is \"generated-css\".");
|
|
384
|
-
return
|
|
396
|
+
return executeTool(() => previewGeneratedCSS(context, {
|
|
397
|
+
context: input.context,
|
|
385
398
|
patterns: input.patterns,
|
|
386
399
|
includeCss: true,
|
|
387
400
|
outputPath: input.outputPath,
|
|
388
401
|
ttlMs: input.ttlMs
|
|
389
402
|
}));
|
|
390
403
|
}
|
|
391
|
-
return
|
|
404
|
+
return executeTool(() => previewLintFixes(context, input));
|
|
392
405
|
});
|
|
393
406
|
server.registerTool("mastercss_preview_directive_format", {
|
|
394
407
|
title: "Preview Master CSS Directive Format",
|
|
395
408
|
description: "Create a safe preview for formatting Master CSS directives, or format in-memory content without writing files.",
|
|
396
409
|
inputSchema: {
|
|
410
|
+
context: z.enum(["project", "preset"]).optional(),
|
|
397
411
|
content: z.string().optional(),
|
|
398
412
|
filePath: z.string().optional(),
|
|
399
413
|
patterns: z.array(z.string()).optional(),
|
|
400
414
|
range: rangeSchema.optional(),
|
|
401
|
-
ttlMs: z.number().int().min(1e3).max(
|
|
415
|
+
ttlMs: z.number().int().min(1e3).max(36e5).optional()
|
|
402
416
|
},
|
|
417
|
+
outputSchema: toolOutputSchema("mastercss_preview_directive_format"),
|
|
403
418
|
annotations: {
|
|
404
419
|
readOnlyHint: false,
|
|
405
420
|
destructiveHint: false,
|
|
406
421
|
idempotentHint: false,
|
|
407
422
|
openWorldHint: false
|
|
408
423
|
}
|
|
409
|
-
}, async (input) =>
|
|
424
|
+
}, async (input) => executeTool(() => previewDirectiveFormat(context, input)));
|
|
410
425
|
server.registerTool("mastercss_apply_preview", {
|
|
411
426
|
title: "Apply Master CSS Preview",
|
|
412
427
|
description: "Apply a previously generated preview token after validating hashes and workspace containment.",
|
|
413
428
|
inputSchema: { confirmToken: z.string().min(1) },
|
|
429
|
+
outputSchema: toolOutputSchema("mastercss_apply_preview"),
|
|
414
430
|
annotations: {
|
|
415
431
|
readOnlyHint: false,
|
|
416
432
|
destructiveHint: true,
|
|
417
433
|
idempotentHint: false,
|
|
418
434
|
openWorldHint: false
|
|
419
435
|
}
|
|
420
|
-
}, async (input) =>
|
|
436
|
+
}, async (input) => executeTool(() => context.applyPreview(input.confirmToken)));
|
|
421
437
|
}
|
|
422
438
|
function createMasterCSSMCPServer(options = {}) {
|
|
423
439
|
const context = new MasterCSSMCPContext(options);
|
|
@@ -428,16 +444,12 @@ function createMasterCSSMCPServer(options = {}) {
|
|
|
428
444
|
registerResources(server, context);
|
|
429
445
|
registerPrompts(server);
|
|
430
446
|
registerTools(server, context);
|
|
431
|
-
return
|
|
432
|
-
server,
|
|
433
|
-
context
|
|
434
|
-
};
|
|
447
|
+
return new MasterCSSMCPServer(server, context);
|
|
435
448
|
}
|
|
436
|
-
async function
|
|
437
|
-
const
|
|
449
|
+
async function startMasterCSSMCPStdioServer(options = {}) {
|
|
450
|
+
const server = createMasterCSSMCPServer(options);
|
|
438
451
|
const transport = new StdioServerTransport();
|
|
439
452
|
await server.connect(transport);
|
|
440
453
|
return server;
|
|
441
454
|
}
|
|
442
|
-
|
|
443
|
-
export { createMasterCSSMCPServer, startStdioServer };
|
|
455
|
+
export { createMasterCSSMCPServer, startMasterCSSMCPStdioServer };
|
package/dist/setup.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { resolveMasterCSSWorkspacePackages } from "./internal/src/workspace.js";
|
|
1
2
|
import { getErrorMessage } from "./result.js";
|
|
2
|
-
import { loadWorkspaceManifest } from "./project.js";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { findCSSManifestEntryFiles } from "@master/css-project/entries";
|
|
6
|
-
import { resolveMasterCSSWorkspacePackages } from "@master/css-project/workspace";
|
|
3
|
+
import { loadWorkspaceManifest, manifestMetadata } from "./project.js";
|
|
7
4
|
import { existsSync } from "node:fs";
|
|
8
|
-
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { discoverManifestEntries } from "@master/css-compiler/project";
|
|
8
|
+
// src/setup.ts
|
|
9
9
|
const SETUP_AUDIT_VERSION = 1;
|
|
10
10
|
const LOCKFILES = {
|
|
11
|
-
pnpm: "pnpm-lock.yaml",
|
|
12
|
-
npm: "package-lock.json",
|
|
13
|
-
yarn: "yarn.lock",
|
|
14
|
-
bun: "bun.lockb"
|
|
11
|
+
pnpm: ["pnpm-lock.yaml"],
|
|
12
|
+
npm: ["package-lock.json"],
|
|
13
|
+
yarn: ["yarn.lock"],
|
|
14
|
+
bun: ["bun.lock", "bun.lockb"]
|
|
15
15
|
};
|
|
16
16
|
const MASTER_CSS_PACKAGES = [
|
|
17
17
|
"@master/css",
|
|
@@ -20,28 +20,27 @@ const MASTER_CSS_PACKAGES = [
|
|
|
20
20
|
"@master/create-css",
|
|
21
21
|
"@master/css-runtime",
|
|
22
22
|
"@master/css-language-server",
|
|
23
|
-
"@master/css
|
|
24
|
-
"@master/css
|
|
25
|
-
"@master/css
|
|
26
|
-
"@master/css
|
|
27
|
-
"@master/css
|
|
28
|
-
"@master/css
|
|
29
|
-
"@master/css-
|
|
23
|
+
"@master/css-vite",
|
|
24
|
+
"@master/css-webpack",
|
|
25
|
+
"@master/css-next",
|
|
26
|
+
"@master/css-nuxt",
|
|
27
|
+
"@master/css-astro",
|
|
28
|
+
"@master/css-svelte",
|
|
29
|
+
"@master/css-svelte-addon",
|
|
30
30
|
"@master/eslint-config-css",
|
|
31
31
|
"@master/eslint-plugin-css"
|
|
32
32
|
];
|
|
33
33
|
const INTEGRATION_PACKAGES = [
|
|
34
34
|
"@master/css-cli",
|
|
35
|
-
"@master/css
|
|
36
|
-
"@master/css
|
|
37
|
-
"@master/css
|
|
38
|
-
"@master/css
|
|
39
|
-
"@master/css
|
|
40
|
-
"@master/css
|
|
41
|
-
"@master/eslint-config-css"
|
|
42
|
-
"@master/eslint-plugin-css"
|
|
35
|
+
"@master/css-vite",
|
|
36
|
+
"@master/css-webpack",
|
|
37
|
+
"@master/css-next",
|
|
38
|
+
"@master/css-nuxt",
|
|
39
|
+
"@master/css-astro",
|
|
40
|
+
"@master/css-svelte",
|
|
41
|
+
"@master/eslint-config-css"
|
|
43
42
|
];
|
|
44
|
-
const SETUP_PACKAGES = ["@master/create-css", "@master/css-
|
|
43
|
+
const SETUP_PACKAGES = ["@master/create-css", "@master/css-svelte-addon"];
|
|
45
44
|
function getDependencies(packageJSON) {
|
|
46
45
|
return {
|
|
47
46
|
...packageJSON?.dependencies,
|
|
@@ -65,7 +64,7 @@ async function readPackageJSON(context) {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
function detectPackageManager(context, packageJSON) {
|
|
68
|
-
const lockfiles = Object.entries(LOCKFILES).filter(([, filename]) => existsSync(join(context.root, filename))).map(([name, filename]) => ({
|
|
67
|
+
const lockfiles = Object.entries(LOCKFILES).flatMap(([name, filenames]) => filenames.map((filename) => [name, filename])).filter(([, filename]) => existsSync(join(context.root, filename))).map(([name, filename]) => ({
|
|
69
68
|
name,
|
|
70
69
|
filePath: join(context.root, filename)
|
|
71
70
|
}));
|
|
@@ -122,7 +121,7 @@ async function auditSetup(context) {
|
|
|
122
121
|
const [packageJSONResult, manifest, discoveredEntries] = await Promise.all([
|
|
123
122
|
readPackageJSON(context),
|
|
124
123
|
loadWorkspaceManifest(context),
|
|
125
|
-
|
|
124
|
+
discoverManifestEntries({ root: context.root }).catch(() => [])
|
|
126
125
|
]);
|
|
127
126
|
const packageJSON = packageJSONResult.value;
|
|
128
127
|
const packageManager = detectPackageManager(context, packageJSON);
|
|
@@ -160,6 +159,7 @@ async function auditSetup(context) {
|
|
|
160
159
|
},
|
|
161
160
|
integrations,
|
|
162
161
|
manifest: {
|
|
162
|
+
...manifestMetadata(manifest),
|
|
163
163
|
status: manifest.status,
|
|
164
164
|
entries: manifest.entries.length ? manifest.entries : discoveredEntries,
|
|
165
165
|
dependencies: manifest.dependencies,
|
|
@@ -179,5 +179,4 @@ async function auditSetup(context) {
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
//#endregion
|
|
183
182
|
export { auditSetup };
|