@maz-ui/nuxt 5.0.1-beta.0 → 5.1.0-beta.1
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 +6 -0
- package/dist/module.d.mts +19 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +66 -24
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -209,6 +209,12 @@ export default defineNuxtConfig({
|
|
|
209
209
|
vFullscreenImg: true,
|
|
210
210
|
vZoomImg: true,
|
|
211
211
|
},
|
|
212
|
+
|
|
213
|
+
// AI coding agents (default: { rules: false, mcp: true }, false to disable)
|
|
214
|
+
// In development, registers the maz-ui MCP server in the configs of the detected agents
|
|
215
|
+
// (.mcp.json, .cursor/mcp.json, .vscode/mcp.json), rules: true also writes .claude/rules/maz-ui.md and an AGENTS.md section
|
|
216
|
+
// In a monorepo, the files go to the root of the workspace (dir: '<folder>' to change it)
|
|
217
|
+
agents: { rules: false, mcp: true },
|
|
212
218
|
},
|
|
213
219
|
})
|
|
214
220
|
```
|
package/dist/module.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { AgentTarget } from '@maz-ui/node';
|
|
2
3
|
import { MazUiThemeOptions, ThemePreset, ThemePresetName } from '@maz-ui/themes';
|
|
3
4
|
import { MazUiTranslationsOptions } from '@maz-ui/translations';
|
|
4
5
|
import { MazUiDefaultsOptions } from 'maz-ui/composables/useGlobalConfig';
|
|
@@ -299,6 +300,23 @@ interface MazUiNuxtOptions {
|
|
|
299
300
|
*/
|
|
300
301
|
vTooltip?: boolean | VTooltipOptions;
|
|
301
302
|
};
|
|
303
|
+
/**
|
|
304
|
+
* AI coding agents integration
|
|
305
|
+
* @description Connects the AI coding agents detected in the project (Claude Code, Cursor, GitHub Copilot...) to maz-ui, in development only (never in CI or tests), version-matched with the installed maz-ui, without overwriting files you own.
|
|
306
|
+
* - `mcp`: registers the maz-ui MCP server in the agent configs (`.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`). Its instructions already give the maz-ui rules to the agents.
|
|
307
|
+
* - `rules`: also writes the maz-ui rules in `.claude/rules/maz-ui.md` and in a delimited section of `AGENTS.md` (for agents without MCP).
|
|
308
|
+
* - `targets`: agents to configure (`'claude'`, `'agents-md'`, `'cursor'`, `'vscode'`), default: the detected ones. Nothing is written when no agent is detected.
|
|
309
|
+
* - `dir`: folder where the agent files are written, relative to the Nuxt root. Default: the workspace root (`workspaceDir`), so that in a monorepo the files land where the agents start
|
|
310
|
+
* - `true`: `{ mcp: true, rules: true }`, `false`: disabled
|
|
311
|
+
* @example `agents: { rules: true }` or `agents: false`
|
|
312
|
+
* @default { rules: false, mcp: true }
|
|
313
|
+
*/
|
|
314
|
+
agents?: boolean | {
|
|
315
|
+
targets?: AgentTarget[];
|
|
316
|
+
rules?: boolean;
|
|
317
|
+
mcp?: boolean;
|
|
318
|
+
dir?: string;
|
|
319
|
+
};
|
|
302
320
|
}
|
|
303
321
|
|
|
304
322
|
declare module 'nuxt/schema' {
|
|
@@ -309,7 +327,7 @@ declare module 'nuxt/schema' {
|
|
|
309
327
|
mazUi: MazUiNuxtOptions;
|
|
310
328
|
}
|
|
311
329
|
interface PublicRuntimeConfig {
|
|
312
|
-
mazUi: Required<MazUiNuxtOptions
|
|
330
|
+
mazUi: Required<Omit<MazUiNuxtOptions, 'agents'>>;
|
|
313
331
|
}
|
|
314
332
|
}
|
|
315
333
|
declare const _default: _nuxt_schema.NuxtModule<MazUiNuxtOptions, MazUiNuxtOptions, false>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { dirname } from 'node:path';
|
|
1
|
+
import { dirname, resolve, join } from 'node:path';
|
|
2
|
+
import process from 'node:process';
|
|
2
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { detectAgentTargets, findProjectPackage, setupAgents } from '@maz-ui/node';
|
|
3
5
|
import { capitalize } from '@maz-ui/utils/helpers/capitalize';
|
|
6
|
+
import { getErrorMessage } from '@maz-ui/utils/helpers/getErrorMessage';
|
|
4
7
|
import { addCustomTab } from '@nuxt/devtools-kit';
|
|
5
|
-
import { defineNuxtModule, createResolver, addPlugin, addComponent, addImports } from '@nuxt/kit';
|
|
8
|
+
import { defineNuxtModule, createResolver, addPlugin, addComponent, addImports, useLogger } from '@nuxt/kit';
|
|
6
9
|
import { defu } from 'defu';
|
|
7
10
|
|
|
8
11
|
const COMPONENT_NAMES = {
|
|
@@ -155,8 +158,46 @@ const defaults = {
|
|
|
155
158
|
vClickOutside: false,
|
|
156
159
|
vFullscreenImg: false,
|
|
157
160
|
vTooltip: false
|
|
161
|
+
},
|
|
162
|
+
agents: {
|
|
163
|
+
rules: false,
|
|
164
|
+
mcp: true
|
|
158
165
|
}
|
|
159
166
|
};
|
|
167
|
+
function syncAgents(agents, nuxt) {
|
|
168
|
+
if (!agents || !(nuxt.options.dev || nuxt.options._prepare) || process.env.CI || nuxt.options.test) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const logger = useLogger("maz-ui");
|
|
172
|
+
const isExplicit = nuxt.options.mazUi?.agents !== void 0;
|
|
173
|
+
try {
|
|
174
|
+
const { rootDir, workspaceDir } = nuxt.options;
|
|
175
|
+
const { targets: requestedTargets, rules = true, mcp = true, dir } = typeof agents === "object" ? agents : {};
|
|
176
|
+
const projectDir = dir ? resolve(rootDir, dir) : workspaceDir || rootDir;
|
|
177
|
+
const targets = requestedTargets ?? detectAgentTargets(projectDir);
|
|
178
|
+
if (targets.length === 0 || !rules && !mcp)
|
|
179
|
+
return;
|
|
180
|
+
const mazUiDir = findProjectPackage(rootDir, "maz-ui");
|
|
181
|
+
const { changes } = setupAgents({
|
|
182
|
+
rootDir: projectDir,
|
|
183
|
+
targets,
|
|
184
|
+
rules,
|
|
185
|
+
mcp,
|
|
186
|
+
...mazUiDir ? { docsDir: join(mazUiDir, "docs") } : {}
|
|
187
|
+
});
|
|
188
|
+
const applied = changes.filter((change) => ["create", "update", "remove"].includes(change.action));
|
|
189
|
+
if (applied.length > 0) {
|
|
190
|
+
const files = applied.map((change) => [change.file, `(${change.action})`].join(" "));
|
|
191
|
+
logger.info(`AI agents configured for maz-ui: ${files.join(", ")}`);
|
|
192
|
+
}
|
|
193
|
+
} catch (error) {
|
|
194
|
+
const message = `Could not configure the AI agents for maz-ui: ${getErrorMessage(error)}`;
|
|
195
|
+
if (isExplicit)
|
|
196
|
+
logger.warn(message);
|
|
197
|
+
else
|
|
198
|
+
logger.debug(message);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
160
201
|
function addMazUiComposableImport({
|
|
161
202
|
name,
|
|
162
203
|
from,
|
|
@@ -179,14 +220,15 @@ const module$1 = defineNuxtModule({
|
|
|
179
220
|
defaults,
|
|
180
221
|
/* eslint-disable complexity, sonarjs/cognitive-complexity */
|
|
181
222
|
setup(options, nuxt) {
|
|
182
|
-
const { resolve } = createResolver(import.meta.url);
|
|
223
|
+
const { resolve: resolve2 } = createResolver(import.meta.url);
|
|
183
224
|
nuxt.options.build.transpile.push("maz-ui", "@maz-ui/themes", "@maz-ui/translations");
|
|
184
|
-
const moduleOptions = defu(
|
|
225
|
+
const { agents, ...moduleOptions } = defu(
|
|
185
226
|
nuxt.options.runtimeConfig.public.mazUi,
|
|
186
227
|
options,
|
|
187
228
|
defaults
|
|
188
229
|
);
|
|
189
230
|
nuxt.options.runtimeConfig.public.mazUi = moduleOptions;
|
|
231
|
+
syncAgents(agents, nuxt);
|
|
190
232
|
if (moduleOptions.css.injectCss) {
|
|
191
233
|
nuxt.options.css.unshift("maz-ui/style.css");
|
|
192
234
|
}
|
|
@@ -197,9 +239,9 @@ const module$1 = defineNuxtModule({
|
|
|
197
239
|
const current = typeof postcssPlugins.cssnano === "object" && postcssPlugins.cssnano !== null ? postcssPlugins.cssnano : {};
|
|
198
240
|
postcssPlugins.cssnano = { ...current, preset: ["default", { calc: false }] };
|
|
199
241
|
}
|
|
200
|
-
addPlugin(
|
|
201
|
-
addPlugin(
|
|
202
|
-
addPlugin(
|
|
242
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/theme"));
|
|
243
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/translations"));
|
|
244
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/maz-link-component"));
|
|
203
245
|
const flags = moduleOptions.flags;
|
|
204
246
|
if (flags && flags !== "cdn" && flags !== "local") {
|
|
205
247
|
moduleOptions.defaults = {
|
|
@@ -208,9 +250,9 @@ const module$1 = defineNuxtModule({
|
|
|
208
250
|
};
|
|
209
251
|
}
|
|
210
252
|
if (flags === "local") {
|
|
211
|
-
addPlugin(
|
|
253
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/local-flags"));
|
|
212
254
|
} else if (Object.keys(moduleOptions.defaults).length > 0) {
|
|
213
|
-
addPlugin(
|
|
255
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/defaults"));
|
|
214
256
|
}
|
|
215
257
|
if (moduleOptions.components.autoImport) {
|
|
216
258
|
for (const name of Object.keys(COMPONENT_NAMES)) {
|
|
@@ -222,10 +264,10 @@ const module$1 = defineNuxtModule({
|
|
|
222
264
|
}
|
|
223
265
|
const autoImportPrefix = moduleOptions.general.autoImportPrefix;
|
|
224
266
|
if (moduleOptions.plugins.aos) {
|
|
225
|
-
addPlugin(
|
|
267
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/aos"));
|
|
226
268
|
addImports({
|
|
227
269
|
name: "useAos",
|
|
228
|
-
from:
|
|
270
|
+
from: resolve2(_dirname, "./runtime/composables/useAos"),
|
|
229
271
|
as: `use${capitalize(autoImportPrefix)}Aos`
|
|
230
272
|
});
|
|
231
273
|
const injectAosCSS = typeof moduleOptions.plugins.aos === "object" && typeof moduleOptions.plugins.aos.injectCss === "boolean" ? moduleOptions.plugins.aos.injectCss : true;
|
|
@@ -234,43 +276,43 @@ const module$1 = defineNuxtModule({
|
|
|
234
276
|
}
|
|
235
277
|
}
|
|
236
278
|
if (moduleOptions.plugins.toast) {
|
|
237
|
-
addPlugin(
|
|
279
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/toast"));
|
|
238
280
|
addImports({
|
|
239
281
|
name: "useToast",
|
|
240
|
-
from:
|
|
282
|
+
from: resolve2(_dirname, "./runtime/composables/useToast"),
|
|
241
283
|
as: `use${capitalize(autoImportPrefix)}Toast`
|
|
242
284
|
});
|
|
243
285
|
}
|
|
244
286
|
if (moduleOptions.plugins.dialog) {
|
|
245
|
-
addPlugin(
|
|
287
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/dialog"));
|
|
246
288
|
addImports({
|
|
247
289
|
name: "useDialog",
|
|
248
|
-
from:
|
|
290
|
+
from: resolve2(_dirname, "./runtime/composables/useDialog"),
|
|
249
291
|
as: `use${capitalize(autoImportPrefix)}Dialog`
|
|
250
292
|
});
|
|
251
293
|
}
|
|
252
294
|
if (moduleOptions.plugins.wait) {
|
|
253
|
-
addPlugin(
|
|
295
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/wait"));
|
|
254
296
|
addImports({
|
|
255
297
|
name: "useWait",
|
|
256
|
-
from:
|
|
298
|
+
from: resolve2(_dirname, "./runtime/composables/useWait"),
|
|
257
299
|
as: `use${capitalize(autoImportPrefix)}Wait`
|
|
258
300
|
});
|
|
259
301
|
}
|
|
260
302
|
if (moduleOptions.directives.vZoomImg) {
|
|
261
|
-
addPlugin(
|
|
303
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/v-zoom-img"));
|
|
262
304
|
}
|
|
263
305
|
if (moduleOptions.directives.vLazyImg) {
|
|
264
|
-
addPlugin(
|
|
306
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/v-lazy-img"));
|
|
265
307
|
}
|
|
266
308
|
if (moduleOptions.directives.vClickOutside) {
|
|
267
|
-
addPlugin(
|
|
309
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/v-click-outside"));
|
|
268
310
|
}
|
|
269
311
|
if (moduleOptions.directives.vFullscreenImg) {
|
|
270
|
-
addPlugin(
|
|
312
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/v-fullscreen-img"));
|
|
271
313
|
}
|
|
272
314
|
if (moduleOptions.directives.vTooltip) {
|
|
273
|
-
addPlugin(
|
|
315
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/v-tooltip"));
|
|
274
316
|
}
|
|
275
317
|
const allowedMazUiComposables = Object.keys(moduleOptions.composables).filter((composable) => mazUiComposables[composable]);
|
|
276
318
|
for (const composable of allowedMazUiComposables) {
|
|
@@ -295,10 +337,10 @@ const module$1 = defineNuxtModule({
|
|
|
295
337
|
});
|
|
296
338
|
}
|
|
297
339
|
if (moduleOptions.general.defaultMazIconPath) {
|
|
298
|
-
addPlugin(
|
|
340
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/maz-icon-path"));
|
|
299
341
|
}
|
|
300
342
|
if (moduleOptions.general.preventIosInputZoom) {
|
|
301
|
-
addPlugin(
|
|
343
|
+
addPlugin(resolve2(_dirname, "./runtime/plugins/prevent-ios-input-zoom.client"));
|
|
302
344
|
}
|
|
303
345
|
if (moduleOptions.general.devtools) {
|
|
304
346
|
addCustomTab({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maz-ui/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0
|
|
4
|
+
"version": "5.1.0-beta.1",
|
|
5
5
|
"description": "Nuxt module for Maz-UI",
|
|
6
6
|
"author": "Louis Mazel <me@loicmazuel.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -51,13 +51,14 @@
|
|
|
51
51
|
"nuxt": ">=3.4.0 <5.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@maz-ui/node": "5.1.0-beta.1",
|
|
54
55
|
"@maz-ui/themes": "5.0.0",
|
|
55
56
|
"@maz-ui/translations": "5.0.0",
|
|
56
57
|
"@maz-ui/utils": "5.0.0",
|
|
57
58
|
"@nuxt/devtools-kit": "^3.4.4",
|
|
58
59
|
"@nuxt/kit": "^4.6.2",
|
|
59
60
|
"defu": "^6.1.7",
|
|
60
|
-
"maz-ui": "5.0
|
|
61
|
+
"maz-ui": "5.1.0-beta.1"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@maz-ui/eslint-config": "5.0.0",
|