onsystem 0.10.0 → 0.10.2

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.
@@ -1,6 +1,5 @@
1
- import { h as DesignSystemModel, i as ResolvedConfig } from "./config-BbTW1jKU.js";
1
+ import { h as DesignSystemModel, i as ResolvedConfig } from "./config-JaNAiR9Z.js";
2
2
  import { MessagePort } from "node:worker_threads";
3
- //#region src/eslint/worker.d.ts
4
3
  export interface LoadRequest {
5
4
  /** ESLint's working directory: where `check` would run from. */
6
5
  cwd: string;
@@ -32,5 +31,4 @@ export interface Call {
32
31
  signal: Int32Array;
33
32
  port: MessagePort;
34
33
  }
35
- export declare function load(request: LoadRequest): Promise<LoadResponse>;
36
- //#endregion
34
+ export declare function load(request: LoadRequest): Promise<LoadResponse>;
@@ -1,9 +1,9 @@
1
- import { Mt as relativePath, at as excludedBy, i as componentFiles, r as buildModel } from "./design-system-D53Jxybo.js";
2
- import { r as loadTarget } from "./workspace-DAa_08uB.js";
1
+ import { At as relativePath, i as componentFiles, ot as excludedBy, r as buildModel } from "./design-system-rl__N6tw.js";
2
+ import { r as loadTarget } from "./workspace-INef0Yqt.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { parentPort } from "node:worker_threads";
6
- //#region src/eslint/worker.ts
6
+ // src/eslint/worker.ts
7
7
  /**
8
8
  * The ESLint plugin's loader, in a worker thread. ESLint rules run synchronously, and finding a
9
9
  * project's design system does not (config files written in code, globs, the extraction
@@ -89,5 +89,4 @@ parentPort?.on("message", ({ request, signal, port }) => {
89
89
  reply({ error: error.message });
90
90
  });
91
91
  });
92
- //#endregion
93
92
  export { load };
package/dist/eslint.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Linter, Rule } from "eslint";
2
- //#region src/eslint/index.d.ts
3
2
  /** `settings.onsystem`: where the project and its config are, when finding them from ESLint's cwd is not right. */
4
3
  export interface Settings {
5
4
  /** The project root, relative to ESLint's working directory (`check --root`). */
@@ -19,5 +18,4 @@ declare const plugin: {
19
18
  recommended: Linter.Config;
20
19
  };
21
20
  };
22
- //#endregion
23
21
  export { plugin as default };
package/dist/eslint.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Mt as relativePath, N as RULES, Q as DEFAULT_TEST_FOLDERS, X as DEFAULT_SEVERITY, Z as DEFAULT_TEST_EXCLUDE, t as DesignSystem, v as NAME, y as VERSION } from "./design-system-D53Jxybo.js";
1
+ import { At as relativePath, N as RULES, Q as DEFAULT_TEST_FOLDERS, X as DEFAULT_SEVERITY, Z as DEFAULT_TEST_EXCLUDE, t as DesignSystem, v as NAME, y as VERSION } from "./design-system-rl__N6tw.js";
2
2
  import path from "node:path";
3
3
  import { MessageChannel, Worker, receiveMessageOnPort } from "node:worker_threads";
4
- //#region src/eslint/bridge.ts
4
+ // src/eslint/bridge.ts
5
5
  /**
6
6
  * Calls the loader worker (`worker.ts`) synchronously: posts the request, blocks on a shared
7
7
  * flag until the worker has answered, and takes the answer off the port. The worker is
@@ -39,8 +39,7 @@ function loadSync(request) {
39
39
  port1.close();
40
40
  }
41
41
  }
42
- //#endregion
43
- //#region src/eslint/index.ts
42
+ // src/eslint/index.ts
44
43
  /**
45
44
  * onsystem's rules as an ESLint plugin (ESLint 9 and 10, flat config):
46
45
  *
@@ -229,5 +228,4 @@ plugin.configs.recommended = {
229
228
  plugins: { onsystem: plugin },
230
229
  rules: Object.fromEntries(RULES.map((rule) => [`onsystem/${rule.id}`, DEFAULT_SEVERITY[rule.id]]))
231
230
  };
232
- //#endregion
233
231
  export { plugin as default };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
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-BbTW1jKU.js";
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-JaNAiR9Z.js";
2
2
  import ts from "typescript";
3
3
  import { Oklch } from "culori";
4
4
  import { McpServer, Transport } from "@modelcontextprotocol/server";
5
- //#region src/lint/analyze.d.ts
6
5
  interface ImportBinding {
7
6
  source: string;
8
7
  /** Imported name, `default`, or `*` for namespace imports. */
@@ -37,8 +36,6 @@ interface Analysis {
37
36
  classStrings: ClassString[];
38
37
  styles: StyleObject[];
39
38
  }
40
- //#endregion
41
- //#region src/modules.d.ts
42
39
  /** Where an import points: a file relative to the root, or `{}` for a declared module not on disk. */
43
40
  interface ModuleLocation {
44
41
  file?: string;
@@ -83,8 +80,6 @@ declare class ModuleResolver {
83
80
  exportsOf(file: string): ModuleExports | undefined;
84
81
  private createResolver;
85
82
  }
86
- //#endregion
87
- //#region src/tokens/roles.d.ts
88
83
  /**
89
84
  * What a color utility paints, which decides the tokens that fit it: `text-*`
90
85
  * wants a foreground, `bg-*` a surface, `border-*` a border color.
@@ -100,8 +95,6 @@ type ColorRole = 'text' | 'surface' | 'line';
100
95
  * palette (`color-red-500`).
101
96
  */
102
97
  type ScopedFamily = string;
103
- //#endregion
104
- //#region src/tokens/css.d.ts
105
98
  /**
106
99
  * Reads design tokens from CSS custom properties, the way shadcn/ui and
107
100
  * Tailwind v4 projects define them:
@@ -114,14 +107,10 @@ export declare function parseCssTokens(css: string, file: string): {
114
107
  tokens: Token[];
115
108
  warnings: string[];
116
109
  };
117
- //#endregion
118
- //#region src/tokens/design-md.d.ts
119
110
  export declare function parseDesignMd(text: string, file: string): {
120
111
  tokens: Token[];
121
112
  warnings: string[];
122
113
  };
123
- //#endregion
124
- //#region src/tokens/dtcg.d.ts
125
114
  interface DtcgOptions {
126
115
  /** Prefix for generated custom property names: `ds` → `--ds-color-primary`. */
127
116
  prefix?: string;
@@ -130,8 +119,6 @@ export declare function parseDtcgTokens(text: string, file: string, options?: Dt
130
119
  tokens: Token[];
131
120
  warnings: string[];
132
121
  };
133
- //#endregion
134
- //#region src/tokens/export.d.ts
135
122
  /**
136
123
  * Writes the tokens onsystem found as a DTCG 2025.10 file or a DESIGN.md. Both are grouped by
137
124
  * category; reading the DTCG file back gives the same tokens, with the same names.
@@ -158,8 +145,6 @@ export declare function toDtcg(tokens: readonly Token[]): Exported;
158
145
  export declare function toDesignMd(tokens: readonly Token[], options: {
159
146
  name: string;
160
147
  }): Exported;
161
- //#endregion
162
- //#region src/tokens/index.d.ts
163
148
  interface TokenSource {
164
149
  file: string;
165
150
  /** DTCG only: prefix for generated custom property names. */
@@ -281,8 +266,6 @@ export declare class TokenIndex {
281
266
  /** px value of a token-like length string, resolving `var()` against the token set. */
282
267
  toPx(value: string): number | undefined;
283
268
  }
284
- //#endregion
285
- //#region src/lint/target.d.ts
286
269
  /** What the lint rules need to know about the design system. */
287
270
  declare class LintTarget {
288
271
  readonly model: DesignSystemModel;
@@ -378,8 +361,6 @@ declare class LintTarget {
378
361
  /** Component names for "did you mean" suggestions. */
379
362
  names(): string[];
380
363
  }
381
- //#endregion
382
- //#region src/lint/context.d.ts
383
364
  interface Report {
384
365
  start: number;
385
366
  end: number;
@@ -440,12 +421,8 @@ type Resolution =
440
421
  {
441
422
  kind: 'external';
442
423
  };
443
- //#endregion
444
- //#region src/lint/rules/index.d.ts
445
424
  /** Every rule, in the order they run. */
446
425
  export declare const RULES: readonly Rule[];
447
- //#endregion
448
- //#region src/lint/format.d.ts
449
426
  type OutputFormat = 'pretty' | 'json' | 'github' | 'sarif';
450
427
  /**
451
428
  * Renders check results:
@@ -468,8 +445,6 @@ export declare function formatDiagnostics(results: CheckResult[], format: Output
468
445
  */
469
446
  uri?: ((file: string) => string) | undefined;
470
447
  }): string;
471
- //#endregion
472
- //#region src/lint/index.d.ts
473
448
  interface CheckOptions {
474
449
  /** File name used in results and to pick TSX vs JSX parsing. Default `snippet.tsx`. */
475
450
  filename?: string | undefined;
@@ -483,8 +458,6 @@ interface CheckOptions {
483
458
  export declare function checkSource(code: string, target: LintTarget, options: CheckOptions): CheckResult;
484
459
  /** Applies non-overlapping fixes from the end of the file backwards. */
485
460
  export declare function applyFixes(code: string, diagnostics: Diagnostic[]): string;
486
- //#endregion
487
- //#region src/search/bm25.d.ts
488
461
  /**
489
462
  * Okapi BM25 over weighted fields (BM25F-style: field weights scale term
490
463
  * frequency and document length). Small, dependency-free and deterministic,
@@ -512,8 +485,6 @@ declare class Bm25Index<T> {
512
485
  get size(): number;
513
486
  search(query: Map<string, number>, limit?: number): Bm25Hit<T>[];
514
487
  }
515
- //#endregion
516
- //#region src/search/index.d.ts
517
488
  interface SearchHit {
518
489
  component: ComponentInfo;
519
490
  score: number;
@@ -530,8 +501,6 @@ interface SearchHit {
530
501
  * which is not an answer to give as the best match.
531
502
  */
532
503
  export declare function searchComponents(index: Bm25Index<ComponentInfo>, query: string, limit?: number): SearchHit[];
533
- //#endregion
534
- //#region src/util/log.d.ts
535
504
  /**
536
505
  * Diagnostics go to stderr: in stdio mode stdout carries JSON-RPC and must
537
506
  * never receive anything else.
@@ -541,8 +510,6 @@ interface Logger {
541
510
  warn(message: string): void;
542
511
  error(message: string): void;
543
512
  }
544
- //#endregion
545
- //#region src/design-system.d.ts
546
513
  /** A loaded design system: the model plus the indexes the tools query. */
547
514
  export declare class DesignSystem {
548
515
  readonly model: DesignSystemModel;
@@ -659,6 +626,11 @@ export declare class DesignSystemHost {
659
626
  constructor(config: ResolvedConfig, options?: HostOptions);
660
627
  get(): Promise<DesignSystem>;
661
628
  reload(): Promise<DesignSystem>;
629
+ /**
630
+ * `build`, dropped if it fails with no earlier model to serve instead (a first build that
631
+ * fails), so the next `get()` builds again.
632
+ */
633
+ private kept;
662
634
  onChange(listener: (ds: DesignSystem) => void): () => void;
663
635
  /** Watches the component, token and docs locations, the config and the tsconfig chain. */
664
636
  watch(): void;
@@ -677,8 +649,6 @@ export declare class DesignSystemHost {
677
649
  private reloadConfig;
678
650
  private build;
679
651
  }
680
- //#endregion
681
- //#region src/extract/components.d.ts
682
652
  interface ExtractComponentsOptions {
683
653
  root: string;
684
654
  /** Absolute paths of the component source files. */
@@ -708,8 +678,6 @@ interface ExtractComponentsResult {
708
678
  * `Tabs.List` via static members or `Object.assign`).
709
679
  */
710
680
  export declare function extractComponents(options: ExtractComponentsOptions): ExtractComponentsResult;
711
- //#endregion
712
- //#region src/extract/cva.d.ts
713
681
  /** A `cva()` (class-variance-authority) or `tv()` (tailwind-variants) definition. */
714
682
  interface VariantDefinition {
715
683
  /** The variable it is assigned to, e.g. `buttonVariants`. */
@@ -721,8 +689,6 @@ interface VariantDefinition {
721
689
  }
722
690
  /** Finds every `const x = cva(base, { variants, defaultVariants })` in a file. */
723
691
  export declare function findVariantDefinitions(sourceFile: ts.SourceFile): Map<string, VariantDefinition>;
724
- //#endregion
725
- //#region src/extract/docs.d.ts
726
692
  interface ParsedDoc {
727
693
  file: string;
728
694
  title?: string;
@@ -739,8 +705,6 @@ interface ParsedDoc {
739
705
  export declare function parseDoc(text: string, file: string): ParsedDoc;
740
706
  /** Attaches docs and their examples to components. Returns warnings for unmatched pages. */
741
707
  export declare function attachDocs(components: ComponentInfo[], docs: ParsedDoc[]): string[];
742
- //#endregion
743
- //#region src/catalog.d.ts
744
708
  /** One project's design system at a workspace root. */
745
709
  interface ServedProject {
746
710
  ds: DesignSystem;
@@ -809,8 +773,6 @@ declare class Catalog {
809
773
  query?: string | undefined;
810
774
  }): CatalogToken[];
811
775
  }
812
- //#endregion
813
- //#region src/server/index.d.ts
814
776
  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. chart-* and sidebar-* tokens are for charts and the sidebar only: for a status color the theme has no token for (success, warning, info), add a token or keep the Tailwind color as check_ui says, and never use a chart-* or sidebar-* token for it.\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.";
815
777
  interface CreateServerOptions {
816
778
  /**
@@ -826,9 +788,7 @@ interface CreateServerOptions {
826
788
  getProjects?: (target?: string) => Promise<ProjectSet | undefined>;
827
789
  }
828
790
  /** Builds the MCP server: five tools, two resources and one prompt. Transport-agnostic. */
829
- export declare function createServer({ getDesignSystem, getProjects }: CreateServerOptions): McpServer;
830
- //#endregion
831
- //#region src/server/stdio.d.ts
791
+ export declare function createServer(options: CreateServerOptions): McpServer;
832
792
  interface ServeOptions extends LoadConfigOptions {
833
793
  cwd: string;
834
794
  cache: boolean;
@@ -860,12 +820,18 @@ interface ServerHandle {
860
820
  * project marker, or the monorepo root above that, served as if the server had been
861
821
  * started there, except that a config there is read only when it is JSON: a prompt can
862
822
  * choose the path, so a JavaScript or TypeScript config is not run. Each root found is
863
- * loaded once and kept; a request without an absolute path is answered from the one root
864
- * found so far.
823
+ * loaded once and kept, by its real path; a request without an absolute path is answered from
824
+ * the one root found so far. The same holds for a `--root` (or a client's root) that is no
825
+ * project but holds projects in its folders, such as a folder of repositories, except that only
826
+ * an absolute path in that folder is answered, from the project in it that holds the file (never
827
+ * from a folder outside or above it), and a file in none of them from that folder, as before.
828
+ * Links are resolved: a path, or the project it leads to, that is really outside the folder is
829
+ * refused, a workspace in it serves only its packages that are really in it, and a project in it
830
+ * that a link replaces while the server runs is not built again from where the link leads.
831
+ *
832
+ * A load that fails, such as on an invalid config, is not kept: the next request loads
833
+ * again, so fixing the config is enough, also when it was invalid at startup.
865
834
  */
866
835
  export declare function serveStdio(options: ServeOptions): Promise<ServerHandle>;
867
- //#endregion
868
- //#region src/version.d.ts
869
836
  export declare const VERSION: string;
870
- //#endregion
871
837
  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,3 +1,3 @@
1
- import { F as loadTokens, G as parseDoc, H as parseDesignMd, I as mergeTokens, K as extractComponents, L as toDesignMd, N as RULES, P as TokenIndex, R as toDtcg, U as parseCssTokens, V as parseDtcgTokens, W as attachDocs, _ as formatDiagnostics, a as fingerprint, dt as findVariantDefinitions, f as searchComponents, it as defineConfig, m as checkSource, n as DesignSystemHost, nt as RULE_IDS, o as loadDesignSystem, p as applyFixes, r as buildModel, rt as configJsonSchema, st as loadConfig, t as DesignSystem, y as VERSION } from "./design-system-D53Jxybo.js";
2
- import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-ha4IF0CU.js";
1
+ import { F as loadTokens, G as parseDoc, H as parseDesignMd, I as mergeTokens, K as extractComponents, L as toDesignMd, N as RULES, P as TokenIndex, R as toDtcg, U as parseCssTokens, V as parseDtcgTokens, W as attachDocs, _ as formatDiagnostics, a as fingerprint, at as defineConfig, ct as loadConfig, f as searchComponents, ft as findVariantDefinitions, it as configJsonSchema, m as checkSource, n as DesignSystemHost, o as loadDesignSystem, p as applyFixes, r as buildModel, rt as RULE_IDS, t as DesignSystem, y as VERSION } from "./design-system-rl__N6tw.js";
2
+ import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-CkczPt_1.js";
3
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 };