onsystem 0.0.0-stage → 0.4.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.
@@ -0,0 +1,1132 @@
1
+ import * as z from "zod";
2
+ import ts from "typescript";
3
+ import { Oklch } from "culori";
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
+ //#region src/lint/analyze.d.ts
384
+ interface ImportBinding {
385
+ source: string;
386
+ /** Imported name, `default`, or `*` for namespace imports. */
387
+ imported: string;
388
+ }
389
+ interface JsxNode {
390
+ node: ts.JsxElement | ts.JsxSelfClosingElement;
391
+ opening: ts.JsxOpeningElement | ts.JsxSelfClosingElement;
392
+ closing?: ts.JsxClosingElement | undefined;
393
+ tagName: ts.JsxTagNameExpression;
394
+ /** Tag as written: `button`, `Button`, `Card.Header`. */
395
+ tag: string;
396
+ attributes: ts.JsxAttribute[];
397
+ hasSpread: boolean;
398
+ children: readonly ts.JsxChild[];
399
+ }
400
+ /** A run of literal class text with its absolute offset in the source. */
401
+ interface ClassString {
402
+ text: string;
403
+ start: number;
404
+ /** The JSX element whose `className` this is, if any. */
405
+ element?: JsxNode | undefined;
406
+ }
407
+ interface StyleObject {
408
+ element: JsxNode;
409
+ object: ts.ObjectLiteralExpression;
410
+ }
411
+ interface Analysis {
412
+ imports: Map<string, ImportBinding>;
413
+ declared: Set<string>;
414
+ elements: JsxNode[];
415
+ classStrings: ClassString[];
416
+ styles: StyleObject[];
417
+ }
418
+ //#endregion
419
+ //#region src/modules.d.ts
420
+ /** Where an import points: a file relative to the root, or `{}` for a declared module not on disk. */
421
+ interface ModuleLocation {
422
+ file?: string;
423
+ }
424
+ /** What a module exports by name, and the modules it re-exports wholesale (`export * from`). */
425
+ interface ModuleExports {
426
+ /** Every name it exports, its own and re-exported ones. */
427
+ names: string[];
428
+ /** The names it declares itself (`export function Table`), not re-exports. */
429
+ declared: string[];
430
+ /** Files relative to the root; undefined where the specifier does not resolve. */
431
+ starFrom: (string | undefined)[];
432
+ /**
433
+ * Names it re-exports from another module, and under which name that module exports
434
+ * them: `export { Button } from "./Button"`, `export { Root as Dialog } from "./dialog"`,
435
+ * or an imported binding exported again. `from` is undefined where it does not resolve.
436
+ */
437
+ reexports: Map<string, {
438
+ from: string | undefined;
439
+ name: string;
440
+ }>;
441
+ /** Names it exports as a module namespace (`export * as Radio from "./radio"`), not a component. */
442
+ namespaces: Set<string>;
443
+ }
444
+ /**
445
+ * Finds the modules a checked file imports from the design system, and what
446
+ * they export, so the linter can tell a name the model left out (an excluded
447
+ * folder, a package built to `dist/`) from an invented one. It resolves through
448
+ * tsconfig `paths`, relative paths and workspace packages, reads files only
449
+ * when asked, and caches both. Where the root is not on disk (the website's
450
+ * playground), it finds nothing, and every missing name counts as invented.
451
+ */
452
+ declare class ModuleResolver {
453
+ private readonly config;
454
+ private resolveFn?;
455
+ private readonly locations;
456
+ private readonly exported;
457
+ constructor(config: Pick<ResolvedConfig, 'root' | 'tsconfig'>);
458
+ /** The module `specifier` points at from `fromFile` (relative to the root). */
459
+ locate(specifier: string, fromFile: string): ModuleLocation | undefined;
460
+ /** What a module exports, read from its source without type-checking. */
461
+ exportsOf(file: string): ModuleExports | undefined;
462
+ private createResolver;
463
+ }
464
+ //#endregion
465
+ //#region src/tokens/roles.d.ts
466
+ /**
467
+ * What a color utility paints, which decides the tokens that fit it: `text-*`
468
+ * wants a foreground, `bg-*` a surface, `border-*` a border color.
469
+ */
470
+ type ColorRole = 'text' | 'surface' | 'line';
471
+ /**
472
+ * Token families made for one part of the UI. `sidebar-accent` has the value
473
+ * of `accent` and `chart-2` that of `muted-foreground`, but they only belong
474
+ * in a sidebar or a chart. Beyond these two, any family that is not named for
475
+ * a role and that at most one design-system file uses is scoped the same way:
476
+ * syntax-highlighting colors (`sh-class`), a chart palette (`rainbow-4`), one
477
+ * screen's background (`envelope-editor-background`), or a copy of Tailwind's
478
+ * palette (`color-red-500`).
479
+ */
480
+ type ScopedFamily = string;
481
+ //#endregion
482
+ //#region src/tokens/css.d.ts
483
+ /**
484
+ * Reads design tokens from CSS custom properties, the way shadcn/ui and
485
+ * Tailwind v4 projects define them:
486
+ *
487
+ * - `:root { --primary: oklch(...) }` holds the values,
488
+ * - `.dark { --primary: ... }` (or a dark media query / data attribute) holds modes,
489
+ * - `@theme inline { --color-primary: var(--primary) }` exposes them to Tailwind.
490
+ */
491
+ export declare function parseCssTokens(css: string, file: string): {
492
+ tokens: Token[];
493
+ warnings: string[];
494
+ };
495
+ //#endregion
496
+ //#region src/tokens/dtcg.d.ts
497
+ interface DtcgOptions {
498
+ /** Prefix for generated custom property names: `ds` → `--ds-color-primary`. */
499
+ prefix?: string;
500
+ }
501
+ export declare function parseDtcgTokens(text: string, file: string, options?: DtcgOptions): {
502
+ tokens: Token[];
503
+ warnings: string[];
504
+ };
505
+ //#endregion
506
+ //#region src/tokens/index.d.ts
507
+ interface TokenSource {
508
+ file: string;
509
+ /** DTCG only: prefix for generated custom property names. */
510
+ prefix?: string | undefined;
511
+ }
512
+ export declare function loadTokens(root: string, sources: TokenSource[]): Promise<{
513
+ tokens: Token[];
514
+ warnings: string[];
515
+ }>;
516
+ /**
517
+ * DTCG files and the CSS generated from them often describe the same tokens.
518
+ * Merge entries that share a custom property: keep the DTCG name and
519
+ * description, and add the Tailwind mapping from CSS.
520
+ */
521
+ export declare function mergeTokens(tokens: Token[]): Token[];
522
+ interface ColorCandidate {
523
+ token: Token;
524
+ color: Oklch;
525
+ /** Values in other theme modes (`dark`), where the token has one. */
526
+ modes?: Record<string, Oklch>;
527
+ }
528
+ interface LengthCandidate {
529
+ token: Token;
530
+ px: number;
531
+ /** Tailwind key for the step (`3` for `p-3`, `md` for `rounded-md`), if any. */
532
+ key?: string;
533
+ }
534
+ interface Nearest<T> {
535
+ candidate: T;
536
+ distance: number;
537
+ }
538
+ interface ColorQuery {
539
+ /** What the color paints: `text-*` is best served by a foreground, `bg-*` by a surface. */
540
+ role?: ColorRole | undefined;
541
+ /** The scoped families the code is in (`sidebar` in `app-sidebar.tsx`), whose tokens then compete like any other. */
542
+ scopes?: ReadonlySet<ScopedFamily> | undefined;
543
+ /** Whether the color is a hue rather than a gray. Default: from its chroma. */
544
+ tinted?: boolean | undefined;
545
+ /** The theme mode the color applies in (`dark` for `dark:bg-*`): tokens are compared by their value there. */
546
+ mode?: string | undefined;
547
+ }
548
+ interface ColorSuggestion {
549
+ /** A token that can replace the color as is: close, of the same hue (or both gray), and not made for another role. */
550
+ match?: Nearest<ColorCandidate> | undefined;
551
+ /** The token to name: the match, else the nearest, preferring the same hue and the role. */
552
+ nearest: Nearest<ColorCandidate>;
553
+ /**
554
+ * Why the nearest token is no match: no token of its hue (or no gray), too far,
555
+ * made for another role, a status color whose hue is not close enough, or a
556
+ * token of a family scoped to another part of the UI.
557
+ */
558
+ reason?: 'far' | 'hue' | 'role' | 'status' | 'scoped' | undefined;
559
+ /** With reason `status`: how far apart the hues are, in degrees. */
560
+ hueOff?: number | undefined;
561
+ /** Other tokens with the nearest one's value. */
562
+ sameValue: Token[];
563
+ }
564
+ interface NearestLength extends Nearest<LengthCandidate> {
565
+ /** A radius so far above the scale that it means "fully rounded" (`rounded-full`). */
566
+ pill?: boolean;
567
+ }
568
+ /** Query helpers over the token list: lookups and nearest-token search. */
569
+ export declare class TokenIndex {
570
+ readonly tokens: Token[];
571
+ readonly colors: ColorCandidate[];
572
+ readonly spacing: LengthCandidate[];
573
+ readonly radius: LengthCandidate[];
574
+ /** Tailwind color keys the design system defines (`primary`, `muted-foreground`). */
575
+ readonly colorKeys: Set<string>;
576
+ /** Base unit when spacing follows Tailwind's multiplier model. */
577
+ readonly spacingUnitPx: number | undefined;
578
+ private readonly spacingUnit;
579
+ private readonly byVar;
580
+ /** Families suggested only in their own part of the UI (`sidebar`, `chart`, `sh`). */
581
+ readonly scopedFamilies: ReadonlySet<ScopedFamily>;
582
+ /** Family → the design-system files that use its tokens. */
583
+ readonly familyFiles: ReadonlyMap<string, ReadonlySet<string>>;
584
+ /**
585
+ * `filesUsing` maps each token family to the design-system files that use it;
586
+ * a family that at most one of them uses is scoped. Without it, only sidebar
587
+ * and chart are.
588
+ */
589
+ constructor(tokens: Token[], options?: {
590
+ filesUsing?: ReadonlyMap<string, ReadonlySet<string>> | undefined;
591
+ });
592
+ has(category: TokenCategory): boolean;
593
+ byCssVar(name: string): Token | undefined;
594
+ /** The scoped family a token belongs to, if any. */
595
+ scopedFamilyOf(token: Token): ScopedFamily | undefined;
596
+ nearestColor(color: Oklch, limit?: number): Nearest<ColorCandidate>[];
597
+ /**
598
+ * The token to suggest for a color. Perceptual distance alone picks badly:
599
+ * several tokens share a value (`muted`, `accent`, `sidebar-accent`,
600
+ * `chart-2`...), and a pale yellow sits 0.07 from a light gray. So among the
601
+ * tokens close enough to swap in, of the same hue, it prefers the ones made
602
+ * for the role (`muted-foreground` for `text-gray-500`), and sidebar and
603
+ * chart tokens only in a sidebar or a chart.
604
+ */
605
+ suggestColor(color: Oklch, query?: ColorQuery): ColorSuggestion | undefined;
606
+ /** The step closest to the magnitude of `px`; callers keep the sign. */
607
+ nearestLength(category: 'spacing' | 'radius', px: number): NearestLength | undefined;
608
+ /**
609
+ * Tailwind v4 derives `p-<n>` from `--spacing` for any n. Whole and half
610
+ * steps (`p-13`, `p-4.5`) count as the scale, plus the static `p-px`;
611
+ * quarter steps are valid but off-grid, like the arbitrary values they replace.
612
+ */
613
+ private spacingSteps;
614
+ /** px value of a token-like length string, resolving `var()` against the token set. */
615
+ toPx(value: string): number | undefined;
616
+ }
617
+ //#endregion
618
+ //#region src/lint/target.d.ts
619
+ /** What the lint rules need to know about the design system. */
620
+ declare class LintTarget {
621
+ readonly model: DesignSystemModel;
622
+ readonly config: Pick<ResolvedConfig, 'elements' | 'importPath'> & Partial<Pick<ResolvedConfig, 'designSystems'>>;
623
+ private readonly resolver?;
624
+ readonly components: Map<string, ComponentInfo>;
625
+ /** Every component under each name and alias, when two design systems share one (`Button`). */
626
+ private readonly named;
627
+ readonly tokens: TokenIndex;
628
+ /** Native element → the component that replaces it. */
629
+ readonly elements: Map<string, ComponentInfo>;
630
+ /** The `elements` entries the config sets explicitly. */
631
+ private readonly configured;
632
+ readonly componentFiles: Set<string>;
633
+ /** Every value the component files export, components or not (`Icons`, `buttonVariants`). */
634
+ readonly exports: Set<string>;
635
+ private readonly importPaths;
636
+ private readonly importPrefixes;
637
+ /** Component files relative to the root, without extension (`components/ui/button`). */
638
+ private readonly componentModules;
639
+ private readonly moduleDirs;
640
+ /** The files extraction read, when the model says. */
641
+ private readonly sources?;
642
+ /**
643
+ * `resolver` finds the module an import points at and what it exports
644
+ * (`@calcom/ui/components/icon` → `components/icon/index.ts`), so a name from
645
+ * a module the model left out is not taken for an invented one. Without it,
646
+ * every missing name is invented.
647
+ */
648
+ constructor(model: DesignSystemModel, config: Pick<ResolvedConfig, 'elements' | 'importPath'> & Partial<Pick<ResolvedConfig, 'designSystems'>>, resolver?: Pick<ModuleResolver, "locate" | "exportsOf"> | undefined);
649
+ /**
650
+ * Whether an import specifier points at the design system. Relative
651
+ * specifiers are resolved against `fromFile` (relative to the root) and
652
+ * must land on a component file, in a directory that holds one, or on that
653
+ * directory itself (a barrel: `../components/ui` and its index).
654
+ */
655
+ isDesignSystemImport(specifier: string, fromFile?: string): boolean;
656
+ /**
657
+ * Whether `name`, imported from the design system, may be a real export the
658
+ * model left out rather than an invented one: its module exists outside the
659
+ * folders extraction read and exports `name`, or re-exports from such a
660
+ * module (an excluded `icons/` folder, a barrel's `export * from "./icons"`).
661
+ * A module declared in a package's `exports` but not on disk counts too,
662
+ * except the design system's own import path.
663
+ */
664
+ outsideModel(specifier: string, name: string, fromFile?: string): boolean;
665
+ /**
666
+ * The component a JSX tag means when `name` is imported from `specifier`, among the
667
+ * model's components of that name: the one declared where the import leads, through
668
+ * barrels (`export { Button } from "./Button"`, `export *`). `undefined` when it leads to
669
+ * a declaration the model does not have (another package's `Button`, or a file of the
670
+ * same name outside the component folders), which is not ours to check. Where the import
671
+ * cannot be followed, the component of that name, as before.
672
+ */
673
+ componentFor(name: string, specifier: string, fromFile: string): ComponentInfo | undefined;
674
+ /**
675
+ * Where what `file` exports as `name` is declared, following re-exports: the file
676
+ * (relative to the root) and its name there, `{ namespace }` for a module namespace,
677
+ * `undefined` when it does not export it, `null` when a step of the way does not
678
+ * resolve or cannot be read.
679
+ */
680
+ private originOf;
681
+ private mayExport;
682
+ /**
683
+ * Whether `<Component>` can replace the native element `key` (`a`,
684
+ * `input[type=checkbox]`) by renaming the tag: the config maps it, it
685
+ * renders that element, or it takes the element's own attributes.
686
+ */
687
+ isDropIn(component: ComponentInfo, key: string): boolean;
688
+ /**
689
+ * Whether a component asks for nothing beyond what the element takes: no
690
+ * required prop of its own, and the element's own attributes (`htmlFor` for a
691
+ * label). Unknown when its props do not fully resolve, so false.
692
+ */
693
+ private plainFor;
694
+ /** The component a module exports as `default`, for `import Anything from "..."`. */
695
+ defaultExport(specifier: string, fromFile?: string): ComponentInfo | undefined;
696
+ private resolveRelative;
697
+ /** Component names for "did you mean" suggestions. */
698
+ names(): string[];
699
+ }
700
+ //#endregion
701
+ //#region src/lint/context.d.ts
702
+ interface Report {
703
+ start: number;
704
+ end: number;
705
+ message: string;
706
+ suggestion?: string | undefined;
707
+ fix?: TextEdit[] | undefined;
708
+ /** Rules may downgrade (never upgrade) their configured severity for low-confidence findings. */
709
+ severity?: Severity;
710
+ }
711
+ interface RuleContext {
712
+ file: string;
713
+ text: string;
714
+ sourceFile: ts.SourceFile;
715
+ target: LintTarget;
716
+ analysis: Analysis;
717
+ options: RuleOptions;
718
+ /** True when the checked file is one of the design system's own component sources. */
719
+ isDesignSystemSource: boolean;
720
+ resolve(element: JsxNode): Resolution;
721
+ report(report: Report): void;
722
+ /** Records a component the model does not include, which the rules cannot check. */
723
+ unchecked(name: string, module: string): void;
724
+ }
725
+ interface Rule {
726
+ id: RuleId;
727
+ description: string;
728
+ run(context: RuleContext): void;
729
+ }
730
+ type Resolution =
731
+ /** A design-system component. */
732
+ {
733
+ kind: 'component';
734
+ component: ComponentInfo;
735
+ } |
736
+ /** A lowercase JSX tag. */
737
+ {
738
+ kind: 'intrinsic';
739
+ tag: string;
740
+ } |
741
+ /** Imported from the design system's path, but the design system has no such component. */
742
+ {
743
+ kind: 'missing-export';
744
+ name: string;
745
+ source: string;
746
+ } |
747
+ /** `Card.Header` where `Card` is a design-system component without that member. */
748
+ {
749
+ kind: 'missing-member';
750
+ owner: ComponentInfo;
751
+ member: string;
752
+ } |
753
+ /** Not imported, not declared and not a design-system component. */
754
+ {
755
+ kind: 'unresolved';
756
+ name: string;
757
+ } |
758
+ /** Imported from elsewhere or declared locally: not our business. */
759
+ {
760
+ kind: 'external';
761
+ };
762
+ //#endregion
763
+ //#region src/lint/format.d.ts
764
+ type OutputFormat = 'pretty' | 'json' | 'github';
765
+ /**
766
+ * Renders check results:
767
+ * - `pretty`: grouped by file, for terminals and agents,
768
+ * - `json`: the raw results,
769
+ * - `github`: workflow commands that GitHub Actions turns into PR annotations.
770
+ */
771
+ export declare function formatDiagnostics(results: CheckResult[], format: OutputFormat, options?: {
772
+ color?: boolean;
773
+ /** Findings a baseline accepted; set when a baseline was applied. */
774
+ baselined?: number | undefined;
775
+ /** Says that baseline entries no longer occur, and how to drop them. */
776
+ fixedHint?: string | undefined;
777
+ /** What the run left out: `5 design-system files skipped`, `12 tests and stories left out`. */
778
+ notes?: readonly string[] | undefined;
779
+ }): string;
780
+ //#endregion
781
+ //#region src/lint/index.d.ts
782
+ export declare const RULES: readonly Rule[];
783
+ interface CheckOptions {
784
+ /** File name used in results and to pick TSX vs JSX parsing. Default `snippet.tsx`. */
785
+ filename?: string | undefined;
786
+ rules: Record<RuleId, ResolvedRule>;
787
+ }
788
+ /**
789
+ * Lints a TSX/JSX snippet or file against the design system. Purely
790
+ * syntactic: no type-checking of the snippet, so it works on fragments an
791
+ * agent has not saved yet.
792
+ */
793
+ export declare function checkSource(code: string, target: LintTarget, options: CheckOptions): CheckResult;
794
+ /** Applies non-overlapping fixes from the end of the file backwards. */
795
+ export declare function applyFixes(code: string, diagnostics: Diagnostic[]): string;
796
+ //#endregion
797
+ //#region src/search/bm25.d.ts
798
+ /**
799
+ * Okapi BM25 over weighted fields (BM25F-style: field weights scale term
800
+ * frequency and document length). Small, dependency-free and deterministic,
801
+ * which is what a local tool index of a few hundred documents needs.
802
+ */
803
+ interface Bm25Options {
804
+ k1?: number;
805
+ b?: number;
806
+ }
807
+ interface Bm25Hit<T> {
808
+ item: T;
809
+ score: number;
810
+ /** Matched query terms, best first. */
811
+ terms: string[];
812
+ }
813
+ declare class Bm25Index<T> {
814
+ private readonly docs;
815
+ private readonly df;
816
+ private totalLength;
817
+ private readonly k1;
818
+ private readonly b;
819
+ constructor(options?: Bm25Options);
820
+ /** Adds a document as `[terms, weight]` fields. */
821
+ add(item: T, fields: [terms: string[], weight: number][]): void;
822
+ get size(): number;
823
+ search(query: Map<string, number>, limit?: number): Bm25Hit<T>[];
824
+ }
825
+ //#endregion
826
+ //#region src/search/index.d.ts
827
+ interface SearchHit {
828
+ component: ComponentInfo;
829
+ score: number;
830
+ matched: string[];
831
+ }
832
+ export declare function searchComponents(index: Bm25Index<ComponentInfo>, query: string, limit?: number): SearchHit[];
833
+ //#endregion
834
+ //#region src/util/log.d.ts
835
+ /**
836
+ * Diagnostics go to stderr: in stdio mode stdout carries JSON-RPC and must
837
+ * never receive anything else.
838
+ */
839
+ interface Logger {
840
+ info(message: string): void;
841
+ warn(message: string): void;
842
+ error(message: string): void;
843
+ }
844
+ //#endregion
845
+ //#region src/design-system.d.ts
846
+ /** A loaded design system: the model plus the indexes the tools query. */
847
+ export declare class DesignSystem {
848
+ readonly model: DesignSystemModel;
849
+ readonly config: ResolvedConfig;
850
+ readonly lint: LintTarget;
851
+ private readonly searchIndex;
852
+ constructor(model: DesignSystemModel, config: ResolvedConfig);
853
+ get root(): string;
854
+ get components(): ComponentInfo[];
855
+ get tokens(): Token[];
856
+ get tokenIndex(): TokenIndex;
857
+ /** Top-level components, i.e. not parts of another component. */
858
+ roots(): ComponentInfo[];
859
+ /** Looks a component up by name, alias, `Card.Header`/`CardHeader` or case-insensitively. */
860
+ getComponent(name: string): ComponentInfo | undefined;
861
+ suggestComponent(name: string): string | undefined;
862
+ search(query: string, limit?: number): SearchHit[];
863
+ /** Tokens, core ones first: scoped families (`sidebar-*`, `chart-*`) follow the rest, which an agent should reach for. */
864
+ getTokens(filter?: {
865
+ category?: TokenCategory | undefined;
866
+ query?: string | undefined;
867
+ }): Token[];
868
+ /** Tokens a component's classes and CSS variables reference, e.g. `bg-primary` → `primary`. */
869
+ relatedTokens(component: ComponentInfo): Token[];
870
+ /**
871
+ * What the rules could not check, when it matters: without components the
872
+ * component rules find nothing, and without color tokens neither does
873
+ * no-hardcoded-color, so a clean result says little. Undefined when both exist.
874
+ * `where` names the projects it applies to, at a workspace root: `in apps/web`.
875
+ */
876
+ notice(where?: string): string | undefined;
877
+ check(code: string, filename?: string): CheckResult;
878
+ }
879
+ interface LoadOptions {
880
+ /** Use the on-disk extraction cache. Default true. */
881
+ cache?: boolean;
882
+ logger?: Logger;
883
+ /** Previous TypeScript program, reused for incremental rebuilds. */
884
+ oldProgram?: ts.Program | undefined;
885
+ }
886
+ interface BuildResult {
887
+ model: DesignSystemModel;
888
+ program?: ts.Program | undefined;
889
+ /** Fingerprint of every input file; unchanged fingerprint means nothing to rebuild. */
890
+ key?: string;
891
+ /** Project files the model depends on beyond the tracked ones; pass them to `fingerprint`. */
892
+ dependencies?: string[];
893
+ }
894
+ /**
895
+ * Fingerprint of the files a config tracks (paths, sizes, mtimes), plus the
896
+ * `dependencies` of a previous build, without extracting anything.
897
+ */
898
+ export declare function fingerprint(config: ResolvedConfig, dependencies?: readonly string[]): Promise<string>;
899
+ export declare function buildModel(config: ResolvedConfig, options?: LoadOptions): Promise<BuildResult>;
900
+ export declare function loadDesignSystem(config: ResolvedConfig, options?: LoadOptions): Promise<DesignSystem>;
901
+ /**
902
+ * Owns the current DesignSystem. Loads lazily, rebuilds when watched files
903
+ * change (reusing the previous TypeScript program), and never serves a
904
+ * half-built model: callers get the in-flight build when one is running.
905
+ */
906
+ interface HostOptions extends LoadOptions {
907
+ /** Builds the model; replaceable in tests. Defaults to `buildModel`. */
908
+ build?: typeof buildModel;
909
+ /**
910
+ * Re-reads the config when its file changes while watching. Defaults to
911
+ * loading the same config file; pass your own to keep overrides such as CLI flags.
912
+ */
913
+ loadConfig?: () => Promise<ResolvedConfig>;
914
+ }
915
+ export declare class DesignSystemHost {
916
+ private config;
917
+ private readonly options;
918
+ private current?;
919
+ private program?;
920
+ private key?;
921
+ private dependencies;
922
+ /** Bumped by every build; only the latest may update the state above. */
923
+ private generation;
924
+ private configChanged;
925
+ private watchers;
926
+ /** Recursively watched directories, and the config files watched through their directory. */
927
+ private watchedRoots;
928
+ private readonly watchedDirs;
929
+ private readonly watchedFiles;
930
+ private timer?;
931
+ private readonly listeners;
932
+ constructor(config: ResolvedConfig, options?: HostOptions);
933
+ get(): Promise<DesignSystem>;
934
+ reload(): Promise<DesignSystem>;
935
+ onChange(listener: (ds: DesignSystem) => void): () => void;
936
+ /** Watches the component, token and docs locations, the config and the tsconfig chain. */
937
+ watch(): void;
938
+ /**
939
+ * Watches the config file, the tsconfig and the tsconfigs it extends through
940
+ * their directories: editors save by renaming a new file over the old one,
941
+ * which ends a watch on the file. Called again after each build, so a new
942
+ * `extends` target is picked up.
943
+ */
944
+ private watchConfigFiles;
945
+ private changed;
946
+ close(): void;
947
+ private watchDirectory;
948
+ private schedule;
949
+ /** Re-reads the config, re-watches what it points at and rebuilds. */
950
+ private reloadConfig;
951
+ private build;
952
+ }
953
+ //#endregion
954
+ //#region src/extract/components.d.ts
955
+ interface ExtractComponentsOptions {
956
+ root: string;
957
+ /** Absolute paths of the component source files. */
958
+ files: string[];
959
+ tsconfig?: string | undefined;
960
+ /** Package name the design system is imported from; overrides tsconfig path inference. */
961
+ importPath?: string | undefined;
962
+ /** Specifiers from the `exports` of the package that holds the components; checked before tsconfig paths. */
963
+ imports?: ImportMapping[] | undefined;
964
+ /** Previous program, to let TypeScript reuse unchanged source files when watching. */
965
+ oldProgram?: ts.Program | undefined;
966
+ }
967
+ interface ExtractComponentsResult {
968
+ components: ComponentInfo[];
969
+ propSets: Record<string, string[]>;
970
+ /** Every value the component files export, components or not (`Icons`, `buttonVariants`). */
971
+ exports: string[];
972
+ warnings: string[];
973
+ program: ts.Program;
974
+ /** Project files extraction depends on: the tsconfig chain and every module the components import. */
975
+ dependencies: string[];
976
+ }
977
+ /**
978
+ * Extracts React components from source with the TypeScript checker: props
979
+ * (types, required, defaults, JSDoc), `cva()`/`tv()` variants, the native
980
+ * element they wrap, and compound structure (`CardHeader` under `Card`,
981
+ * `Tabs.List` via static members or `Object.assign`).
982
+ */
983
+ export declare function extractComponents(options: ExtractComponentsOptions): ExtractComponentsResult;
984
+ //#endregion
985
+ //#region src/extract/cva.d.ts
986
+ /** A `cva()` (class-variance-authority) or `tv()` (tailwind-variants) definition. */
987
+ interface VariantDefinition {
988
+ /** The variable it is assigned to, e.g. `buttonVariants`. */
989
+ name: string;
990
+ base: string;
991
+ variants: VariantInfo[];
992
+ compoundVariants: CompoundVariantInfo[];
993
+ node: ts.CallExpression;
994
+ }
995
+ /** Finds every `const x = cva(base, { variants, defaultVariants })` in a file. */
996
+ export declare function findVariantDefinitions(sourceFile: ts.SourceFile): Map<string, VariantDefinition>;
997
+ //#endregion
998
+ //#region src/extract/docs.d.ts
999
+ interface ParsedDoc {
1000
+ file: string;
1001
+ title?: string;
1002
+ description?: string;
1003
+ sections: DocSection[];
1004
+ examples: ExampleInfo[];
1005
+ frontmatter: Record<string, string | string[]>;
1006
+ }
1007
+ /**
1008
+ * Parses a component's Markdown/MDX page into a description, sections and
1009
+ * runnable examples. MDX `import`/`export` lines are dropped; JSX in prose is
1010
+ * kept as text.
1011
+ */
1012
+ export declare function parseDoc(text: string, file: string): ParsedDoc;
1013
+ /** Attaches docs and their examples to components. Returns warnings for unmatched pages. */
1014
+ export declare function attachDocs(components: ComponentInfo[], docs: ParsedDoc[]): string[];
1015
+ //#endregion
1016
+ //#region src/catalog.d.ts
1017
+ /** One project's design system at a workspace root. */
1018
+ interface ServedProject {
1019
+ ds: DesignSystem;
1020
+ /** Folder relative to the workspace root, with forward slashes. */
1021
+ dir: string;
1022
+ name?: string | undefined;
1023
+ }
1024
+ /**
1025
+ * The projects of a workspace root, as the MCP server serves them: one design system per
1026
+ * path, and all of them for the merged catalog.
1027
+ */
1028
+ interface ProjectSet {
1029
+ root: string;
1030
+ /** Folders of the projects with a design system, relative to the root. */
1031
+ dirs: string[];
1032
+ /** The design system that checks `target`, a file or folder relative to the root. */
1033
+ forPath(target: string): Promise<ServedProject>;
1034
+ /** Every project with a design system, loaded. */
1035
+ all(): Promise<ServedProject[]>;
1036
+ /** Their components and tokens together, rebuilt when a project reloads. */
1037
+ catalog(): Promise<Catalog>;
1038
+ }
1039
+ /** A component of the merged catalog: one source declaration, whichever projects use it. */
1040
+ interface CatalogEntry {
1041
+ /** As the first project that has it describes it, with `source.file` relative to the workspace root. */
1042
+ component: ComponentInfo;
1043
+ /** The design system to render it with (its props, tokens and parts). */
1044
+ ds: DesignSystem;
1045
+ /** The package its source file belongs to: `@acme/ui`, or the app's own name. */
1046
+ package: string;
1047
+ /** Folders of the projects that use it. */
1048
+ projects: string[];
1049
+ /** Another component of the catalog has the same name. */
1050
+ ambiguous: boolean;
1051
+ }
1052
+ interface CatalogToken {
1053
+ token: Token;
1054
+ ds: DesignSystem;
1055
+ package: string;
1056
+ projects: string[];
1057
+ }
1058
+ /**
1059
+ * Every project's components and tokens in one list, for a workspace root when no path
1060
+ * picks a project. A component used by several projects (a design-system package) is
1061
+ * listed once, tagged with its package; two different components under one name are both
1062
+ * listed, each with its package, and a lookup by that name returns both.
1063
+ */
1064
+ declare class Catalog {
1065
+ readonly root: string;
1066
+ readonly projects: ServedProject[];
1067
+ readonly entries: CatalogEntry[];
1068
+ readonly tokens: CatalogToken[];
1069
+ private readonly index;
1070
+ constructor(root: string, projects: ServedProject[]);
1071
+ /** Top-level components, not parts of another. */
1072
+ roots(): CatalogEntry[];
1073
+ /** Every distinct component a name resolves to, through each project's lookup. */
1074
+ find(name: string): CatalogEntry[];
1075
+ suggest(name: string): string | undefined;
1076
+ search(query: string, limit?: number): (SearchHit & {
1077
+ entry: CatalogEntry;
1078
+ })[];
1079
+ /** Tokens as `get_tokens` filters them, core ones before scoped families. */
1080
+ getTokens(filter?: {
1081
+ category?: TokenCategory | undefined;
1082
+ query?: string | undefined;
1083
+ }): CatalogToken[];
1084
+ }
1085
+ //#endregion
1086
+ //#region src/server/index.d.ts
1087
+ 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
+ interface CreateServerOptions {
1089
+ /** Resolves the design system to serve. Called per request, so it can be swapped on reload. */
1090
+ getDesignSystem: () => Promise<DesignSystem>;
1091
+ /**
1092
+ * At a workspace root: its projects. When this resolves to a set, the tools take a `path`
1093
+ * to pick a project and serve every project together without one, and `getDesignSystem`
1094
+ * is not called.
1095
+ */
1096
+ getProjects?: () => Promise<ProjectSet | undefined>;
1097
+ }
1098
+ /** Builds the MCP server: five tools, two resources and one prompt. Transport-agnostic. */
1099
+ export declare function createServer({ getDesignSystem, getProjects }: CreateServerOptions): McpServer;
1100
+ //#endregion
1101
+ //#region src/server/stdio.d.ts
1102
+ interface ServeOptions extends LoadConfigOptions {
1103
+ cwd: string;
1104
+ cache: boolean;
1105
+ watch: boolean;
1106
+ logger: Logger;
1107
+ /** Defaults to stdio. */
1108
+ transport?: Transport;
1109
+ }
1110
+ /** The running server: `close()` ends the connection and stops watching. */
1111
+ interface ServerHandle {
1112
+ close(): Promise<void>;
1113
+ }
1114
+ /**
1115
+ * Starts the server (on stdio unless another transport is given), for clients on
1116
+ * either protocol era: a 2026-07-28 client (stateless, `server/discover`) and a
1117
+ * 2025-era one (the `initialize` handshake) are both served, the era chosen by the
1118
+ * client's first message.
1119
+ *
1120
+ * The project root comes from `--root` or `--config`, a config file in the working
1121
+ * directory, or the working directory itself when it holds a project (a
1122
+ * package.json, a components.json). MCP roots, which the 2026-07-28 revision
1123
+ * deprecates, are the fallback for a 2025-era client that starts servers somewhere
1124
+ * else (Claude Desktop starts them in `/`): its first `file://` root. At a monorepo
1125
+ * root with no design system of its own, every project in it is served.
1126
+ */
1127
+ export declare function serveStdio(options: ServeOptions): Promise<ServerHandle>;
1128
+ //#endregion
1129
+ //#region src/version.d.ts
1130
+ export declare const VERSION: string;
1131
+ //#endregion
1132
+ export type { CheckResult, ComponentDocs, ComponentInfo, CompoundVariantInfo, Config, DesignSystemModel, Diagnostic, DocSection, ExampleInfo, HostOptions, InheritedProps, LoadConfigOptions, LoadOptions, OutputFormat, PropInfo, ResolvedConfig, RuleId, Severity, SourceLocation, TOKEN_CATEGORIES, TextEdit, Token, TokenCategory, VariantInfo };