onsystem 0.5.0 → 0.7.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.
@@ -1,4 +1,4 @@
1
- import { F as CONFIG_FILES, G as loadConfig, V as LEGACY_CONFIG_FILES, X as workspacePackageDirs, Y as isWorkspaceRoot, Z as workspacePatterns, i as componentFiles, it as relativePath, nt as isInside } from "./design-system-CnEv5sIL.js";
1
+ import { $ as loadConfig, Ct as relativePath, H as CONFIG_FILES, J as LEGACY_CONFIG_FILES, Q as hasOwnConfig, et as loadConfigWith, ft as findDesignSystemPackage, gt as workspacePatterns, ht as workspacePackageDirs, i as componentFiles, lt as PackageFinder, mt as isWorkspaceRoot, xt as isInside } from "./design-system-C4bhqLLw.js";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import os from "node:os";
@@ -18,7 +18,8 @@ const PROJECT_MARKERS = [
18
18
  ];
19
19
  /**
20
20
  * A monorepo seen from its root: every workspace package with a design system (an app
21
- * that uses one, or the design-system package itself), and how to find the project of
21
+ * that uses one, from source or a published library, or the design-system package
22
+ * itself), and how to find the project of
22
23
  * any file in it. Without a design system at the root, `check`, `inspect` and the MCP
23
24
  * server work from here, each file checked by its own project's design system.
24
25
  */
@@ -30,8 +31,9 @@ var Workspace = class {
30
31
  configFile;
31
32
  options;
32
33
  rootConfig;
34
+ otherConfigs;
33
35
  bare = /* @__PURE__ */ new Map();
34
- constructor(root, source, projects, others, configFile, options, rootConfig) {
36
+ constructor(root, source, projects, others, configFile, options, rootConfig, otherConfigs = []) {
35
37
  this.root = root;
36
38
  this.source = source;
37
39
  this.projects = projects;
@@ -39,6 +41,19 @@ var Workspace = class {
39
41
  this.configFile = configFile;
40
42
  this.options = options;
41
43
  this.rootConfig = rootConfig;
44
+ this.otherConfigs = otherConfigs;
45
+ }
46
+ /**
47
+ * What the configs of the workspace's packages have to say ({@link ResolvedConfig.warnings}),
48
+ * each once, as they were read when the workspace was found.
49
+ */
50
+ get warnings() {
51
+ const configs = [
52
+ this.rootConfig,
53
+ ...this.projects.map((p) => p.config),
54
+ ...this.otherConfigs
55
+ ];
56
+ return [...new Set(configs.flatMap((c) => c.warnings ?? []))];
42
57
  }
43
58
  /**
44
59
  * The project `target` (a file or a folder) belongs to: the nearest folder at or above
@@ -102,24 +117,31 @@ async function discoverWorkspace(rootConfig, options) {
102
117
  ].filter(Boolean).join(", ");
103
118
  const projects = [];
104
119
  const others = [];
120
+ const otherConfigs = [];
105
121
  for (const dir of workspacePackageDirs(root)) {
106
122
  const config = await loadProjectConfig(dir, root, rootConfig.configFile, options);
107
123
  const files = (await componentFiles(config)).length;
108
124
  const own = config.configFile !== void 0 && config.configFile !== rootConfig.configFile;
109
- if (files || own) projects.push({
125
+ const library = config.libraries?.some((l) => l.dir !== void 0) ?? false;
126
+ if (files || own || library) projects.push({
110
127
  root: dir,
111
128
  dir: relativePath(root, dir),
112
129
  name: packageName(dir),
113
130
  config,
114
131
  componentFiles: files
115
132
  });
116
- else others.push(relativePath(root, dir));
133
+ else {
134
+ others.push(relativePath(root, dir));
135
+ if (config.warnings) otherConfigs.push(config);
136
+ }
117
137
  }
118
- return new Workspace(root, source, projects, others, rootConfig.configFile, options, rootConfig);
138
+ return new Workspace(root, source, projects, others, rootConfig.configFile, options, rootConfig, otherConfigs);
119
139
  }
120
140
  /**
121
- * A project's config: its own config file, or the workspace root's, with paths relative to
122
- * the workspace root, or zero config. CLI flags that apply to every project carry over.
141
+ * A project's config: its own config file, else the config its design-system package declares
142
+ * (a dependency with `"onsystem"` in its package.json), else the workspace root's, with paths
143
+ * relative to the workspace root, else zero config. `loadConfig` from the project's folder finds
144
+ * the first two the same way. CLI flags that apply to every project carry over.
123
145
  */
124
146
  function loadProjectConfig(dir, workspaceRoot, rootConfigFile, options) {
125
147
  const shared = {
@@ -127,15 +149,27 @@ function loadProjectConfig(dir, workspaceRoot, rootConfigFile, options) {
127
149
  includeDesignSystem: options.includeDesignSystem,
128
150
  jsonConfigOnly: options.jsonConfigOnly
129
151
  };
130
- if ([...CONFIG_FILES, ...LEGACY_CONFIG_FILES].some((name) => fs.existsSync(path.join(dir, name))) || !rootConfigFile) return loadConfig({
152
+ const packages = new PackageFinder(dir);
153
+ if (!rootConfigFile || hasOwnConfig(dir)) return loadConfigWith({
154
+ ...shared,
155
+ root: dir
156
+ }, { packages });
157
+ const lookup = findDesignSystemPackage(dir, packages);
158
+ if (lookup?.found || lookup?.problems.length) return loadConfigWith({
131
159
  ...shared,
132
160
  root: dir
161
+ }, {
162
+ packages,
163
+ lookup
133
164
  });
134
- return loadConfig({
165
+ return loadConfigWith({
135
166
  ...shared,
136
167
  root: dir,
137
168
  config: rootConfigFile,
138
169
  base: workspaceRoot
170
+ }, {
171
+ packages,
172
+ lookup
139
173
  });
140
174
  }
141
175
  /** The nearest folder at or above `target` (a file or folder) with a project marker, up to `root`. */
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "onsystem",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "mcpName": "io.github.dgesteves/onsystem",
5
- "description": "Keeps coding agents on your design system: it knows your real components, props, variants and tokens, catches the moment an agent invents one and has it fix it, and the same check gates your PRs. Local, zero config, works alongside @shadcn/lint.",
5
+ "description": "Keeps coding agents on your design system: catches palette colors, native elements and APIs your system lacks, at every edit and pull request, with the fix. Set it up once in your design-system package; every app in your monorepo gets it.",
6
6
  "keywords": [
7
7
  "design-system",
8
8
  "design-system-lint",
@@ -25,7 +25,7 @@
25
25
  "mcp",
26
26
  "model-context-protocol"
27
27
  ],
28
- "homepage": "https://github.com/dgesteves/onsystem#readme",
28
+ "homepage": "https://onsystem.vercel.app",
29
29
  "bugs": "https://github.com/dgesteves/onsystem/issues",
30
30
  "repository": {
31
31
  "type": "git",
@@ -68,10 +68,11 @@
68
68
  "stemmer": "^2.0.1",
69
69
  "tinyglobby": "^0.2.17",
70
70
  "typescript": "~6.0.3",
71
- "zod": "^4.6.5"
71
+ "yaml": "^2.9.1",
72
+ "zod": "^4.6.6"
72
73
  },
73
74
  "peerDependencies": {
74
- "eslint": ">=9.0.0"
75
+ "eslint": ">=8.57.0"
75
76
  },
76
77
  "peerDependenciesMeta": {
77
78
  "eslint": {
@@ -85,7 +86,7 @@
85
86
  "@modelcontextprotocol/client": "^2.3.1",
86
87
  "@modelcontextprotocol/sdk": "^1.32.1",
87
88
  "@types/culori": "^4.0.1",
88
- "@types/node": "^24.19.1",
89
+ "@types/node": "^24.19.2",
89
90
  "ajv": "^8.20.0",
90
91
  "ajv-draft-04": "^1.0.0",
91
92
  "ajv-formats": "^3.0.1",
@@ -95,11 +96,11 @@
95
96
  "geist": "^1.7.2",
96
97
  "globals": "^17.13.0",
97
98
  "opentype.js": "^2.0.0",
98
- "prettier": "^3.9.9",
99
+ "prettier": "^3.9.10",
99
100
  "publint": "^0.3.25",
100
- "react-aria-components": "^1.21.1",
101
+ "react-aria-components": "^1.22.1",
101
102
  "tailwind-variants": "^3.3.1",
102
- "tsdown": "^0.23.0",
103
+ "tsdown": "^0.23.1",
103
104
  "typescript-eslint": "^8.71.1",
104
105
  "vitest": "^5.0.3"
105
106
  },
@@ -113,7 +114,7 @@
113
114
  "test": "vitest run",
114
115
  "test:watch": "vitest",
115
116
  "smoke": "node scripts/smoke.mjs",
116
- "pack-test": "node scripts/pack-test.mjs",
117
+ "pack-test": "node scripts/pack-test.mjs && node scripts/pack-test-eslint8.mjs",
117
118
  "assets": "node scripts/build-assets.mjs",
118
119
  "palette": "node scripts/build-palette.mjs",
119
120
  "sync-plugins": "node scripts/sync-plugins.mjs",
package/schema.json CHANGED
@@ -29,7 +29,7 @@
29
29
  }
30
30
  },
31
31
  "tokens": {
32
- "description": "Token files: W3C DTCG JSON (*.json) or CSS custom properties (*.css).",
32
+ "description": "Token files: W3C DTCG JSON (*.json), CSS custom properties (*.css) or a DESIGN.md's front matter (*.md).",
33
33
  "anyOf": [
34
34
  {
35
35
  "anyOf": [
@@ -116,6 +116,24 @@
116
116
  "type": "string"
117
117
  }
118
118
  },
119
+ "libraries": {
120
+ "description": "Published component libraries to read from their type declarations when the project depends on them. Omitted: every one onsystem reads (mui). false: none. A list: only those, e.g. [\"mui\"].",
121
+ "anyOf": [
122
+ {
123
+ "type": "boolean",
124
+ "const": false
125
+ },
126
+ {
127
+ "type": "array",
128
+ "items": {
129
+ "type": "string",
130
+ "enum": [
131
+ "mui"
132
+ ]
133
+ }
134
+ }
135
+ ]
136
+ },
119
137
  "includeDesignSystem": {
120
138
  "description": "check: lint the design system's own component files too. Off by default: they implement the scale and primitives the rules enforce.",
121
139
  "type": "boolean"