onsystem 0.4.0 → 0.5.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 +18 -14
- package/dist/cli.js +42 -152
- package/dist/{stdio-BcJth14k.js → design-system-CnEv5sIL.js} +311 -1531
- package/dist/eslint-worker.d.ts +36 -0
- package/dist/eslint-worker.js +88 -0
- package/dist/eslint.d.ts +23 -0
- package/dist/eslint.js +172 -0
- package/dist/index.d.ts +30 -387
- package/dist/index.js +2 -1
- package/dist/stdio-DjfkiDMV.js +1399 -0
- package/dist/types-DJtccu3A.d.ts +386 -0
- package/dist/workspace-DzWQ4L8R.js +193 -0
- package/package.json +20 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,385 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { C as RuleId, D as loadConfig, E as defineConfig, O as ImportMapping, S as ResolvedRule, T as configJsonSchema, _ as VariantInfo, a as DesignSystemModel, b as RULE_IDS, c as ExampleInfo, d as Severity, f as SourceLocation, g as TokenCategory, h as Token, i as CompoundVariantInfo, l as InheritedProps, m as TextEdit, n as ComponentDocs, o as Diagnostic, p as TOKEN_CATEGORIES, r as ComponentInfo, s as DocSection, t as CheckResult, u as PropInfo, v as Config, w as RuleOptions, x as ResolvedConfig, y as LoadConfigOptions } from "./types-DJtccu3A.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;
|
|
@@ -760,13 +382,18 @@ type Resolution =
|
|
|
760
382
|
kind: 'external';
|
|
761
383
|
};
|
|
762
384
|
//#endregion
|
|
385
|
+
//#region src/lint/rules/index.d.ts
|
|
386
|
+
/** Every rule, in the order they run. */
|
|
387
|
+
export declare const RULES: readonly Rule[];
|
|
388
|
+
//#endregion
|
|
763
389
|
//#region src/lint/format.d.ts
|
|
764
|
-
type OutputFormat = 'pretty' | 'json' | 'github';
|
|
390
|
+
type OutputFormat = 'pretty' | 'json' | 'github' | 'sarif';
|
|
765
391
|
/**
|
|
766
392
|
* Renders check results:
|
|
767
393
|
* - `pretty`: grouped by file, for terminals and agents,
|
|
768
394
|
* - `json`: the raw results,
|
|
769
|
-
* - `github`: workflow commands that GitHub Actions turns into PR annotations
|
|
395
|
+
* - `github`: workflow commands that GitHub Actions turns into PR annotations,
|
|
396
|
+
* - `sarif`: a SARIF 2.1.0 log, for GitHub code scanning and other SARIF consumers.
|
|
770
397
|
*/
|
|
771
398
|
export declare function formatDiagnostics(results: CheckResult[], format: OutputFormat, options?: {
|
|
772
399
|
color?: boolean;
|
|
@@ -776,10 +403,14 @@ export declare function formatDiagnostics(results: CheckResult[], format: Output
|
|
|
776
403
|
fixedHint?: string | undefined;
|
|
777
404
|
/** What the run left out: `5 design-system files skipped`, `12 tests and stories left out`. */
|
|
778
405
|
notes?: readonly string[] | undefined;
|
|
406
|
+
/**
|
|
407
|
+
* `sarif` and `github`: a result's file as a path relative to the repository root, which
|
|
408
|
+
* code scanning and workflow commands resolve locations against.
|
|
409
|
+
*/
|
|
410
|
+
uri?: ((file: string) => string) | undefined;
|
|
779
411
|
}): string;
|
|
780
412
|
//#endregion
|
|
781
413
|
//#region src/lint/index.d.ts
|
|
782
|
-
export declare const RULES: readonly Rule[];
|
|
783
414
|
interface CheckOptions {
|
|
784
415
|
/** File name used in results and to pick TSX vs JSX parsing. Default `snippet.tsx`. */
|
|
785
416
|
filename?: string | undefined;
|
|
@@ -1086,14 +717,17 @@ declare class Catalog {
|
|
|
1086
717
|
//#region src/server/index.d.ts
|
|
1087
718
|
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
719
|
interface CreateServerOptions {
|
|
1089
|
-
/**
|
|
1090
|
-
|
|
720
|
+
/**
|
|
721
|
+
* Resolves the design system to serve. Called per request, so it can be swapped on reload.
|
|
722
|
+
* `target` is the `path` (or `filename`) the request names, if any, as given.
|
|
723
|
+
*/
|
|
724
|
+
getDesignSystem: (target?: string) => Promise<DesignSystem>;
|
|
1091
725
|
/**
|
|
1092
726
|
* At a workspace root: its projects. When this resolves to a set, the tools take a `path`
|
|
1093
727
|
* to pick a project and serve every project together without one, and `getDesignSystem`
|
|
1094
|
-
* is not called.
|
|
728
|
+
* is not called. `target` is the `path` (or `filename`) the request names, if any.
|
|
1095
729
|
*/
|
|
1096
|
-
getProjects?: () => Promise<ProjectSet | undefined>;
|
|
730
|
+
getProjects?: (target?: string) => Promise<ProjectSet | undefined>;
|
|
1097
731
|
}
|
|
1098
732
|
/** Builds the MCP server: five tools, two resources and one prompt. Transport-agnostic. */
|
|
1099
733
|
export declare function createServer({ getDesignSystem, getProjects }: CreateServerOptions): McpServer;
|
|
@@ -1123,10 +757,19 @@ interface ServerHandle {
|
|
|
1123
757
|
* deprecates, are the fallback for a 2025-era client that starts servers somewhere
|
|
1124
758
|
* else (Claude Desktop starts them in `/`): its first `file://` root. At a monorepo
|
|
1125
759
|
* root with no design system of its own, every project in it is served.
|
|
760
|
+
*
|
|
761
|
+
* When none of those gives a project (a client that starts servers in the home or the
|
|
762
|
+
* plugin's folder and reports no roots), each request's project is found from the
|
|
763
|
+
* absolute path it names (`findProjectRoot`): the nearest folder at or above it with a
|
|
764
|
+
* project marker, or the monorepo root above that, served as if the server had been
|
|
765
|
+
* started there, except that a config there is read only when it is JSON: a prompt can
|
|
766
|
+
* choose the path, so a JavaScript or TypeScript config is not run. Each root found is
|
|
767
|
+
* loaded once and kept; a request without an absolute path is answered from the one root
|
|
768
|
+
* found so far.
|
|
1126
769
|
*/
|
|
1127
770
|
export declare function serveStdio(options: ServeOptions): Promise<ServerHandle>;
|
|
1128
771
|
//#endregion
|
|
1129
772
|
//#region src/version.d.ts
|
|
1130
773
|
export declare const VERSION: string;
|
|
1131
774
|
//#endregion
|
|
1132
|
-
export type
|
|
775
|
+
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 {
|
|
1
|
+
import { A as parseDtcgTokens, D as loadTokens, E as TokenIndex, G as loadConfig, H as RULE_IDS, M as attachDocs, N as parseDoc, O as mergeTokens, P as extractComponents, T as RULES, U as configJsonSchema, W as defineConfig, _ as VERSION, a as fingerprint, d as searchComponents, f as applyFixes, h as formatDiagnostics, j as parseCssTokens, n as DesignSystemHost, o as loadDesignSystem, p as checkSource, q as findVariantDefinitions, r as buildModel, t as DesignSystem } from "./design-system-CnEv5sIL.js";
|
|
2
|
+
import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-DjfkiDMV.js";
|
|
2
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, parseDoc, parseDtcgTokens, searchComponents, serveStdio };
|