@maz-ui/node 5.1.0-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/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +30 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -234,6 +234,14 @@ interface AgentDocs {
|
|
|
234
234
|
*/
|
|
235
235
|
declare function findInstalledPackage(fromDir: string, name: string): string | undefined;
|
|
236
236
|
/** Reads the agent files shipped in `maz-ui/docs/agents` */
|
|
237
|
+
/** Version of an installed package, read from its `package.json` */
|
|
238
|
+
declare function readPackageVersion(packageDir: string): string | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Finds a package installed in a project: in the `node_modules` of the
|
|
241
|
+
* project root and of its workspace folders (`apps/*`, `packages/*`, for
|
|
242
|
+
* monorepos without hoisting), then in the parent folders.
|
|
243
|
+
*/
|
|
244
|
+
declare function findProjectPackage(rootDir: string, name: string): string | undefined;
|
|
237
245
|
declare function readAgentDocs(rootDir: string, docsDir?: string): AgentDocs;
|
|
238
246
|
/**
|
|
239
247
|
* Configures the AI coding agents of a project to use maz-ui: rules (version
|
|
@@ -243,5 +251,5 @@ declare function readAgentDocs(rootDir: string, docsDir?: string): AgentDocs;
|
|
|
243
251
|
*/
|
|
244
252
|
declare function setupAgents(options: SetupAgentsOptions): SetupAgentsResult;
|
|
245
253
|
|
|
246
|
-
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MCP_SERVER_NAME, createLogger, detectAgentTargets, execPromise, findInstalledPackage, logger, printBanner, readAgentDocs, redactError, redactSecrets, setupAgents };
|
|
254
|
+
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MCP_SERVER_NAME, createLogger, detectAgentTargets, execPromise, findInstalledPackage, findProjectPackage, logger, printBanner, readAgentDocs, readPackageVersion, redactError, redactSecrets, setupAgents };
|
|
247
255
|
export type { AgentDocs, AgentTarget, ExecPromiseOptions, LogLevel, Logger, LoggerOptions, SetupAgentsAction, SetupAgentsChange, SetupAgentsOptions, SetupAgentsResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -234,6 +234,14 @@ interface AgentDocs {
|
|
|
234
234
|
*/
|
|
235
235
|
declare function findInstalledPackage(fromDir: string, name: string): string | undefined;
|
|
236
236
|
/** Reads the agent files shipped in `maz-ui/docs/agents` */
|
|
237
|
+
/** Version of an installed package, read from its `package.json` */
|
|
238
|
+
declare function readPackageVersion(packageDir: string): string | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Finds a package installed in a project: in the `node_modules` of the
|
|
241
|
+
* project root and of its workspace folders (`apps/*`, `packages/*`, for
|
|
242
|
+
* monorepos without hoisting), then in the parent folders.
|
|
243
|
+
*/
|
|
244
|
+
declare function findProjectPackage(rootDir: string, name: string): string | undefined;
|
|
237
245
|
declare function readAgentDocs(rootDir: string, docsDir?: string): AgentDocs;
|
|
238
246
|
/**
|
|
239
247
|
* Configures the AI coding agents of a project to use maz-ui: rules (version
|
|
@@ -243,5 +251,5 @@ declare function readAgentDocs(rootDir: string, docsDir?: string): AgentDocs;
|
|
|
243
251
|
*/
|
|
244
252
|
declare function setupAgents(options: SetupAgentsOptions): SetupAgentsResult;
|
|
245
253
|
|
|
246
|
-
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MCP_SERVER_NAME, createLogger, detectAgentTargets, execPromise, findInstalledPackage, logger, printBanner, readAgentDocs, redactError, redactSecrets, setupAgents };
|
|
254
|
+
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MCP_SERVER_NAME, createLogger, detectAgentTargets, execPromise, findInstalledPackage, findProjectPackage, logger, printBanner, readAgentDocs, readPackageVersion, redactError, redactSecrets, setupAgents };
|
|
247
255
|
export type { AgentDocs, AgentTarget, ExecPromiseOptions, LogLevel, Logger, LoggerOptions, SetupAgentsAction, SetupAgentsChange, SetupAgentsOptions, SetupAgentsResult };
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import process$1 from 'node:process';
|
|
|
3
3
|
import { blueBright } from 'colorette';
|
|
4
4
|
import { createConsola } from 'consola';
|
|
5
5
|
import figlet from 'figlet';
|
|
6
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
|
6
|
+
import { existsSync, readdirSync, readFileSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
|
7
7
|
import { join, dirname } from 'node:path';
|
|
8
8
|
import { parse, applyEdits, modify } from 'jsonc-parser';
|
|
9
9
|
|
|
@@ -191,6 +191,12 @@ const MCP_SERVER_NAME = "maz-ui";
|
|
|
191
191
|
const DEFAULT_MCP_SERVER = { command: "npx", args: ["-y", "@maz-ui/mcp@latest"] };
|
|
192
192
|
const CLAUDE_RULE_FILE = ".claude/rules/maz-ui.md";
|
|
193
193
|
const CLAUDE_MEMORY_FILES = ["CLAUDE.md", ".claude/CLAUDE.md", "CLAUDE.local.md"];
|
|
194
|
+
function withVersion(content, version) {
|
|
195
|
+
return content.replace(/^(#{1,2} .+)\n/, `$1
|
|
196
|
+
|
|
197
|
+
> maz-ui ${version} is installed: these rules and the docs in \`node_modules/maz-ui/docs\` match this version.
|
|
198
|
+
`);
|
|
199
|
+
}
|
|
194
200
|
function managedHeader(version) {
|
|
195
201
|
return `<!-- ${MANAGED_MARKER} ${version}: generated by \`npx @maz-ui/mcp init\` (or the \`mazUi.agents\` Nuxt option). Do not edit, your changes would be overwritten: write your own rules elsewhere. -->`;
|
|
196
202
|
}
|
|
@@ -219,10 +225,27 @@ function findInstalledPackage(fromDir, name) {
|
|
|
219
225
|
directory = parent;
|
|
220
226
|
}
|
|
221
227
|
}
|
|
228
|
+
function readPackageVersion(packageDir) {
|
|
229
|
+
const file = join(packageDir, "package.json");
|
|
230
|
+
return existsSync(file) ? JSON.parse(readFileSync(file, "utf8")).version : void 0;
|
|
231
|
+
}
|
|
232
|
+
function findProjectPackage(rootDir, name) {
|
|
233
|
+
const bases = [rootDir];
|
|
234
|
+
for (const folder of ["apps", "packages"]) {
|
|
235
|
+
const root = join(rootDir, folder);
|
|
236
|
+
if (existsSync(root)) {
|
|
237
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
238
|
+
if (entry.isDirectory())
|
|
239
|
+
bases.push(join(root, entry.name));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return bases.map((base) => join(base, "node_modules", name)).find((candidate) => existsSync(join(candidate, "package.json"))) ?? findInstalledPackage(rootDir, name);
|
|
244
|
+
}
|
|
222
245
|
function readAgentDocs(rootDir, docsDir) {
|
|
223
246
|
let directory = docsDir;
|
|
224
247
|
if (!directory) {
|
|
225
|
-
const packageDir =
|
|
248
|
+
const packageDir = findProjectPackage(rootDir, "maz-ui");
|
|
226
249
|
if (!packageDir)
|
|
227
250
|
throw new Error(`maz-ui is not installed in ${rootDir}: install it first (\`npm install maz-ui\`).`);
|
|
228
251
|
directory = join(packageDir, "docs");
|
|
@@ -233,9 +256,10 @@ function readAgentDocs(rootDir, docsDir) {
|
|
|
233
256
|
if (!existsSync(manifestFile) || !existsSync(claudeRuleFile) || !existsSync(agentsMdFile)) {
|
|
234
257
|
throw new Error(`The installed maz-ui does not ship the agent docs (${directory}): upgrade maz-ui to the latest version.`);
|
|
235
258
|
}
|
|
259
|
+
const packageVersion = readPackageVersion(dirname(directory));
|
|
236
260
|
return {
|
|
237
261
|
directory,
|
|
238
|
-
version: JSON.parse(readFileSync(manifestFile, "utf8")).version,
|
|
262
|
+
version: packageVersion ?? JSON.parse(readFileSync(manifestFile, "utf8")).version,
|
|
239
263
|
claudeRule: readFileSync(claudeRuleFile, "utf8").trim(),
|
|
240
264
|
agentsMdSection: readFileSync(agentsMdFile, "utf8").trim()
|
|
241
265
|
};
|
|
@@ -386,14 +410,14 @@ function syncRules(changes, rootDir, targets, docs) {
|
|
|
386
410
|
if (targets.includes("claude")) {
|
|
387
411
|
const rule = docs && !claudeReadsAgentsMd ? `${managedHeader(version)}
|
|
388
412
|
|
|
389
|
-
${docs.claudeRule}
|
|
413
|
+
${withVersion(docs.claudeRule, version)}
|
|
390
414
|
` : void 0;
|
|
391
415
|
syncOwnedFile(changes, CLAUDE_RULE_FILE, rule);
|
|
392
416
|
}
|
|
393
417
|
if (targets.includes("agents-md"))
|
|
394
418
|
syncAgentsMd(changes, docs ? `${managedHeader(version)}
|
|
395
419
|
|
|
396
|
-
${docs.agentsMdSection}` : void 0);
|
|
420
|
+
${withVersion(docs.agentsMdSection, version)}` : void 0);
|
|
397
421
|
}
|
|
398
422
|
function setupAgents(options) {
|
|
399
423
|
const { rootDir, rules = true, mcp = true, dryRun = false, remove = false } = options;
|
|
@@ -413,4 +437,4 @@ function setupAgents(options) {
|
|
|
413
437
|
return { targets, version, changes: changes.changes };
|
|
414
438
|
}
|
|
415
439
|
|
|
416
|
-
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MCP_SERVER_NAME, createLogger, detectAgentTargets, execPromise, findInstalledPackage, logger, printBanner, readAgentDocs, redactError, redactSecrets, setupAgents };
|
|
440
|
+
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MCP_SERVER_NAME, createLogger, detectAgentTargets, execPromise, findInstalledPackage, findProjectPackage, logger, printBanner, readAgentDocs, readPackageVersion, redactError, redactSecrets, setupAgents };
|