@maz-ui/node 5.2.0-beta.0 → 5.3.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.
- package/README.md +1 -1
- package/dist/agents.d.mts +198 -0
- package/dist/agents.d.ts +198 -0
- package/dist/agents.mjs +5 -0
- package/dist/index.d.mts +3 -149
- package/dist/index.d.ts +3 -149
- package/dist/index.mjs +22 -480
- package/dist/shared/node.rmAtZA9U.mjs +635 -0
- package/package.json +12 -6
package/README.md
CHANGED
|
@@ -370,7 +370,7 @@ All logger methods automatically handle error objects using `getErrorMessage` ut
|
|
|
370
370
|
|
|
371
371
|
## Requirements
|
|
372
372
|
|
|
373
|
-
- Node.js
|
|
373
|
+
- Node.js 22.23.4+, 24.22.1+ or 26.12.1+ (the releases with the October 2026 security fixes)
|
|
374
374
|
- TypeScript support included
|
|
375
375
|
|
|
376
376
|
## Contributing
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI coding agents supported by `setupAgents`.
|
|
3
|
+
*
|
|
4
|
+
* - `claude`: Claude Code rule (`.claude/rules/<tool>.md`) and MCP server (`.mcp.json`)
|
|
5
|
+
* - `agents-md`: section in `AGENTS.md` (Codex, Cursor, Copilot, Windsurf, Zed, Gemini...)
|
|
6
|
+
* - `cursor`: MCP server in `.cursor/mcp.json` (rules come from `AGENTS.md`)
|
|
7
|
+
* - `vscode`: MCP server in `.vscode/mcp.json` for GitHub Copilot (rules come from `AGENTS.md`)
|
|
8
|
+
*/
|
|
9
|
+
type AgentTarget = 'claude' | 'agents-md' | 'cursor' | 'vscode';
|
|
10
|
+
declare const AGENT_TARGETS: AgentTarget[];
|
|
11
|
+
interface SetupAgentsOptions {
|
|
12
|
+
/** Root of the project (where `AGENTS.md`, `.claude/`, `.mcp.json` live) */
|
|
13
|
+
rootDir: string;
|
|
14
|
+
/** Agents to configure. Default: the agents detected in the project */
|
|
15
|
+
targets?: AgentTarget[];
|
|
16
|
+
/** Write the rules of the tool (Claude Code rule, `AGENTS.md` section). Default `true` */
|
|
17
|
+
rules?: boolean;
|
|
18
|
+
/** Register the MCP server of the tool. Default `true` */
|
|
19
|
+
mcp?: boolean;
|
|
20
|
+
/** Compute the changes without writing anything */
|
|
21
|
+
dryRun?: boolean;
|
|
22
|
+
/** Remove everything `setupAgents` added */
|
|
23
|
+
remove?: boolean;
|
|
24
|
+
/** Folder of the maz-ui agent docs. Default: `docs/` of the maz-ui package installed in `rootDir` */
|
|
25
|
+
docsDir?: string;
|
|
26
|
+
/** Command used to start the MCP server. Default: `mcpServerCommand(rootDir, mcpVersion, tool)` */
|
|
27
|
+
mcpServer?: McpServerCommand;
|
|
28
|
+
/** Version of the MCP package pinned in the `npx -y` command, when the project does not install it. Default `latest` */
|
|
29
|
+
mcpVersion?: string;
|
|
30
|
+
/** Tool whose agents are configured. Default: maz-ui (`MAZ_UI_AGENTS_TOOL`) */
|
|
31
|
+
tool?: AgentsTool;
|
|
32
|
+
/** Rules of the tool, required with another `tool` than maz-ui. Default: the maz-ui agent docs of `docsDir` */
|
|
33
|
+
agentDocs?: AgentDocs;
|
|
34
|
+
/**
|
|
35
|
+
* Scope of the Claude Code rule, written as a `paths:` frontmatter so that Claude Code only loads it
|
|
36
|
+
* when it reads or edits a matching file, instead of at every session:
|
|
37
|
+
* - `'auto'` (default): the files of the workspaces whose `package.json` depends on one of `tool.packages`
|
|
38
|
+
* (e.g. `apps/pwa/**\/*.vue`), else the files of the project. No scope when the tool declares no `packages`
|
|
39
|
+
* - `'all'`: no scope, the rule is always loaded
|
|
40
|
+
* - globs, relative to `rootDir`: used as is
|
|
41
|
+
*/
|
|
42
|
+
paths?: 'auto' | 'all' | string[];
|
|
43
|
+
}
|
|
44
|
+
interface McpServerCommand {
|
|
45
|
+
command: string;
|
|
46
|
+
args: string[];
|
|
47
|
+
}
|
|
48
|
+
type SetupAgentsAction = 'create' | 'update' | 'remove' | 'unchanged' | 'skip';
|
|
49
|
+
interface SetupAgentsChange {
|
|
50
|
+
/** Path relative to `rootDir` */
|
|
51
|
+
file: string;
|
|
52
|
+
action: SetupAgentsAction;
|
|
53
|
+
reason?: string;
|
|
54
|
+
}
|
|
55
|
+
interface SetupAgentsResult {
|
|
56
|
+
targets: AgentTarget[];
|
|
57
|
+
version: string;
|
|
58
|
+
changes: SetupAgentsChange[];
|
|
59
|
+
/** Command registered in the MCP config files */
|
|
60
|
+
mcpServer: McpServerCommand;
|
|
61
|
+
/** `false` when the server runs through `npx -y` because the project does not install the MCP package */
|
|
62
|
+
localMcpServer: boolean;
|
|
63
|
+
/** Globs the Claude Code rule is scoped to (`paths:` frontmatter). `undefined`: the rule is always loaded, or not written */
|
|
64
|
+
claudeRulePaths?: string[];
|
|
65
|
+
}
|
|
66
|
+
declare const MANAGED_MARKER = "Managed by maz-ui";
|
|
67
|
+
declare const AGENTS_MD_BEGIN = "<!-- BEGIN:maz-ui -->";
|
|
68
|
+
declare const AGENTS_MD_END = "<!-- END:maz-ui -->";
|
|
69
|
+
declare const MCP_SERVER_NAME = "maz-ui";
|
|
70
|
+
declare const DEFAULT_MCP_SERVER: McpServerCommand;
|
|
71
|
+
/**
|
|
72
|
+
* A tool whose AI agents are configured by `setupAgents`: maz-ui by default,
|
|
73
|
+
* or another package that ships its own MCP server and rules.
|
|
74
|
+
*/
|
|
75
|
+
interface AgentsTool {
|
|
76
|
+
/** Name of the tool: key of its MCP server, `.claude/rules/<name>.md` and markers of the generated content */
|
|
77
|
+
name: string;
|
|
78
|
+
/** Package that ships the MCP server */
|
|
79
|
+
mcpPackage: string;
|
|
80
|
+
/** Bin of `mcpPackage` that starts the MCP server */
|
|
81
|
+
mcpBin: string;
|
|
82
|
+
/** Arguments of `mcpBin` that start the MCP server (e.g. `['mcp']`). Default `[]` */
|
|
83
|
+
mcpArgs?: string[];
|
|
84
|
+
/** What generates the rules, written in their header (markdown, e.g. `` `npx relizy mcp init` ``) */
|
|
85
|
+
generatedBy: string;
|
|
86
|
+
/** Marker of the generated content, written in its header and used to recognize the files the tool owns. Default `Managed by <name>` */
|
|
87
|
+
marker?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Line written under the title of the rules, `false` to write none.
|
|
90
|
+
* Default: `> <name> <version> is installed: these rules match this version.`
|
|
91
|
+
*/
|
|
92
|
+
versionNote?: ((version: string) => string) | false;
|
|
93
|
+
/**
|
|
94
|
+
* Packages (or bins) of former MCP servers of the tool: an entry of the MCP config files that references one of
|
|
95
|
+
* them, when the tool has no entry yet, is replaced by the entry of the tool. Default: none
|
|
96
|
+
*/
|
|
97
|
+
legacyMcpPackages?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Packages whose presence in the `dependencies`, `devDependencies`, `peerDependencies` or `optionalDependencies`
|
|
100
|
+
* of a `package.json` ties the files of its project to the tool (e.g. `['maz-ui', '@maz-ui/themes']`). Used by
|
|
101
|
+
* the `'auto'` scope of the Claude Code rule. Default: none, the rule is always loaded
|
|
102
|
+
*/
|
|
103
|
+
packages?: string[];
|
|
104
|
+
/**
|
|
105
|
+
* Files of a project the rule applies to, relative to its folder. Default `['**\/*']` (the whole project).
|
|
106
|
+
* With `packages`, applied to each workspace that depends on one of them
|
|
107
|
+
*/
|
|
108
|
+
ruleGlobs?: string[];
|
|
109
|
+
}
|
|
110
|
+
declare const MAZ_UI_AGENTS_TOOL: AgentsTool;
|
|
111
|
+
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';
|
|
112
|
+
/** `true` when the `package.json` of the project declares the MCP package of the tool (`@maz-ui/mcp` by default) */
|
|
113
|
+
declare function installsMcpPackage(rootDir: string, tool?: AgentsTool): boolean;
|
|
114
|
+
/** Package manager of a project: the `packageManager` field, else its lockfile */
|
|
115
|
+
declare function detectPackageManager(rootDir: string): PackageManager;
|
|
116
|
+
/**
|
|
117
|
+
* Command of the MCP server of a tool (maz-ui by default) for a project. When
|
|
118
|
+
* the project installs its package, the package manager starts the installed
|
|
119
|
+
* version in about a second, at the version of the lockfile. Otherwise
|
|
120
|
+
* `npx -y` downloads it, pinned to `version`: a dist-tag (`latest`) makes npx
|
|
121
|
+
* query the registry at every start, which can exceed the start timeout of the
|
|
122
|
+
* agents behind a slow registry.
|
|
123
|
+
*/
|
|
124
|
+
declare function mcpServerCommand(rootDir: string, version?: string, tool?: AgentsTool): McpServerCommand;
|
|
125
|
+
/**
|
|
126
|
+
* `true` when generated rules were edited by hand since they were written:
|
|
127
|
+
* they are kept, a newer version of the rules would overwrite the edits.
|
|
128
|
+
* The checksum covers what follows the managed header, and also what precedes
|
|
129
|
+
* it (the `paths:` frontmatter), so an edit of the frontmatter is kept too. A
|
|
130
|
+
* checksum of the body alone is still accepted: rules written without
|
|
131
|
+
* frontmatter (header on the first line), or before the frontmatter was part
|
|
132
|
+
* of the checksum, are checked against it.
|
|
133
|
+
*/
|
|
134
|
+
declare function isEditedManagedContent(content: string | undefined, tool?: AgentsTool): boolean;
|
|
135
|
+
/** Detects the AI agents configured in a project */
|
|
136
|
+
declare function detectAgentTargets(rootDir: string): AgentTarget[];
|
|
137
|
+
interface AgentDocs {
|
|
138
|
+
directory: string;
|
|
139
|
+
version: string;
|
|
140
|
+
claudeRule: string;
|
|
141
|
+
agentsMdSection: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Finds `node_modules/<name>` from a directory up to the filesystem root, like
|
|
145
|
+
* the Node resolution but without the global folders (`NODE_PATH`), so only a
|
|
146
|
+
* package installed for the project is found.
|
|
147
|
+
*/
|
|
148
|
+
declare function findInstalledPackage(fromDir: string, name: string): string | undefined;
|
|
149
|
+
/** Version of an installed package, read from its `package.json` */
|
|
150
|
+
declare function readPackageVersion(packageDir: string): string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Workspace patterns of a monorepo: the `packages` of `pnpm-workspace.yaml`,
|
|
153
|
+
* else the `workspaces` of `package.json` (npm, yarn, bun), else `apps/*` and
|
|
154
|
+
* `packages/*`. Negated patterns are ignored.
|
|
155
|
+
*/
|
|
156
|
+
declare function readWorkspacePatterns(rootDir: string): string[];
|
|
157
|
+
/** Folders of the workspaces of a monorepo, in the order of the patterns. Only the fixed part of each pattern is read (`apps/*` reads `apps`) */
|
|
158
|
+
declare function findWorkspaceDirs(rootDir: string): string[];
|
|
159
|
+
/**
|
|
160
|
+
* Finds a package installed in a project: in the `node_modules` of the
|
|
161
|
+
* project root and of its workspaces (monorepos without hoisting), then in
|
|
162
|
+
* the parent folders.
|
|
163
|
+
*/
|
|
164
|
+
declare function findProjectPackage(rootDir: string, name: string): string | undefined;
|
|
165
|
+
/** Reads the agent files shipped in `maz-ui/docs/agents` */
|
|
166
|
+
declare function readAgentDocs(rootDir: string, docsDir?: string): AgentDocs;
|
|
167
|
+
/**
|
|
168
|
+
* Writes a temporary file then renames it: a concurrent reader (several Nuxt
|
|
169
|
+
* apps of a monorepo starting together) sees the old or the new file, never a
|
|
170
|
+
* truncated one.
|
|
171
|
+
*/
|
|
172
|
+
declare function writeFileAtomic(path: string, content: string): void;
|
|
173
|
+
/** Compares two semver versions: negative when `a < b`, positive when `a > b`, `0` when equal */
|
|
174
|
+
declare function compareVersions(a: string, b: string): number;
|
|
175
|
+
/** Version of the tool (maz-ui by default) that generated a managed content, read from its header */
|
|
176
|
+
declare function readManagedVersion(content: string | undefined, tool?: AgentsTool): string | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Folders (relative to `rootDir`, `''` for the root) whose `package.json` depends on one of the packages: the
|
|
179
|
+
* workspaces of a monorepo, or the root of a single package project. The workspaces excluded by a negated pattern
|
|
180
|
+
* (`!apps/legacy`) are left out, with the folders below them
|
|
181
|
+
*/
|
|
182
|
+
declare function findWorkspacesUsing(rootDir: string, packages: string[]): string[];
|
|
183
|
+
/**
|
|
184
|
+
* Globs the Claude Code rule is scoped to, `undefined` when it must always be loaded. The root of the project
|
|
185
|
+
* depending on the tool (single package project), or no dependency found (the tool is used from elsewhere), apply
|
|
186
|
+
* the files of the tool to the whole project, since no folder is more relevant than another.
|
|
187
|
+
*/
|
|
188
|
+
declare function resolveRulePaths(rootDir: string, tool: AgentsTool, option?: SetupAgentsOptions['paths']): string[] | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Configures the AI coding agents of a project to use a tool, maz-ui by
|
|
191
|
+
* default: rules (version matched with the installed tool) and its MCP server.
|
|
192
|
+
* Idempotent and conservative: it only writes files it owns, a delimited
|
|
193
|
+
* section of `AGENTS.md` and its own entry of the MCP config files.
|
|
194
|
+
*/
|
|
195
|
+
declare function setupAgents(options: SetupAgentsOptions): SetupAgentsResult;
|
|
196
|
+
|
|
197
|
+
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MAZ_UI_AGENTS_TOOL, MCP_SERVER_NAME, compareVersions, detectAgentTargets, detectPackageManager, findInstalledPackage, findProjectPackage, findWorkspaceDirs, findWorkspacesUsing, installsMcpPackage, isEditedManagedContent, mcpServerCommand, readAgentDocs, readManagedVersion, readPackageVersion, readWorkspacePatterns, resolveRulePaths, setupAgents, writeFileAtomic };
|
|
198
|
+
export type { AgentDocs, AgentTarget, AgentsTool, McpServerCommand, PackageManager, SetupAgentsAction, SetupAgentsChange, SetupAgentsOptions, SetupAgentsResult };
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI coding agents supported by `setupAgents`.
|
|
3
|
+
*
|
|
4
|
+
* - `claude`: Claude Code rule (`.claude/rules/<tool>.md`) and MCP server (`.mcp.json`)
|
|
5
|
+
* - `agents-md`: section in `AGENTS.md` (Codex, Cursor, Copilot, Windsurf, Zed, Gemini...)
|
|
6
|
+
* - `cursor`: MCP server in `.cursor/mcp.json` (rules come from `AGENTS.md`)
|
|
7
|
+
* - `vscode`: MCP server in `.vscode/mcp.json` for GitHub Copilot (rules come from `AGENTS.md`)
|
|
8
|
+
*/
|
|
9
|
+
type AgentTarget = 'claude' | 'agents-md' | 'cursor' | 'vscode';
|
|
10
|
+
declare const AGENT_TARGETS: AgentTarget[];
|
|
11
|
+
interface SetupAgentsOptions {
|
|
12
|
+
/** Root of the project (where `AGENTS.md`, `.claude/`, `.mcp.json` live) */
|
|
13
|
+
rootDir: string;
|
|
14
|
+
/** Agents to configure. Default: the agents detected in the project */
|
|
15
|
+
targets?: AgentTarget[];
|
|
16
|
+
/** Write the rules of the tool (Claude Code rule, `AGENTS.md` section). Default `true` */
|
|
17
|
+
rules?: boolean;
|
|
18
|
+
/** Register the MCP server of the tool. Default `true` */
|
|
19
|
+
mcp?: boolean;
|
|
20
|
+
/** Compute the changes without writing anything */
|
|
21
|
+
dryRun?: boolean;
|
|
22
|
+
/** Remove everything `setupAgents` added */
|
|
23
|
+
remove?: boolean;
|
|
24
|
+
/** Folder of the maz-ui agent docs. Default: `docs/` of the maz-ui package installed in `rootDir` */
|
|
25
|
+
docsDir?: string;
|
|
26
|
+
/** Command used to start the MCP server. Default: `mcpServerCommand(rootDir, mcpVersion, tool)` */
|
|
27
|
+
mcpServer?: McpServerCommand;
|
|
28
|
+
/** Version of the MCP package pinned in the `npx -y` command, when the project does not install it. Default `latest` */
|
|
29
|
+
mcpVersion?: string;
|
|
30
|
+
/** Tool whose agents are configured. Default: maz-ui (`MAZ_UI_AGENTS_TOOL`) */
|
|
31
|
+
tool?: AgentsTool;
|
|
32
|
+
/** Rules of the tool, required with another `tool` than maz-ui. Default: the maz-ui agent docs of `docsDir` */
|
|
33
|
+
agentDocs?: AgentDocs;
|
|
34
|
+
/**
|
|
35
|
+
* Scope of the Claude Code rule, written as a `paths:` frontmatter so that Claude Code only loads it
|
|
36
|
+
* when it reads or edits a matching file, instead of at every session:
|
|
37
|
+
* - `'auto'` (default): the files of the workspaces whose `package.json` depends on one of `tool.packages`
|
|
38
|
+
* (e.g. `apps/pwa/**\/*.vue`), else the files of the project. No scope when the tool declares no `packages`
|
|
39
|
+
* - `'all'`: no scope, the rule is always loaded
|
|
40
|
+
* - globs, relative to `rootDir`: used as is
|
|
41
|
+
*/
|
|
42
|
+
paths?: 'auto' | 'all' | string[];
|
|
43
|
+
}
|
|
44
|
+
interface McpServerCommand {
|
|
45
|
+
command: string;
|
|
46
|
+
args: string[];
|
|
47
|
+
}
|
|
48
|
+
type SetupAgentsAction = 'create' | 'update' | 'remove' | 'unchanged' | 'skip';
|
|
49
|
+
interface SetupAgentsChange {
|
|
50
|
+
/** Path relative to `rootDir` */
|
|
51
|
+
file: string;
|
|
52
|
+
action: SetupAgentsAction;
|
|
53
|
+
reason?: string;
|
|
54
|
+
}
|
|
55
|
+
interface SetupAgentsResult {
|
|
56
|
+
targets: AgentTarget[];
|
|
57
|
+
version: string;
|
|
58
|
+
changes: SetupAgentsChange[];
|
|
59
|
+
/** Command registered in the MCP config files */
|
|
60
|
+
mcpServer: McpServerCommand;
|
|
61
|
+
/** `false` when the server runs through `npx -y` because the project does not install the MCP package */
|
|
62
|
+
localMcpServer: boolean;
|
|
63
|
+
/** Globs the Claude Code rule is scoped to (`paths:` frontmatter). `undefined`: the rule is always loaded, or not written */
|
|
64
|
+
claudeRulePaths?: string[];
|
|
65
|
+
}
|
|
66
|
+
declare const MANAGED_MARKER = "Managed by maz-ui";
|
|
67
|
+
declare const AGENTS_MD_BEGIN = "<!-- BEGIN:maz-ui -->";
|
|
68
|
+
declare const AGENTS_MD_END = "<!-- END:maz-ui -->";
|
|
69
|
+
declare const MCP_SERVER_NAME = "maz-ui";
|
|
70
|
+
declare const DEFAULT_MCP_SERVER: McpServerCommand;
|
|
71
|
+
/**
|
|
72
|
+
* A tool whose AI agents are configured by `setupAgents`: maz-ui by default,
|
|
73
|
+
* or another package that ships its own MCP server and rules.
|
|
74
|
+
*/
|
|
75
|
+
interface AgentsTool {
|
|
76
|
+
/** Name of the tool: key of its MCP server, `.claude/rules/<name>.md` and markers of the generated content */
|
|
77
|
+
name: string;
|
|
78
|
+
/** Package that ships the MCP server */
|
|
79
|
+
mcpPackage: string;
|
|
80
|
+
/** Bin of `mcpPackage` that starts the MCP server */
|
|
81
|
+
mcpBin: string;
|
|
82
|
+
/** Arguments of `mcpBin` that start the MCP server (e.g. `['mcp']`). Default `[]` */
|
|
83
|
+
mcpArgs?: string[];
|
|
84
|
+
/** What generates the rules, written in their header (markdown, e.g. `` `npx relizy mcp init` ``) */
|
|
85
|
+
generatedBy: string;
|
|
86
|
+
/** Marker of the generated content, written in its header and used to recognize the files the tool owns. Default `Managed by <name>` */
|
|
87
|
+
marker?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Line written under the title of the rules, `false` to write none.
|
|
90
|
+
* Default: `> <name> <version> is installed: these rules match this version.`
|
|
91
|
+
*/
|
|
92
|
+
versionNote?: ((version: string) => string) | false;
|
|
93
|
+
/**
|
|
94
|
+
* Packages (or bins) of former MCP servers of the tool: an entry of the MCP config files that references one of
|
|
95
|
+
* them, when the tool has no entry yet, is replaced by the entry of the tool. Default: none
|
|
96
|
+
*/
|
|
97
|
+
legacyMcpPackages?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Packages whose presence in the `dependencies`, `devDependencies`, `peerDependencies` or `optionalDependencies`
|
|
100
|
+
* of a `package.json` ties the files of its project to the tool (e.g. `['maz-ui', '@maz-ui/themes']`). Used by
|
|
101
|
+
* the `'auto'` scope of the Claude Code rule. Default: none, the rule is always loaded
|
|
102
|
+
*/
|
|
103
|
+
packages?: string[];
|
|
104
|
+
/**
|
|
105
|
+
* Files of a project the rule applies to, relative to its folder. Default `['**\/*']` (the whole project).
|
|
106
|
+
* With `packages`, applied to each workspace that depends on one of them
|
|
107
|
+
*/
|
|
108
|
+
ruleGlobs?: string[];
|
|
109
|
+
}
|
|
110
|
+
declare const MAZ_UI_AGENTS_TOOL: AgentsTool;
|
|
111
|
+
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';
|
|
112
|
+
/** `true` when the `package.json` of the project declares the MCP package of the tool (`@maz-ui/mcp` by default) */
|
|
113
|
+
declare function installsMcpPackage(rootDir: string, tool?: AgentsTool): boolean;
|
|
114
|
+
/** Package manager of a project: the `packageManager` field, else its lockfile */
|
|
115
|
+
declare function detectPackageManager(rootDir: string): PackageManager;
|
|
116
|
+
/**
|
|
117
|
+
* Command of the MCP server of a tool (maz-ui by default) for a project. When
|
|
118
|
+
* the project installs its package, the package manager starts the installed
|
|
119
|
+
* version in about a second, at the version of the lockfile. Otherwise
|
|
120
|
+
* `npx -y` downloads it, pinned to `version`: a dist-tag (`latest`) makes npx
|
|
121
|
+
* query the registry at every start, which can exceed the start timeout of the
|
|
122
|
+
* agents behind a slow registry.
|
|
123
|
+
*/
|
|
124
|
+
declare function mcpServerCommand(rootDir: string, version?: string, tool?: AgentsTool): McpServerCommand;
|
|
125
|
+
/**
|
|
126
|
+
* `true` when generated rules were edited by hand since they were written:
|
|
127
|
+
* they are kept, a newer version of the rules would overwrite the edits.
|
|
128
|
+
* The checksum covers what follows the managed header, and also what precedes
|
|
129
|
+
* it (the `paths:` frontmatter), so an edit of the frontmatter is kept too. A
|
|
130
|
+
* checksum of the body alone is still accepted: rules written without
|
|
131
|
+
* frontmatter (header on the first line), or before the frontmatter was part
|
|
132
|
+
* of the checksum, are checked against it.
|
|
133
|
+
*/
|
|
134
|
+
declare function isEditedManagedContent(content: string | undefined, tool?: AgentsTool): boolean;
|
|
135
|
+
/** Detects the AI agents configured in a project */
|
|
136
|
+
declare function detectAgentTargets(rootDir: string): AgentTarget[];
|
|
137
|
+
interface AgentDocs {
|
|
138
|
+
directory: string;
|
|
139
|
+
version: string;
|
|
140
|
+
claudeRule: string;
|
|
141
|
+
agentsMdSection: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Finds `node_modules/<name>` from a directory up to the filesystem root, like
|
|
145
|
+
* the Node resolution but without the global folders (`NODE_PATH`), so only a
|
|
146
|
+
* package installed for the project is found.
|
|
147
|
+
*/
|
|
148
|
+
declare function findInstalledPackage(fromDir: string, name: string): string | undefined;
|
|
149
|
+
/** Version of an installed package, read from its `package.json` */
|
|
150
|
+
declare function readPackageVersion(packageDir: string): string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Workspace patterns of a monorepo: the `packages` of `pnpm-workspace.yaml`,
|
|
153
|
+
* else the `workspaces` of `package.json` (npm, yarn, bun), else `apps/*` and
|
|
154
|
+
* `packages/*`. Negated patterns are ignored.
|
|
155
|
+
*/
|
|
156
|
+
declare function readWorkspacePatterns(rootDir: string): string[];
|
|
157
|
+
/** Folders of the workspaces of a monorepo, in the order of the patterns. Only the fixed part of each pattern is read (`apps/*` reads `apps`) */
|
|
158
|
+
declare function findWorkspaceDirs(rootDir: string): string[];
|
|
159
|
+
/**
|
|
160
|
+
* Finds a package installed in a project: in the `node_modules` of the
|
|
161
|
+
* project root and of its workspaces (monorepos without hoisting), then in
|
|
162
|
+
* the parent folders.
|
|
163
|
+
*/
|
|
164
|
+
declare function findProjectPackage(rootDir: string, name: string): string | undefined;
|
|
165
|
+
/** Reads the agent files shipped in `maz-ui/docs/agents` */
|
|
166
|
+
declare function readAgentDocs(rootDir: string, docsDir?: string): AgentDocs;
|
|
167
|
+
/**
|
|
168
|
+
* Writes a temporary file then renames it: a concurrent reader (several Nuxt
|
|
169
|
+
* apps of a monorepo starting together) sees the old or the new file, never a
|
|
170
|
+
* truncated one.
|
|
171
|
+
*/
|
|
172
|
+
declare function writeFileAtomic(path: string, content: string): void;
|
|
173
|
+
/** Compares two semver versions: negative when `a < b`, positive when `a > b`, `0` when equal */
|
|
174
|
+
declare function compareVersions(a: string, b: string): number;
|
|
175
|
+
/** Version of the tool (maz-ui by default) that generated a managed content, read from its header */
|
|
176
|
+
declare function readManagedVersion(content: string | undefined, tool?: AgentsTool): string | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Folders (relative to `rootDir`, `''` for the root) whose `package.json` depends on one of the packages: the
|
|
179
|
+
* workspaces of a monorepo, or the root of a single package project. The workspaces excluded by a negated pattern
|
|
180
|
+
* (`!apps/legacy`) are left out, with the folders below them
|
|
181
|
+
*/
|
|
182
|
+
declare function findWorkspacesUsing(rootDir: string, packages: string[]): string[];
|
|
183
|
+
/**
|
|
184
|
+
* Globs the Claude Code rule is scoped to, `undefined` when it must always be loaded. The root of the project
|
|
185
|
+
* depending on the tool (single package project), or no dependency found (the tool is used from elsewhere), apply
|
|
186
|
+
* the files of the tool to the whole project, since no folder is more relevant than another.
|
|
187
|
+
*/
|
|
188
|
+
declare function resolveRulePaths(rootDir: string, tool: AgentsTool, option?: SetupAgentsOptions['paths']): string[] | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Configures the AI coding agents of a project to use a tool, maz-ui by
|
|
191
|
+
* default: rules (version matched with the installed tool) and its MCP server.
|
|
192
|
+
* Idempotent and conservative: it only writes files it owns, a delimited
|
|
193
|
+
* section of `AGENTS.md` and its own entry of the MCP config files.
|
|
194
|
+
*/
|
|
195
|
+
declare function setupAgents(options: SetupAgentsOptions): SetupAgentsResult;
|
|
196
|
+
|
|
197
|
+
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MAZ_UI_AGENTS_TOOL, MCP_SERVER_NAME, compareVersions, detectAgentTargets, detectPackageManager, findInstalledPackage, findProjectPackage, findWorkspaceDirs, findWorkspacesUsing, installsMcpPackage, isEditedManagedContent, mcpServerCommand, readAgentDocs, readManagedVersion, readPackageVersion, readWorkspacePatterns, resolveRulePaths, setupAgents, writeFileAtomic };
|
|
198
|
+
export type { AgentDocs, AgentTarget, AgentsTool, McpServerCommand, PackageManager, SetupAgentsAction, SetupAgentsChange, SetupAgentsOptions, SetupAgentsResult };
|
package/dist/agents.mjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { A as AGENTS_MD_BEGIN, a as AGENTS_MD_END, b as AGENT_TARGETS, D as DEFAULT_MCP_SERVER, M as MANAGED_MARKER, c as MAZ_UI_AGENTS_TOOL, d as MCP_SERVER_NAME, e as compareVersions, f as detectAgentTargets, g as detectPackageManager, h as findInstalledPackage, i as findProjectPackage, j as findWorkspaceDirs, k as findWorkspacesUsing, l as installsMcpPackage, m as isEditedManagedContent, n as mcpServerCommand, r as readAgentDocs, o as readManagedVersion, p as readPackageVersion, q as readWorkspacePatterns, s as resolveRulePaths, t as setupAgents, w as writeFileAtomic } from './shared/node.rmAtZA9U.mjs';
|
|
2
|
+
import 'node:crypto';
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import 'node:path';
|
|
5
|
+
import 'jsonc-parser';
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import * as consola from 'consola';
|
|
|
3
3
|
import { ConsolaOptions, InputLogObject, ConsolaReporter, ConsolaInstance } from 'consola';
|
|
4
4
|
export { ConsolaOptions } from 'consola';
|
|
5
5
|
import { FigletOptions } from 'figlet/node';
|
|
6
|
+
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, AgentDocs, AgentTarget, AgentsTool, DEFAULT_MCP_SERVER, MANAGED_MARKER, MAZ_UI_AGENTS_TOOL, MCP_SERVER_NAME, McpServerCommand, PackageManager, SetupAgentsAction, SetupAgentsChange, SetupAgentsOptions, SetupAgentsResult, compareVersions, detectAgentTargets, detectPackageManager, findInstalledPackage, findProjectPackage, findWorkspaceDirs, findWorkspacesUsing, installsMcpPackage, isEditedManagedContent, mcpServerCommand, readAgentDocs, readManagedVersion, readPackageVersion, readWorkspacePatterns, resolveRulePaths, setupAgents, writeFileAtomic } from './agents.mjs';
|
|
6
7
|
|
|
7
8
|
declare const LogLevelMap: {
|
|
8
9
|
silent: number;
|
|
@@ -168,152 +169,5 @@ declare function redactSecrets(input: string): string;
|
|
|
168
169
|
*/
|
|
169
170
|
declare function redactError<T>(error: T): T;
|
|
170
171
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
* - `claude`: Claude Code rule (`.claude/rules/<tool>.md`) and MCP server (`.mcp.json`)
|
|
175
|
-
* - `agents-md`: section in `AGENTS.md` (Codex, Cursor, Copilot, Windsurf, Zed, Gemini...)
|
|
176
|
-
* - `cursor`: MCP server in `.cursor/mcp.json` (rules come from `AGENTS.md`)
|
|
177
|
-
* - `vscode`: MCP server in `.vscode/mcp.json` for GitHub Copilot (rules come from `AGENTS.md`)
|
|
178
|
-
*/
|
|
179
|
-
type AgentTarget = 'claude' | 'agents-md' | 'cursor' | 'vscode';
|
|
180
|
-
declare const AGENT_TARGETS: AgentTarget[];
|
|
181
|
-
interface SetupAgentsOptions {
|
|
182
|
-
/** Root of the project (where `AGENTS.md`, `.claude/`, `.mcp.json` live) */
|
|
183
|
-
rootDir: string;
|
|
184
|
-
/** Agents to configure. Default: the agents detected in the project */
|
|
185
|
-
targets?: AgentTarget[];
|
|
186
|
-
/** Write the rules of the tool (Claude Code rule, `AGENTS.md` section). Default `true` */
|
|
187
|
-
rules?: boolean;
|
|
188
|
-
/** Register the MCP server of the tool. Default `true` */
|
|
189
|
-
mcp?: boolean;
|
|
190
|
-
/** Compute the changes without writing anything */
|
|
191
|
-
dryRun?: boolean;
|
|
192
|
-
/** Remove everything `setupAgents` added */
|
|
193
|
-
remove?: boolean;
|
|
194
|
-
/** Folder of the maz-ui agent docs. Default: `docs/` of the maz-ui package installed in `rootDir` */
|
|
195
|
-
docsDir?: string;
|
|
196
|
-
/** Command used to start the MCP server. Default: `mcpServerCommand(rootDir, mcpVersion, tool)` */
|
|
197
|
-
mcpServer?: McpServerCommand;
|
|
198
|
-
/** Version of the MCP package pinned in the `npx -y` command, when the project does not install it. Default `latest` */
|
|
199
|
-
mcpVersion?: string;
|
|
200
|
-
/** Tool whose agents are configured. Default: maz-ui (`MAZ_UI_AGENTS_TOOL`) */
|
|
201
|
-
tool?: AgentsTool;
|
|
202
|
-
/** Rules of the tool, required with another `tool` than maz-ui. Default: the maz-ui agent docs of `docsDir` */
|
|
203
|
-
agentDocs?: AgentDocs;
|
|
204
|
-
}
|
|
205
|
-
interface McpServerCommand {
|
|
206
|
-
command: string;
|
|
207
|
-
args: string[];
|
|
208
|
-
}
|
|
209
|
-
type SetupAgentsAction = 'create' | 'update' | 'remove' | 'unchanged' | 'skip';
|
|
210
|
-
interface SetupAgentsChange {
|
|
211
|
-
/** Path relative to `rootDir` */
|
|
212
|
-
file: string;
|
|
213
|
-
action: SetupAgentsAction;
|
|
214
|
-
reason?: string;
|
|
215
|
-
}
|
|
216
|
-
interface SetupAgentsResult {
|
|
217
|
-
targets: AgentTarget[];
|
|
218
|
-
version: string;
|
|
219
|
-
changes: SetupAgentsChange[];
|
|
220
|
-
/** Command registered in the MCP config files */
|
|
221
|
-
mcpServer: McpServerCommand;
|
|
222
|
-
/** `false` when the server runs through `npx -y` because the project does not install the MCP package */
|
|
223
|
-
localMcpServer: boolean;
|
|
224
|
-
}
|
|
225
|
-
declare const MANAGED_MARKER = "Managed by maz-ui";
|
|
226
|
-
declare const AGENTS_MD_BEGIN = "<!-- BEGIN:maz-ui -->";
|
|
227
|
-
declare const AGENTS_MD_END = "<!-- END:maz-ui -->";
|
|
228
|
-
declare const MCP_SERVER_NAME = "maz-ui";
|
|
229
|
-
declare const DEFAULT_MCP_SERVER: McpServerCommand;
|
|
230
|
-
/**
|
|
231
|
-
* A tool whose AI agents are configured by `setupAgents`: maz-ui by default,
|
|
232
|
-
* or another package that ships its own MCP server and rules.
|
|
233
|
-
*/
|
|
234
|
-
interface AgentsTool {
|
|
235
|
-
/** Name of the tool: key of its MCP server, `.claude/rules/<name>.md` and markers of the generated content */
|
|
236
|
-
name: string;
|
|
237
|
-
/** Package that ships the MCP server */
|
|
238
|
-
mcpPackage: string;
|
|
239
|
-
/** Bin of `mcpPackage` that starts the MCP server */
|
|
240
|
-
mcpBin: string;
|
|
241
|
-
/** Arguments of `mcpBin` that start the MCP server (e.g. `['mcp']`). Default `[]` */
|
|
242
|
-
mcpArgs?: string[];
|
|
243
|
-
/** What generates the rules, written in their header (markdown, e.g. `` `npx relizy mcp init` ``) */
|
|
244
|
-
generatedBy: string;
|
|
245
|
-
/** Line written under the title of the rules. Default: `> <name> <version> is installed: these rules match this version.` */
|
|
246
|
-
versionNote?: (version: string) => string;
|
|
247
|
-
}
|
|
248
|
-
declare const MAZ_UI_AGENTS_TOOL: AgentsTool;
|
|
249
|
-
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';
|
|
250
|
-
/** `true` when the `package.json` of the project declares the MCP package of the tool (`@maz-ui/mcp` by default) */
|
|
251
|
-
declare function installsMcpPackage(rootDir: string, tool?: AgentsTool): boolean;
|
|
252
|
-
/** Package manager of a project: the `packageManager` field, else its lockfile */
|
|
253
|
-
declare function detectPackageManager(rootDir: string): PackageManager;
|
|
254
|
-
/**
|
|
255
|
-
* Command of the MCP server of a tool (maz-ui by default) for a project. When
|
|
256
|
-
* the project installs its package, the package manager starts the installed
|
|
257
|
-
* version in about a second, at the version of the lockfile. Otherwise
|
|
258
|
-
* `npx -y` downloads it, pinned to `version`: a dist-tag (`latest`) makes npx
|
|
259
|
-
* query the registry at every start, which can exceed the start timeout of the
|
|
260
|
-
* agents behind a slow registry.
|
|
261
|
-
*/
|
|
262
|
-
declare function mcpServerCommand(rootDir: string, version?: string, tool?: AgentsTool): McpServerCommand;
|
|
263
|
-
/**
|
|
264
|
-
* `true` when generated rules were edited by hand since they were written:
|
|
265
|
-
* they are kept, a newer version of the rules would overwrite the edits.
|
|
266
|
-
*/
|
|
267
|
-
declare function isEditedManagedContent(content: string | undefined, tool?: AgentsTool): boolean;
|
|
268
|
-
/** Detects the AI agents configured in a project */
|
|
269
|
-
declare function detectAgentTargets(rootDir: string): AgentTarget[];
|
|
270
|
-
interface AgentDocs {
|
|
271
|
-
directory: string;
|
|
272
|
-
version: string;
|
|
273
|
-
claudeRule: string;
|
|
274
|
-
agentsMdSection: string;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Finds `node_modules/<name>` from a directory up to the filesystem root, like
|
|
278
|
-
* the Node resolution but without the global folders (`NODE_PATH`), so only a
|
|
279
|
-
* package installed for the project is found.
|
|
280
|
-
*/
|
|
281
|
-
declare function findInstalledPackage(fromDir: string, name: string): string | undefined;
|
|
282
|
-
/** Version of an installed package, read from its `package.json` */
|
|
283
|
-
declare function readPackageVersion(packageDir: string): string | undefined;
|
|
284
|
-
/**
|
|
285
|
-
* Workspace patterns of a monorepo: the `packages` of `pnpm-workspace.yaml`,
|
|
286
|
-
* else the `workspaces` of `package.json` (npm, yarn, bun), else `apps/*` and
|
|
287
|
-
* `packages/*`. Negated patterns are ignored.
|
|
288
|
-
*/
|
|
289
|
-
declare function readWorkspacePatterns(rootDir: string): string[];
|
|
290
|
-
/** Folders of the workspaces of a monorepo, in the order of the patterns. Only the fixed part of each pattern is read (`apps/*` reads `apps`) */
|
|
291
|
-
declare function findWorkspaceDirs(rootDir: string): string[];
|
|
292
|
-
/**
|
|
293
|
-
* Finds a package installed in a project: in the `node_modules` of the
|
|
294
|
-
* project root and of its workspaces (monorepos without hoisting), then in
|
|
295
|
-
* the parent folders.
|
|
296
|
-
*/
|
|
297
|
-
declare function findProjectPackage(rootDir: string, name: string): string | undefined;
|
|
298
|
-
/** Reads the agent files shipped in `maz-ui/docs/agents` */
|
|
299
|
-
declare function readAgentDocs(rootDir: string, docsDir?: string): AgentDocs;
|
|
300
|
-
/**
|
|
301
|
-
* Writes a temporary file then renames it: a concurrent reader (several Nuxt
|
|
302
|
-
* apps of a monorepo starting together) sees the old or the new file, never a
|
|
303
|
-
* truncated one.
|
|
304
|
-
*/
|
|
305
|
-
declare function writeFileAtomic(path: string, content: string): void;
|
|
306
|
-
/** Compares two semver versions: negative when `a < b`, positive when `a > b`, `0` when equal */
|
|
307
|
-
declare function compareVersions(a: string, b: string): number;
|
|
308
|
-
/** Version of the tool (maz-ui by default) that generated a managed content, read from its header */
|
|
309
|
-
declare function readManagedVersion(content: string | undefined, tool?: AgentsTool): string | undefined;
|
|
310
|
-
/**
|
|
311
|
-
* Configures the AI coding agents of a project to use a tool, maz-ui by
|
|
312
|
-
* default: rules (version matched with the installed tool) and its MCP server.
|
|
313
|
-
* Idempotent and conservative: it only writes files it owns, a delimited
|
|
314
|
-
* section of `AGENTS.md` and its own entry of the MCP config files.
|
|
315
|
-
*/
|
|
316
|
-
declare function setupAgents(options: SetupAgentsOptions): SetupAgentsResult;
|
|
317
|
-
|
|
318
|
-
export { AGENTS_MD_BEGIN, AGENTS_MD_END, AGENT_TARGETS, DEFAULT_MCP_SERVER, MANAGED_MARKER, MAZ_UI_AGENTS_TOOL, MCP_SERVER_NAME, compareVersions, createLogger, detectAgentTargets, detectPackageManager, execPromise, findInstalledPackage, findProjectPackage, findWorkspaceDirs, installsMcpPackage, isEditedManagedContent, logger, mcpServerCommand, printBanner, readAgentDocs, readManagedVersion, readPackageVersion, readWorkspacePatterns, redactError, redactSecrets, setupAgents, writeFileAtomic };
|
|
319
|
-
export type { AgentDocs, AgentTarget, AgentsTool, ExecPromiseOptions, LogLevel, Logger, LoggerOptions, McpServerCommand, PackageManager, SetupAgentsAction, SetupAgentsChange, SetupAgentsOptions, SetupAgentsResult };
|
|
172
|
+
export { createLogger, execPromise, logger, printBanner, redactError, redactSecrets };
|
|
173
|
+
export type { ExecPromiseOptions, LogLevel, Logger, LoggerOptions };
|