import { readFileSync } from 'node:fs' import { join } from 'node:path' import { stringifyFrontmatter } from '../markdown/frontmatter.ts' export interface AgentContent { /** Complete rules: the AGENTS.md section, the skill and the rules page */ rules: string /** Core of the rules, always useful: the Claude Code rule, loaded in the context of the agent, stays short */ rulesCore: string workflow: string } export const SKILL_DESCRIPTION = 'Build Vue and Nuxt UIs with the maz-ui ecosystem (components, composables, directives, @maz-ui/icons, @maz-ui/utils, @maz-ui/themes, Tailwind theme tokens) instead of re-implementing them. Use whenever you write or review Vue/Nuxt components, pages, forms, layouts, styles or helpers in a project that depends on maz-ui.' export function loadAgentContent(contentDir: string): AgentContent { return { rules: readFileSync(join(contentDir, 'rules.md'), 'utf8').trim(), rulesCore: readFileSync(join(contentDir, 'rules-core.md'), 'utf8').trim(), workflow: readFileSync(join(contentDir, 'skill.md'), 'utf8').trim(), } } /** No version number: the docs are generated before the release bumps the version (see setupAgents for the installed one) */ const VERSION_NOTE = '> These rules and the docs in `node_modules/maz-ui/agent-docs` and `node_modules/@maz-ui//agent-docs` match the installed versions of the packages (their `package.json`).' /** `rules.md` at the root of the bundle */ export function renderRulesDoc(content: AgentContent): string { return `${stringifyFrontmatter({ title: 'maz-ui rules for AI agents', description: 'How to use maz-ui and its ecosystem in this project: look-up workflow, components, icons, helpers, Tailwind theme tokens, imports.', })} # maz-ui rules for AI agents ${VERSION_NOTE} ${content.rules} ` } /** Content of `.claude/rules/maz-ui.md`: the core of the rules, the rest is served on demand by the MCP tools */ export function renderClaudeRule(content: AgentContent): string { return `# maz-ui ${content.rulesCore} ` } /** Section inserted between markers in the project `AGENTS.md` */ export function renderAgentsMdSection(content: AgentContent): string { return `## maz-ui ${content.rules} ` } /** `SKILL.md` of the Claude Code plugin: version agnostic */ export function renderSkill(content: AgentContent): string { return `${stringifyFrontmatter({ name: 'maz-ui', description: SKILL_DESCRIPTION, })} # maz-ui ${content.rules} ${content.workflow} ` }