onsystem 0.4.0 → 0.6.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 +36 -15
- package/dist/cli.js +339 -180
- package/dist/config-lbfW91qB.d.ts +482 -0
- package/dist/{stdio-BcJth14k.js → design-system-A3pRX3Ka.js} +8439 -7212
- package/dist/eslint-worker.d.ts +36 -0
- package/dist/eslint-worker.js +95 -0
- package/dist/eslint.d.ts +23 -0
- package/dist/eslint.js +172 -0
- package/dist/index.d.ts +84 -387
- package/dist/index.js +3 -2
- package/dist/stdio-CEChNFLR.js +1396 -0
- package/dist/workspace-CHvUwgz9.js +227 -0
- package/package.json +22 -2
- package/schema.json +19 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,385 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { C as TOKEN_CATEGORIES, D as VariantInfo, E as TokenCategory, O as ImportMapping, S as SourceLocation, T as Token, _ as DocSection, a as ResolvedRule, b as PropInfo, c as configJsonSchema, d as CheckResult, f as ComponentDocs, g as Diagnostic, h as DesignSystemModel, i as ResolvedConfig, l as defineConfig, m as CompoundVariantInfo, n as LoadConfigOptions, o as RuleId, p as ComponentInfo, r as RULE_IDS, s as RuleOptions, t as Config, u as loadConfig, v as ExampleInfo, w as TextEdit, x as Severity, y as InheritedProps } from "./config-lbfW91qB.js";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { Oklch } from "culori";
|
|
4
4
|
import { McpServer, Transport } from "@modelcontextprotocol/server";
|
|
5
|
-
//#region src/detect.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* How apps import a design-system module, from a package's `exports`:
|
|
8
|
-
* `@midday/ui/button` → `../../packages/ui/src/components/button.tsx`, or a
|
|
9
|
-
* pattern (`@workspace/ui/components/*` → `…/src/components/*.tsx`). A
|
|
10
|
-
* specifier without `*` and a pattern target map every matching file to one
|
|
11
|
-
* module: a package that exports its components from a barrel.
|
|
12
|
-
*/
|
|
13
|
-
interface ImportMapping {
|
|
14
|
-
specifier: string;
|
|
15
|
-
/** File or pattern relative to the root, with forward slashes. */
|
|
16
|
-
target: string;
|
|
17
|
-
}
|
|
18
|
-
/** One of several design systems an app uses, and how often its code imports it. */
|
|
19
|
-
interface DesignSystemSource {
|
|
20
|
-
source: string;
|
|
21
|
-
components: string[];
|
|
22
|
-
imports: number;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/config.d.ts
|
|
26
|
-
export declare const RULE_IDS: readonly ["no-hardcoded-color", "no-hardcoded-spacing", "no-hardcoded-radius", "prefer-design-system-component", "no-unknown-component", "no-unknown-prop", "no-unknown-variant", "icon-button-accessible-name"];
|
|
27
|
-
type RuleId = (typeof RULE_IDS)[number];
|
|
28
|
-
declare const severitySchema: z.ZodEnum<{
|
|
29
|
-
off: "off";
|
|
30
|
-
warn: "warn";
|
|
31
|
-
error: "error";
|
|
32
|
-
}>;
|
|
33
|
-
type RuleSeverity = z.infer<typeof severitySchema>;
|
|
34
|
-
declare const ruleOptionsSchema: z.ZodObject<{
|
|
35
|
-
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
-
}, z.core.$strict>;
|
|
37
|
-
type RuleOptions = z.infer<typeof ruleOptionsSchema>;
|
|
38
|
-
declare const configSchema: z.ZodObject<{
|
|
39
|
-
$schema: z.ZodOptional<z.ZodString>;
|
|
40
|
-
components: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
41
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
-
tokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
43
|
-
path: z.ZodString;
|
|
44
|
-
prefix: z.ZodOptional<z.ZodString>;
|
|
45
|
-
}, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
46
|
-
path: z.ZodString;
|
|
47
|
-
prefix: z.ZodOptional<z.ZodString>;
|
|
48
|
-
}, z.core.$strict>]>>]>>;
|
|
49
|
-
docs: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
50
|
-
tsconfig: z.ZodOptional<z.ZodString>;
|
|
51
|
-
importPath: z.ZodOptional<z.ZodString>;
|
|
52
|
-
elements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
53
|
-
includeDesignSystem: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
-
rules: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
55
|
-
"no-hardcoded-color": "no-hardcoded-color";
|
|
56
|
-
"no-hardcoded-spacing": "no-hardcoded-spacing";
|
|
57
|
-
"no-hardcoded-radius": "no-hardcoded-radius";
|
|
58
|
-
"prefer-design-system-component": "prefer-design-system-component";
|
|
59
|
-
"no-unknown-component": "no-unknown-component";
|
|
60
|
-
"no-unknown-prop": "no-unknown-prop";
|
|
61
|
-
"no-unknown-variant": "no-unknown-variant";
|
|
62
|
-
"icon-button-accessible-name": "icon-button-accessible-name";
|
|
63
|
-
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodEnum<{
|
|
64
|
-
off: "off";
|
|
65
|
-
warn: "warn";
|
|
66
|
-
error: "error";
|
|
67
|
-
}>, z.ZodTuple<[z.ZodEnum<{
|
|
68
|
-
off: "off";
|
|
69
|
-
warn: "warn";
|
|
70
|
-
error: "error";
|
|
71
|
-
}>], null>, z.ZodTuple<[z.ZodEnum<{
|
|
72
|
-
off: "off";
|
|
73
|
-
warn: "warn";
|
|
74
|
-
error: "error";
|
|
75
|
-
}>, z.ZodObject<{
|
|
76
|
-
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
-
}, z.core.$strict>], null>]>>>;
|
|
78
|
-
overrides: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
79
|
-
files: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
80
|
-
rules: z.ZodRecord<z.ZodEnum<{
|
|
81
|
-
"no-hardcoded-color": "no-hardcoded-color";
|
|
82
|
-
"no-hardcoded-spacing": "no-hardcoded-spacing";
|
|
83
|
-
"no-hardcoded-radius": "no-hardcoded-radius";
|
|
84
|
-
"prefer-design-system-component": "prefer-design-system-component";
|
|
85
|
-
"no-unknown-component": "no-unknown-component";
|
|
86
|
-
"no-unknown-prop": "no-unknown-prop";
|
|
87
|
-
"no-unknown-variant": "no-unknown-variant";
|
|
88
|
-
"icon-button-accessible-name": "icon-button-accessible-name";
|
|
89
|
-
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodEnum<{
|
|
90
|
-
off: "off";
|
|
91
|
-
warn: "warn";
|
|
92
|
-
error: "error";
|
|
93
|
-
}>, z.ZodTuple<[z.ZodEnum<{
|
|
94
|
-
off: "off";
|
|
95
|
-
warn: "warn";
|
|
96
|
-
error: "error";
|
|
97
|
-
}>], null>, z.ZodTuple<[z.ZodEnum<{
|
|
98
|
-
off: "off";
|
|
99
|
-
warn: "warn";
|
|
100
|
-
error: "error";
|
|
101
|
-
}>, z.ZodObject<{
|
|
102
|
-
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
103
|
-
}, z.core.$strict>], null>]>>;
|
|
104
|
-
}, z.core.$strict>>>;
|
|
105
|
-
}, z.core.$strict>;
|
|
106
|
-
type Config = z.input<typeof configSchema>;
|
|
107
|
-
/** Identity helper for typed `onsystem.config.ts` files. */
|
|
108
|
-
export declare function defineConfig(config: Config): Config;
|
|
109
|
-
interface TokenSourceConfig {
|
|
110
|
-
path: string;
|
|
111
|
-
prefix?: string | undefined;
|
|
112
|
-
}
|
|
113
|
-
interface ResolvedRule {
|
|
114
|
-
severity: RuleSeverity;
|
|
115
|
-
options: RuleOptions;
|
|
116
|
-
}
|
|
117
|
-
/** Rule settings for the files that match `files` (root-relative globs). */
|
|
118
|
-
interface ResolvedOverride {
|
|
119
|
-
files: string[];
|
|
120
|
-
rules: Partial<Record<RuleId, ResolvedRule>>;
|
|
121
|
-
}
|
|
122
|
-
interface ResolvedConfig {
|
|
123
|
-
root: string;
|
|
124
|
-
configFile?: string | undefined;
|
|
125
|
-
components: string[];
|
|
126
|
-
exclude: string[];
|
|
127
|
-
tokens: TokenSourceConfig[];
|
|
128
|
-
docs: string[];
|
|
129
|
-
tsconfig?: string | undefined;
|
|
130
|
-
importPath?: string | undefined;
|
|
131
|
-
/** Import specifiers for component files, from the `exports` of the package that holds them. */
|
|
132
|
-
imports?: ImportMapping[] | undefined;
|
|
133
|
-
/** How the design system was found when the config does not say (`components.json`, a workspace package). */
|
|
134
|
-
detected?: string | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Several design systems found at once, the most imported first: its components win
|
|
137
|
-
* where two share a name, and are the ones suggested for native elements.
|
|
138
|
-
*/
|
|
139
|
-
designSystems?: DesignSystemSource[] | undefined;
|
|
140
|
-
/** A Tailwind v3 config, which maps color classes to custom properties (`primary` → `hsl(var(--primary))`). */
|
|
141
|
-
tailwindConfig?: string | undefined;
|
|
142
|
-
elements: Record<string, string>;
|
|
143
|
-
/** `check` lints the component files themselves, which it skips by default. */
|
|
144
|
-
includeDesignSystem: boolean;
|
|
145
|
-
rules: Record<RuleId, ResolvedRule>;
|
|
146
|
-
/** Per-file rule settings, applied in order over `rules`. */
|
|
147
|
-
overrides?: ResolvedOverride[] | undefined;
|
|
148
|
-
/**
|
|
149
|
-
* The folder `overrides` globs are relative to, when it is not the root: the workspace
|
|
150
|
-
* root, for a project that takes its settings from a config there.
|
|
151
|
-
*/
|
|
152
|
-
base?: string | undefined;
|
|
153
|
-
/** `components` comes from the config file or `--components`, not from detection or the defaults. */
|
|
154
|
-
configured?: boolean | undefined;
|
|
155
|
-
/**
|
|
156
|
-
* What to tell the user about the config's name: a config file found under its name from
|
|
157
|
-
* before the rename to onsystem. The CLI prints these once per run, the server logs them once.
|
|
158
|
-
*/
|
|
159
|
-
deprecations?: string[] | undefined;
|
|
160
|
-
}
|
|
161
|
-
interface LoadConfigOptions {
|
|
162
|
-
/** Where to look for a config file when `root` and `config` are not given. */
|
|
163
|
-
cwd?: string;
|
|
164
|
-
/** Project root. Defaults to the config file's directory, then `cwd`. */
|
|
165
|
-
root?: string | undefined;
|
|
166
|
-
/** Explicit config file path. */
|
|
167
|
-
config?: string | undefined;
|
|
168
|
-
/**
|
|
169
|
-
* The folder the config file's paths and globs are written relative to, when it is not
|
|
170
|
-
* the root: a workspace root whose config a project in it takes on.
|
|
171
|
-
*/
|
|
172
|
-
base?: string | undefined;
|
|
173
|
-
/** CLI overrides; replace the config file's values when set. */
|
|
174
|
-
components?: string[] | undefined;
|
|
175
|
-
tokens?: string[] | undefined;
|
|
176
|
-
docs?: string[] | undefined;
|
|
177
|
-
includeDesignSystem?: boolean | undefined;
|
|
178
|
-
}
|
|
179
|
-
export declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
|
|
180
|
-
/** JSON Schema for editor completion in `onsystem.config.json`. */
|
|
181
|
-
export declare function configJsonSchema(): Record<string, unknown>;
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/types.d.ts
|
|
184
|
-
/**
|
|
185
|
-
* The design-system model the server exposes. Everything here is plain JSON so
|
|
186
|
-
* it can be cached on disk and returned as MCP structured content.
|
|
187
|
-
*/
|
|
188
|
-
declare const TOKEN_CATEGORIES: readonly ["color", "spacing", "radius", "typography", "shadow", "other"];
|
|
189
|
-
type TokenCategory = (typeof TOKEN_CATEGORIES)[number];
|
|
190
|
-
interface SourceLocation {
|
|
191
|
-
/** Path relative to the project root, with forward slashes. */
|
|
192
|
-
file: string;
|
|
193
|
-
/** 1-based line. */
|
|
194
|
-
line: number;
|
|
195
|
-
}
|
|
196
|
-
interface Token {
|
|
197
|
-
/**
|
|
198
|
-
* Canonical name: the DTCG path for JSON tokens (`color.brand.500`) or the
|
|
199
|
-
* custom property without its dashes for CSS tokens (`primary`, `radius-md`).
|
|
200
|
-
*/
|
|
201
|
-
name: string;
|
|
202
|
-
category: TokenCategory;
|
|
203
|
-
/** The value with aliases resolved, as authored (`oklch(0.205 0 0)`, `0.5rem`). */
|
|
204
|
-
value: string;
|
|
205
|
-
/** Values for other modes or themes, e.g. `{ dark: "oklch(0.922 0 0)" }`. */
|
|
206
|
-
modes?: Record<string, string>;
|
|
207
|
-
/** The custom property to reference from CSS, e.g. `--primary`. */
|
|
208
|
-
cssVar?: string;
|
|
209
|
-
/**
|
|
210
|
-
* Tailwind theme key when the token is exposed through `@theme`
|
|
211
|
-
* (`primary` for `--color-primary`, `md` for `--radius-md`).
|
|
212
|
-
*/
|
|
213
|
-
tailwind?: string;
|
|
214
|
-
/** Ready-to-paste usages, most idiomatic first: `bg-primary`, `var(--primary)`. */
|
|
215
|
-
usage: string[];
|
|
216
|
-
description?: string;
|
|
217
|
-
deprecated?: string | true;
|
|
218
|
-
/** Name of the token this one aliases, if any. */
|
|
219
|
-
aliasOf?: string;
|
|
220
|
-
/** Where the value comes from. `tailwind-default` marks Tailwind built-ins such as `--spacing`. */
|
|
221
|
-
origin?: 'tailwind-default';
|
|
222
|
-
source: SourceLocation;
|
|
223
|
-
}
|
|
224
|
-
interface PropInfo {
|
|
225
|
-
name: string;
|
|
226
|
-
/** TypeScript type as written by the checker, without `| undefined`. */
|
|
227
|
-
type: string;
|
|
228
|
-
required: boolean;
|
|
229
|
-
default?: string;
|
|
230
|
-
description?: string;
|
|
231
|
-
/** Allowed values when the type is a finite set of literals. */
|
|
232
|
-
values?: string[];
|
|
233
|
-
deprecated?: string | true;
|
|
234
|
-
/** `variant` when the prop comes from a `cva()` definition. */
|
|
235
|
-
kind: 'prop' | 'variant';
|
|
236
|
-
}
|
|
237
|
-
interface VariantInfo {
|
|
238
|
-
/** Variant prop name, e.g. `variant` or `size`. */
|
|
239
|
-
name: string;
|
|
240
|
-
values: string[];
|
|
241
|
-
default?: string;
|
|
242
|
-
/** Classes applied for each value, straight from the `cva()` config. */
|
|
243
|
-
classes: Record<string, string>;
|
|
244
|
-
}
|
|
245
|
-
interface CompoundVariantInfo {
|
|
246
|
-
when: Record<string, string | string[]>;
|
|
247
|
-
classes: string;
|
|
248
|
-
}
|
|
249
|
-
interface InheritedProps {
|
|
250
|
-
/** Source text of the type the props come from, e.g. `React.ComponentProps<"button">`. */
|
|
251
|
-
from: string;
|
|
252
|
-
count: number;
|
|
253
|
-
/** Key into `DesignSystemModel.propSets` with the full list of names. */
|
|
254
|
-
set: string;
|
|
255
|
-
/** Names in the set marked `@deprecated` (React Aria's `onClick`), left out of summaries. */
|
|
256
|
-
deprecated?: string[];
|
|
257
|
-
}
|
|
258
|
-
interface ExampleInfo {
|
|
259
|
-
title?: string;
|
|
260
|
-
code: string;
|
|
261
|
-
lang: string;
|
|
262
|
-
source: 'docs' | 'jsdoc';
|
|
263
|
-
}
|
|
264
|
-
interface DocSection {
|
|
265
|
-
heading: string;
|
|
266
|
-
body: string;
|
|
267
|
-
}
|
|
268
|
-
interface ComponentDocs {
|
|
269
|
-
file: string;
|
|
270
|
-
description?: string;
|
|
271
|
-
sections: DocSection[];
|
|
272
|
-
frontmatter: Record<string, string | string[]>;
|
|
273
|
-
}
|
|
274
|
-
interface ComponentInfo {
|
|
275
|
-
/** How the component is referenced in JSX: `Button`, `CardHeader` or `Tabs.List`. */
|
|
276
|
-
name: string;
|
|
277
|
-
/** Other names that resolve to the same component (e.g. `Card.Header` when `CardHeader` is also exported). */
|
|
278
|
-
aliases: string[];
|
|
279
|
-
description?: string;
|
|
280
|
-
deprecated?: string | true;
|
|
281
|
-
/** Suggested import specifier, e.g. `@/components/ui/button`. */
|
|
282
|
-
importPath: string;
|
|
283
|
-
/** Exported binding name, or the static member path for compound members. */
|
|
284
|
-
exportName: string;
|
|
285
|
-
source: SourceLocation;
|
|
286
|
-
/** The root component this one belongs to (`Card` for `CardHeader`). */
|
|
287
|
-
parent?: string;
|
|
288
|
-
/** Direct sub-components, in declaration order. */
|
|
289
|
-
subcomponents: string[];
|
|
290
|
-
/** Native element it renders or wraps, when it can be inferred (`button`, `input`). */
|
|
291
|
-
element?: string;
|
|
292
|
-
props: PropInfo[];
|
|
293
|
-
inherits: InheritedProps[];
|
|
294
|
-
/**
|
|
295
|
-
* True when part of the props type could not be resolved (missing
|
|
296
|
-
* `node_modules`, a type error). The linter then skips unknown-prop checks.
|
|
297
|
-
*/
|
|
298
|
-
openProps: boolean;
|
|
299
|
-
variants: VariantInfo[];
|
|
300
|
-
compoundVariants: CompoundVariantInfo[];
|
|
301
|
-
examples: ExampleInfo[];
|
|
302
|
-
docs?: ComponentDocs;
|
|
303
|
-
/** Utility classes used in the component source; mapped to tokens at query time. */
|
|
304
|
-
classNames: string[];
|
|
305
|
-
/** CSS custom properties referenced in the component source. */
|
|
306
|
-
cssVars: string[];
|
|
307
|
-
}
|
|
308
|
-
interface DesignSystemModel {
|
|
309
|
-
version: 1;
|
|
310
|
-
root: string;
|
|
311
|
-
components: ComponentInfo[];
|
|
312
|
-
tokens: Token[];
|
|
313
|
-
/** Shared inherited prop-name lists, deduplicated across components. */
|
|
314
|
-
propSets: Record<string, string[]>;
|
|
315
|
-
/**
|
|
316
|
-
* Every value the component files export, components or not (`Icons`,
|
|
317
|
-
* `buttonVariants`), so the linter tells an invented name from a real export.
|
|
318
|
-
*/
|
|
319
|
-
exports: string[];
|
|
320
|
-
/** Non-fatal problems found while extracting (unparseable files, unmatched docs). */
|
|
321
|
-
warnings: string[];
|
|
322
|
-
/**
|
|
323
|
-
* The component files extraction read, relative to the root: a name one of them exports
|
|
324
|
-
* that is not a component was seen, while a file outside them was never looked at.
|
|
325
|
-
*/
|
|
326
|
-
sources?: string[];
|
|
327
|
-
stats: {
|
|
328
|
-
files: {
|
|
329
|
-
components: number;
|
|
330
|
-
tokens: number;
|
|
331
|
-
docs: number;
|
|
332
|
-
};
|
|
333
|
-
durationMs: number;
|
|
334
|
-
fromCache: boolean;
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
type Severity = 'error' | 'warning';
|
|
338
|
-
interface TextEdit {
|
|
339
|
-
/** 0-based offsets into the checked source, end exclusive. */
|
|
340
|
-
range: [number, number];
|
|
341
|
-
text: string;
|
|
342
|
-
}
|
|
343
|
-
interface Diagnostic {
|
|
344
|
-
ruleId: string;
|
|
345
|
-
severity: Severity;
|
|
346
|
-
message: string;
|
|
347
|
-
/** 1-based. */
|
|
348
|
-
line: number;
|
|
349
|
-
/** 1-based. */
|
|
350
|
-
column: number;
|
|
351
|
-
endLine: number;
|
|
352
|
-
endColumn: number;
|
|
353
|
-
/** The offending source text. */
|
|
354
|
-
source: string;
|
|
355
|
-
/** What to write instead, e.g. `bg-destructive` or `<Button>`. */
|
|
356
|
-
suggestion?: string;
|
|
357
|
-
/** Edits that apply the suggestion, when it can be done mechanically. */
|
|
358
|
-
fix?: TextEdit[];
|
|
359
|
-
}
|
|
360
|
-
interface CheckResult {
|
|
361
|
-
file: string;
|
|
362
|
-
diagnostics: Diagnostic[];
|
|
363
|
-
errorCount: number;
|
|
364
|
-
warningCount: number;
|
|
365
|
-
/** With a baseline: findings it accepted, left out of `diagnostics` and the counts. */
|
|
366
|
-
baselined?: number;
|
|
367
|
-
/**
|
|
368
|
-
* Components imported from design-system modules the model does not include
|
|
369
|
-
* (extraction is incomplete), which the rules could not check.
|
|
370
|
-
*/
|
|
371
|
-
unchecked?: {
|
|
372
|
-
names: string[];
|
|
373
|
-
modules: string[];
|
|
374
|
-
};
|
|
375
|
-
/**
|
|
376
|
-
* Why the file was not checked: it renders outside the browser's CSS (an
|
|
377
|
-
* Open Graph image through next/og, an email through React Email), where
|
|
378
|
-
* design tokens and classes do not apply.
|
|
379
|
-
*/
|
|
380
|
-
skipped?: string;
|
|
381
|
-
}
|
|
382
|
-
//#endregion
|
|
383
5
|
//#region src/lint/analyze.d.ts
|
|
384
6
|
interface ImportBinding {
|
|
385
7
|
source: string;
|
|
@@ -493,6 +115,12 @@ export declare function parseCssTokens(css: string, file: string): {
|
|
|
493
115
|
warnings: string[];
|
|
494
116
|
};
|
|
495
117
|
//#endregion
|
|
118
|
+
//#region src/tokens/design-md.d.ts
|
|
119
|
+
export declare function parseDesignMd(text: string, file: string): {
|
|
120
|
+
tokens: Token[];
|
|
121
|
+
warnings: string[];
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
496
124
|
//#region src/tokens/dtcg.d.ts
|
|
497
125
|
interface DtcgOptions {
|
|
498
126
|
/** Prefix for generated custom property names: `ds` → `--ds-color-primary`. */
|
|
@@ -503,6 +131,34 @@ export declare function parseDtcgTokens(text: string, file: string, options?: Dt
|
|
|
503
131
|
warnings: string[];
|
|
504
132
|
};
|
|
505
133
|
//#endregion
|
|
134
|
+
//#region src/tokens/export.d.ts
|
|
135
|
+
/**
|
|
136
|
+
* Writes the tokens onsystem found as a DTCG 2025.10 file or a DESIGN.md. Both are grouped by
|
|
137
|
+
* category; reading the DTCG file back gives the same tokens, with the same names.
|
|
138
|
+
*/
|
|
139
|
+
interface Exported {
|
|
140
|
+
text: string;
|
|
141
|
+
/** How many tokens were written. */
|
|
142
|
+
count: number;
|
|
143
|
+
/** Tokens left out, and why. */
|
|
144
|
+
warnings: string[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The tokens as a DTCG 2025.10 file: a group per category, colors as color objects in their
|
|
148
|
+
* own color space, lengths as `{ value, unit }`, aliases as references, and what DTCG has no
|
|
149
|
+
* field for (the token's name, the custom property, the Tailwind theme variable, dark and
|
|
150
|
+
* other modes) under `$extensions["com.github.dgesteves.onsystem"]`.
|
|
151
|
+
*/
|
|
152
|
+
export declare function toDtcg(tokens: readonly Token[]): Exported;
|
|
153
|
+
/**
|
|
154
|
+
* The tokens as a DESIGN.md: front matter with the colors, typography, rounded corners and
|
|
155
|
+
* spacing in the spec's schema, then a heading per category with a table of its tokens, their
|
|
156
|
+
* values in each mode and how code uses them.
|
|
157
|
+
*/
|
|
158
|
+
export declare function toDesignMd(tokens: readonly Token[], options: {
|
|
159
|
+
name: string;
|
|
160
|
+
}): Exported;
|
|
161
|
+
//#endregion
|
|
506
162
|
//#region src/tokens/index.d.ts
|
|
507
163
|
interface TokenSource {
|
|
508
164
|
file: string;
|
|
@@ -639,6 +295,8 @@ declare class LintTarget {
|
|
|
639
295
|
private readonly moduleDirs;
|
|
640
296
|
/** The files extraction read, when the model says. */
|
|
641
297
|
private readonly sources?;
|
|
298
|
+
/** Published libraries the model read from type declarations: `@mui/material`. */
|
|
299
|
+
readonly libraries: Set<string>;
|
|
642
300
|
/**
|
|
643
301
|
* `resolver` finds the module an import points at and what it exports
|
|
644
302
|
* (`@calcom/ui/components/icon` → `components/icon/index.ts`), so a name from
|
|
@@ -694,6 +352,10 @@ declare class LintTarget {
|
|
|
694
352
|
/** The component a module exports as `default`, for `import Anything from "..."`. */
|
|
695
353
|
defaultExport(specifier: string, fromFile?: string): ComponentInfo | undefined;
|
|
696
354
|
private resolveRelative;
|
|
355
|
+
/** The library an import specifier points into (`@mui/material/Button`), if any. */
|
|
356
|
+
libraryOf(specifier: string): string | undefined;
|
|
357
|
+
/** The library's own component of that name: `Button` from `@mui/material`, not a wrapper. */
|
|
358
|
+
libraryComponent(name: string, library: string): ComponentInfo | undefined;
|
|
697
359
|
/** Component names for "did you mean" suggestions. */
|
|
698
360
|
names(): string[];
|
|
699
361
|
}
|
|
@@ -760,13 +422,18 @@ type Resolution =
|
|
|
760
422
|
kind: 'external';
|
|
761
423
|
};
|
|
762
424
|
//#endregion
|
|
425
|
+
//#region src/lint/rules/index.d.ts
|
|
426
|
+
/** Every rule, in the order they run. */
|
|
427
|
+
export declare const RULES: readonly Rule[];
|
|
428
|
+
//#endregion
|
|
763
429
|
//#region src/lint/format.d.ts
|
|
764
|
-
type OutputFormat = 'pretty' | 'json' | 'github';
|
|
430
|
+
type OutputFormat = 'pretty' | 'json' | 'github' | 'sarif';
|
|
765
431
|
/**
|
|
766
432
|
* Renders check results:
|
|
767
433
|
* - `pretty`: grouped by file, for terminals and agents,
|
|
768
434
|
* - `json`: the raw results,
|
|
769
|
-
* - `github`: workflow commands that GitHub Actions turns into PR annotations
|
|
435
|
+
* - `github`: workflow commands that GitHub Actions turns into PR annotations,
|
|
436
|
+
* - `sarif`: a SARIF 2.1.0 log, for GitHub code scanning and other SARIF consumers.
|
|
770
437
|
*/
|
|
771
438
|
export declare function formatDiagnostics(results: CheckResult[], format: OutputFormat, options?: {
|
|
772
439
|
color?: boolean;
|
|
@@ -776,10 +443,14 @@ export declare function formatDiagnostics(results: CheckResult[], format: Output
|
|
|
776
443
|
fixedHint?: string | undefined;
|
|
777
444
|
/** What the run left out: `5 design-system files skipped`, `12 tests and stories left out`. */
|
|
778
445
|
notes?: readonly string[] | undefined;
|
|
446
|
+
/**
|
|
447
|
+
* `sarif` and `github`: a result's file as a path relative to the repository root, which
|
|
448
|
+
* code scanning and workflow commands resolve locations against.
|
|
449
|
+
*/
|
|
450
|
+
uri?: ((file: string) => string) | undefined;
|
|
779
451
|
}): string;
|
|
780
452
|
//#endregion
|
|
781
453
|
//#region src/lint/index.d.ts
|
|
782
|
-
export declare const RULES: readonly Rule[];
|
|
783
454
|
interface CheckOptions {
|
|
784
455
|
/** File name used in results and to pick TSX vs JSX parsing. Default `snippet.tsx`. */
|
|
785
456
|
filename?: string | undefined;
|
|
@@ -849,6 +520,12 @@ export declare class DesignSystem {
|
|
|
849
520
|
readonly config: ResolvedConfig;
|
|
850
521
|
readonly lint: LintTarget;
|
|
851
522
|
private readonly searchIndex;
|
|
523
|
+
/**
|
|
524
|
+
* The components the tools offer: all of them, except a library's (MUI's) where the project
|
|
525
|
+
* has its own of that name, a wrapper the team means to be used. The rules still check code
|
|
526
|
+
* that imports the library's directly against the library's.
|
|
527
|
+
*/
|
|
528
|
+
private readonly offered;
|
|
852
529
|
constructor(model: DesignSystemModel, config: ResolvedConfig);
|
|
853
530
|
get root(): string;
|
|
854
531
|
get components(): ComponentInfo[];
|
|
@@ -867,6 +544,14 @@ export declare class DesignSystem {
|
|
|
867
544
|
}): Token[];
|
|
868
545
|
/** Tokens a component's classes and CSS variables reference, e.g. `bg-primary` → `primary`. */
|
|
869
546
|
relatedTokens(component: ComponentInfo): Token[];
|
|
547
|
+
/**
|
|
548
|
+
* Whether `check --require-design-system` (and the GitHub Action, where it is on by default)
|
|
549
|
+
* finds a design system to check against: components and color tokens, or components from a
|
|
550
|
+
* published library (MUI). A library is the design system whatever its theme: when the theme's
|
|
551
|
+
* colors cannot be read (a palette from Sass variables), the check still runs and `notice()`
|
|
552
|
+
* says that no-hardcoded-color did not.
|
|
553
|
+
*/
|
|
554
|
+
hasDesignSystem(): boolean;
|
|
870
555
|
/**
|
|
871
556
|
* What the rules could not check, when it matters: without components the
|
|
872
557
|
* component rules find nothing, and without color tokens neither does
|
|
@@ -1086,14 +771,17 @@ declare class Catalog {
|
|
|
1086
771
|
//#region src/server/index.d.ts
|
|
1087
772
|
export declare const INSTRUCTIONS = "This server describes the project's design system: its React components (props, variants, parts), design tokens and usage docs, and lints UI code against it.\nWhen writing or changing UI in this project:\n1. Find components with search_components (by intent) or list_components.\n2. Read get_component before using a component: use only the props and variant values it lists.\n3. Style with tokens from get_tokens, never with hex/rgb colors, arbitrary px values or Tailwind's default palette.\n4. Run check_ui on every snippet or file you write and fix all errors before you finish.\nIn a monorepo served from its root, pass `path` (the file you are editing) to list_components, get_component, search_components and get_tokens, and `path` or `filename` to check_ui, so each answer comes from that file's own project.";
|
|
1088
773
|
interface CreateServerOptions {
|
|
1089
|
-
/**
|
|
1090
|
-
|
|
774
|
+
/**
|
|
775
|
+
* Resolves the design system to serve. Called per request, so it can be swapped on reload.
|
|
776
|
+
* `target` is the `path` (or `filename`) the request names, if any, as given.
|
|
777
|
+
*/
|
|
778
|
+
getDesignSystem: (target?: string) => Promise<DesignSystem>;
|
|
1091
779
|
/**
|
|
1092
780
|
* At a workspace root: its projects. When this resolves to a set, the tools take a `path`
|
|
1093
781
|
* to pick a project and serve every project together without one, and `getDesignSystem`
|
|
1094
|
-
* is not called.
|
|
782
|
+
* is not called. `target` is the `path` (or `filename`) the request names, if any.
|
|
1095
783
|
*/
|
|
1096
|
-
getProjects?: () => Promise<ProjectSet | undefined>;
|
|
784
|
+
getProjects?: (target?: string) => Promise<ProjectSet | undefined>;
|
|
1097
785
|
}
|
|
1098
786
|
/** Builds the MCP server: five tools, two resources and one prompt. Transport-agnostic. */
|
|
1099
787
|
export declare function createServer({ getDesignSystem, getProjects }: CreateServerOptions): McpServer;
|
|
@@ -1123,10 +811,19 @@ interface ServerHandle {
|
|
|
1123
811
|
* deprecates, are the fallback for a 2025-era client that starts servers somewhere
|
|
1124
812
|
* else (Claude Desktop starts them in `/`): its first `file://` root. At a monorepo
|
|
1125
813
|
* root with no design system of its own, every project in it is served.
|
|
814
|
+
*
|
|
815
|
+
* When none of those gives a project (a client that starts servers in the home or the
|
|
816
|
+
* plugin's folder and reports no roots), each request's project is found from the
|
|
817
|
+
* absolute path it names (`findProjectRoot`): the nearest folder at or above it with a
|
|
818
|
+
* project marker, or the monorepo root above that, served as if the server had been
|
|
819
|
+
* started there, except that a config there is read only when it is JSON: a prompt can
|
|
820
|
+
* choose the path, so a JavaScript or TypeScript config is not run. Each root found is
|
|
821
|
+
* loaded once and kept; a request without an absolute path is answered from the one root
|
|
822
|
+
* found so far.
|
|
1126
823
|
*/
|
|
1127
824
|
export declare function serveStdio(options: ServeOptions): Promise<ServerHandle>;
|
|
1128
825
|
//#endregion
|
|
1129
826
|
//#region src/version.d.ts
|
|
1130
827
|
export declare const VERSION: string;
|
|
1131
828
|
//#endregion
|
|
1132
|
-
export type
|
|
829
|
+
export { type CheckResult, type ComponentDocs, type ComponentInfo, type CompoundVariantInfo, type Config, type DesignSystemModel, type Diagnostic, type DocSection, type ExampleInfo, type HostOptions, type InheritedProps, type LoadConfigOptions, type LoadOptions, type OutputFormat, type PropInfo, RULE_IDS, type ResolvedConfig, type RuleId, type Severity, type SourceLocation, type TOKEN_CATEGORIES, type TextEdit, type Token, type TokenCategory, type VariantInfo, configJsonSchema, defineConfig, loadConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { $ as findVariantDefinitions, A as toDtcg, D as loadTokens, E as TokenIndex, F as attachDocs, G as RULE_IDS, I as parseDoc, K as configJsonSchema, L as extractComponents, M as parseDtcgTokens, N as parseDesignMd, O as mergeTokens, P as parseCssTokens, T as RULES, Y as loadConfig, _ as VERSION, a as fingerprint, d as searchComponents, f as applyFixes, h as formatDiagnostics, k as toDesignMd, n as DesignSystemHost, o as loadDesignSystem, p as checkSource, q as defineConfig, r as buildModel, t as DesignSystem } from "./design-system-A3pRX3Ka.js";
|
|
2
|
+
import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-CEChNFLR.js";
|
|
3
|
+
export { DesignSystem, DesignSystemHost, INSTRUCTIONS, RULES, RULE_IDS, TokenIndex, VERSION, applyFixes, attachDocs, buildModel, checkSource, configJsonSchema, createServer, defineConfig, extractComponents, findVariantDefinitions, fingerprint, formatDiagnostics, loadConfig, loadDesignSystem, loadTokens, mergeTokens, parseCssTokens, parseDesignMd, parseDoc, parseDtcgTokens, searchComponents, serveStdio, toDesignMd, toDtcg };
|