diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 2cec261..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Build - -on: - push: - branches: [main] - - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - - - run: bun install - - - run: bun run build diff --git a/docs/anthropic-submission.md b/docs/anthropic-submission.md index bedba3f..d3ff547 100644 --- a/docs/anthropic-submission.md +++ b/docs/anthropic-submission.md @@ -56,6 +56,26 @@ auto-discover the universal endpoint. logs. It does not change project files, but the Claude profile conservatively treats that infrastructure side effect as a state-changing operation. +## Directory file rules + +The directory accepts scripts, programs, and other file types only from Verified +organizations. Until the Macaly organization is Verified, keep every file in this +repository inside these rules: + +- Use only Markdown, text, JSON, and YAML files, and PNG, JPEG, GIF, WebP, or ICO + images. +- Do not add a file that starts with `#!`. +- Do not add a package manager configuration file, such as package.json or + pnpm-workspace.yaml. +- Save each text file as UTF-8 with no NUL bytes. + +The license, the readme files, .gitignore, and the plugin icon can stay. The plugin +icon is the PNG logo that the `icon` field of the Claude manifest names. The Codex and +Cursor manifests use the same file. + +The Cursor and Codex validators and the CI workflow that ran them broke these rules, +so the repository does not hold them. Commit `449edd5` has the last copy. + ## Review preparation 1. Deploy the Claude endpoint and verify its OAuth metadata at diff --git a/package.json b/package.json deleted file mode 100644 index c3d0592..0000000 --- a/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "macaly-agent-plugins", - "type": "module", - "private": true, - "scripts": { - "build": "bun ./scripts/validate-cursor-schema.mjs && bun ./scripts/validate-cursor-structure.mjs && bun ./scripts/validate-codex.mjs" - }, - "devDependencies": { - "@types/bun": "latest", - "ajv": "^8.18.0", - "ajv-formats": "^3.0.1" - }, - "peerDependencies": { - "typescript": "^5" - } -} diff --git a/plugins/macaly-code/.claude-plugin/plugin.json b/plugins/macaly-code/.claude-plugin/plugin.json index 9b313f7..ae3fbe7 100644 --- a/plugins/macaly-code/.claude-plugin/plugin.json +++ b/plugins/macaly-code/.claude-plugin/plugin.json @@ -7,6 +7,7 @@ "url": "https://www.macaly.com" }, "homepage": "https://www.macaly.com", + "icon": "./assets/logo.png", "documentationUrl": "https://www.macaly.com/docs/en/welcome/overview", "supportUrl": "https://www.macaly.com/docs/en/welcome/faq#support", "privacyPolicyUrl": "https://www.macaly.com/privacy-policy", diff --git a/plugins/macaly-code/.codex-plugin/plugin.json b/plugins/macaly-code/.codex-plugin/plugin.json index 5690d43..27d07fb 100644 --- a/plugins/macaly-code/.codex-plugin/plugin.json +++ b/plugins/macaly-code/.codex-plugin/plugin.json @@ -25,8 +25,8 @@ "privacyPolicyURL": "https://www.macaly.com/privacy-policy", "termsOfServiceURL": "https://www.macaly.com/terms-of-service", "brandColor": "#000000", - "composerIcon": "./assets/logo.svg", - "logo": "./assets/logo.svg", + "composerIcon": "./assets/logo.png", + "logo": "./assets/logo.png", "defaultPrompt": [ "Build a customer feedback dashboard", "Build a landing page for my coffee shop", diff --git a/plugins/macaly-code/.cursor-plugin/plugin.json b/plugins/macaly-code/.cursor-plugin/plugin.json index bb9b369..c464f0a 100644 --- a/plugins/macaly-code/.cursor-plugin/plugin.json +++ b/plugins/macaly-code/.cursor-plugin/plugin.json @@ -23,5 +23,5 @@ "rules": "./rules/", "commands": "./commands/", "mcpServers": "./.mcp.universal.json", - "logo": "./assets/logo.svg" + "logo": "./assets/logo.png" } diff --git a/plugins/macaly-code/assets/logo.png b/plugins/macaly-code/assets/logo.png new file mode 100644 index 0000000..17d0d14 Binary files /dev/null and b/plugins/macaly-code/assets/logo.png differ diff --git a/plugins/macaly-code/assets/logo.svg b/plugins/macaly-code/assets/logo.svg deleted file mode 100644 index 143edbc..0000000 --- a/plugins/macaly-code/assets/logo.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/plugins/macaly-code/rules/route-app-builds-to-macaly.mdc b/plugins/macaly-code/rules/route-app-builds-to-macaly.md similarity index 100% rename from plugins/macaly-code/rules/route-app-builds-to-macaly.mdc rename to plugins/macaly-code/rules/route-app-builds-to-macaly.md diff --git a/schemas/marketplace.schema.json b/schemas/marketplace.schema.json deleted file mode 100644 index 70eba0f..0000000 --- a/schemas/marketplace.schema.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://cursor.com/schemas/cursor-plugin/marketplace.json", - "title": "Cursor Plugin Marketplace", - "description": "Schema for .cursor-plugin/marketplace.json — defines a marketplace that indexes one or more Cursor plugins.", - "type": "object", - "required": ["name", "plugins"], - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "minLength": 1, - "description": "Unique identifier for the marketplace." - }, - "owner": { - "$ref": "#/$defs/owner", - "description": "The marketplace owner or organisation." - }, - "metadata": { - "type": "object", - "additionalProperties": true, - "properties": { - "description": { - "type": "string", - "description": "Short description of the marketplace." - } - }, - "description": "Arbitrary metadata about the marketplace." - }, - "plugins": { - "type": "array", - "items": { "$ref": "#/$defs/pluginEntry" }, - "description": "List of plugins available in the marketplace." - } - }, - "$defs": { - "owner": { - "type": "object", - "required": ["name"], - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "minLength": 1, - "description": "Owner or organisation name." - }, - "email": { - "type": "string", - "format": "email", - "description": "Contact email address." - } - } - }, - "pluginEntry": { - "type": "object", - "required": ["name", "source"], - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "minLength": 1, - "pattern": "^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$", - "description": "Plugin identifier matching the plugin's name in its plugin.json." - }, - "source": { - "type": "string", - "minLength": 1, - "description": "Path to the plugin directory (relative to the marketplace root) or a remote URL." - }, - "description": { - "type": "string", - "description": "Short description of the plugin." - } - } - } - } -} diff --git a/schemas/plugin.schema.json b/schemas/plugin.schema.json deleted file mode 100644 index a88db49..0000000 --- a/schemas/plugin.schema.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://cursor.com/schemas/cursor-plugin/plugin.json", - "title": "Cursor Plugin Manifest", - "description": "Schema for .cursor-plugin/plugin.json — defines a single Cursor plugin's metadata, components, and configuration.", - "type": "object", - "required": ["name"], - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "minLength": 1, - "pattern": "^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$", - "description": "Unique plugin identifier in kebab-case (lowercase alphanumeric with hyphens and periods)." - }, - "displayName": { - "type": "string", - "description": "Human-readable display name for the plugin." - }, - "description": { - "type": "string", - "description": "Short description of what the plugin does." - }, - "version": { - "type": "string", - "description": "Semantic version of the plugin (e.g. \"1.2.3\")." - }, - "author": { - "$ref": "#/$defs/author", - "description": "The plugin author." - }, - "publisher": { - "type": "string", - "minLength": 1, - "description": "Publisher or organisation name." - }, - "homepage": { - "type": "string", - "format": "uri", - "description": "URL to the plugin's homepage." - }, - "repository": { - "type": "string", - "format": "uri", - "description": "URL to the plugin's source code repository." - }, - "license": { - "type": "string", - "description": "SPDX license identifier (e.g. \"MIT\", \"Apache-2.0\")." - }, - "logo": { - "type": "string", - "description": "Path to a logo image (relative to the plugin root) or an absolute URL." - }, - "keywords": { - "type": "array", - "items": { "type": "string" }, - "description": "Keywords for discovery and search." - }, - "category": { - "type": "string", - "description": "Plugin category for marketplace classification." - }, - "tags": { - "type": "array", - "items": { "type": "string" }, - "description": "Tags for filtering and discovery." - }, - "commands": { - "$ref": "#/$defs/stringOrStringArray", - "description": "Glob pattern(s) or path(s) to command files." - }, - "agents": { - "$ref": "#/$defs/stringOrStringArray", - "description": "Glob pattern(s) or path(s) to agent definition files." - }, - "skills": { - "$ref": "#/$defs/stringOrStringArray", - "description": "Glob pattern(s) or path(s) to skill files." - }, - "rules": { - "$ref": "#/$defs/stringOrStringArray", - "description": "Glob pattern(s) or path(s) to rule files." - }, - "hooks": { - "oneOf": [{ "type": "string" }, { "type": "object" }], - "description": "Path to a hooks configuration file, or an inline hooks object." - }, - "mcpServers": { - "$ref": "#/$defs/mcpServers", - "description": "MCP server configuration — a path, an inline config object, or an array of either." - } - }, - "$defs": { - "author": { - "type": "object", - "required": ["name"], - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "minLength": 1, - "description": "Author name." - }, - "email": { - "type": "string", - "format": "email", - "description": "Author email address." - } - } - }, - "stringOrStringArray": { - "oneOf": [ - { "type": "string" }, - { - "type": "array", - "items": { "type": "string" } - } - ] - }, - "mcpServers": { - "oneOf": [ - { "type": "string" }, - { "type": "object" }, - { - "type": "array", - "items": { - "oneOf": [{ "type": "string" }, { "type": "object" }] - } - } - ] - } - } -} diff --git a/scripts/validate-codex.mjs b/scripts/validate-codex.mjs deleted file mode 100644 index fb5586c..0000000 --- a/scripts/validate-codex.mjs +++ /dev/null @@ -1,433 +0,0 @@ -#!/usr/bin/env node - -/** - * Codex plugin validator — ported from codex-rs/core/src/plugins/marketplace.rs - * and codex-rs/core/src/plugins/manifest.rs - */ - -import { readFileSync, existsSync, readdirSync, statSync } from "fs"; -import { resolve, dirname, basename, relative } from "path"; -import { fileURLToPath } from "url"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); -const root = resolve(__dirname, ".."); - -let errors = 0; -let warnings = 0; - -function fail(message) { - console.error(`ERROR: ${message}`); - errors++; -} - -function warn(message) { - console.warn(`WARN: ${message}`); - warnings++; -} - -function loadJSON(path, context) { - let raw; - try { - raw = readFileSync(path, "utf-8"); - } catch { - fail(`${context}: file not found at ${relative(root, path)}`); - return null; - } - try { - return JSON.parse(raw); - } catch (err) { - fail(`${context}: invalid JSON — ${err.message}`); - return null; - } -} - -// --- Path validation (mirrors resolve_manifest_path / resolve_plugin_source_path) --- - -function isValidRelativePath(path) { - if (typeof path !== "string" || path.length === 0) return false; - const stripped = path.startsWith("./") ? path.slice(2) : null; - if (stripped === null) return false; - if (stripped.length === 0) return false; - // Must not contain .. or other non-normal components - const segments = stripped.replace(/\/+$/, "").split("/"); - return segments.every((s) => s.length > 0 && s !== ".." && s !== "."); -} - -// --- Marketplace validation (mirrors marketplace.rs) --- - -function validateMarketplace() { - const marketplacePath = resolve( - root, - ".agents", - "plugins", - "marketplace.json" - ); - const marketplace = loadJSON(marketplacePath, "Marketplace"); - if (!marketplace) return; - - if (typeof marketplace.name !== "string" || marketplace.name.length === 0) { - fail("Marketplace: missing or empty `name`"); - } - - if (!Array.isArray(marketplace.plugins)) { - fail("Marketplace: `plugins` must be an array"); - return; - } - - for (const [index, plugin] of marketplace.plugins.entries()) { - const label = `Marketplace plugins[${index}]`; - - if (typeof plugin.name !== "string" || plugin.name.length === 0) { - fail(`${label}: missing or empty \`name\``); - continue; - } - - const pluginLabel = `Marketplace plugin "${plugin.name}"`; - - // Validate source - if (!plugin.source || typeof plugin.source !== "object") { - fail(`${pluginLabel}: \`source\` must be an object`); - continue; - } - - if (plugin.source.source !== "local") { - fail( - `${pluginLabel}: \`source.source\` must be "local", got "${plugin.source.source}"` - ); - continue; - } - - const sourcePath = plugin.source.path; - if (!isValidRelativePath(sourcePath)) { - fail( - `${pluginLabel}: \`source.path\` must be a relative path starting with "./" — got "${sourcePath}"` - ); - continue; - } - - // Resolve relative to marketplace root (2 levels up from .agents/plugins/marketplace.json) - const pluginDir = resolve(root, sourcePath.slice(2)); - - if (!existsSync(pluginDir) || !statSync(pluginDir).isDirectory()) { - fail(`${pluginLabel}: source directory does not exist — ${sourcePath}`); - continue; - } - - // Validate policy - const validInstallPolicies = [ - "NOT_AVAILABLE", - "AVAILABLE", - "INSTALLED_BY_DEFAULT", - ]; - const validAuthPolicies = ["ON_INSTALL", "ON_USE"]; - - if (plugin.policy) { - if ( - plugin.policy.installation && - !validInstallPolicies.includes(plugin.policy.installation) - ) { - fail( - `${pluginLabel}: invalid policy.installation "${plugin.policy.installation}"` - ); - } - if ( - plugin.policy.authentication && - !validAuthPolicies.includes(plugin.policy.authentication) - ) { - fail( - `${pluginLabel}: invalid policy.authentication "${plugin.policy.authentication}"` - ); - } - } - - // Validate plugin manifest - validatePluginManifest(pluginDir, plugin.name); - } -} - -// --- Plugin manifest validation (mirrors manifest.rs) --- - -const MAX_SKILL_NAME_LENGTH = 64; -const MAX_FINAL_SHORT_DESCRIPTION_LENGTH = 30; -const MAX_FINAL_URL_LENGTH = 1024; -const MAX_DEFAULT_PROMPT_COUNT = 3; -const MAX_DEFAULT_PROMPT_LENGTH = 128; -const REQUIRED_MCP_INTERFACE_URLS = [ - "websiteURL", - "supportURL", - "privacyPolicyURL", - "termsOfServiceURL", -]; -const FINAL_DIRECTORY_CATEGORIES = new Set([ - "Productivity", - "Creativity", - "Developer Tools", - "Business & Operations", - "Data & Analytics", - "Communication", - "Education & Research", - "Security", - "Finance", - "Healthcare", - "Travel", - "Entertainment", - "Other", -]); - -function validatePluginManifest(pluginDir, marketplaceName) { - const manifestPath = resolve(pluginDir, ".codex-plugin", "plugin.json"); - const label = `Plugin "${marketplaceName}"`; - const manifest = loadJSON(manifestPath, `${label} manifest`); - if (!manifest) return; - - // Name validation - if (typeof manifest.name === "string" && manifest.name.length > 0) { - if (manifest.name !== marketplaceName) { - fail( - `${label}: marketplace name does not match plugin.json name "${manifest.name}"` - ); - } - } - - // Validate manifest paths (skills, mcpServers, apps) - for (const field of ["skills", "mcpServers", "apps"]) { - const value = manifest[field]; - if (value === undefined || value === null) continue; - if (typeof value !== "string") { - fail(`${label}: \`${field}\` must be a string path`); - continue; - } - if (!isValidRelativePath(value)) { - fail( - `${label}: \`${field}\` must be a relative path starting with "./" — got "${value}"` - ); - continue; - } - const resolved = resolve(pluginDir, value.slice(2)); - if (!existsSync(resolved)) { - fail(`${label}: \`${field}\` references missing path "${value}"`); - } - } - - // Validate interface - if (manifest.interface) { - validatePluginInterface( - pluginDir, - label, - manifest.interface, - Boolean(manifest.mcpServers) - ); - } - - // Validate skills - validateSkills(pluginDir, label, manifest.skills); -} - -function validatePluginInterface(pluginDir, label, iface, hasMcpServers) { - if ( - typeof iface.shortDescription !== "string" || - iface.shortDescription.trim().length === 0 - ) { - fail(`${label}: interface.shortDescription must be a non-empty string`); - } else if (iface.shortDescription.length > MAX_FINAL_SHORT_DESCRIPTION_LENGTH) { - fail( - `${label}: interface.shortDescription exceeds the ${MAX_FINAL_SHORT_DESCRIPTION_LENGTH}-character final directory limit` - ); - } - - if (!FINAL_DIRECTORY_CATEGORIES.has(iface.category)) { - fail( - `${label}: interface.category must be a supported final directory category` - ); - } - - if (hasMcpServers) { - for (const field of REQUIRED_MCP_INTERFACE_URLS) { - const value = iface[field]; - if (typeof value !== "string" || value.length === 0) { - fail(`${label}: interface.${field} is required for MCP submissions`); - continue; - } - if (value.length > MAX_FINAL_URL_LENGTH) { - fail( - `${label}: interface.${field} exceeds the ${MAX_FINAL_URL_LENGTH}-character final directory limit` - ); - continue; - } - try { - const url = new URL(value); - if (url.protocol !== "https:" || !url.hostname) { - fail(`${label}: interface.${field} must be a public HTTPS URL`); - } - } catch { - fail(`${label}: interface.${field} must be a valid HTTPS URL`); - } - } - } - - // Validate asset paths - for (const field of ["composerIcon", "logo"]) { - const value = iface[field]; - if (!value) continue; - if (!isValidRelativePath(value)) { - fail( - `${label}: interface.${field} must be a relative path starting with "./" — got "${value}"` - ); - continue; - } - const resolved = resolve(pluginDir, value.slice(2)); - if (!existsSync(resolved)) { - fail(`${label}: interface.${field} references missing path "${value}"`); - } - } - - // Validate screenshots - if (Array.isArray(iface.screenshots)) { - for (const [i, screenshot] of iface.screenshots.entries()) { - if (!isValidRelativePath(screenshot)) { - fail( - `${label}: interface.screenshots[${i}] must be a relative path starting with "./"` - ); - continue; - } - const resolved = resolve(pluginDir, screenshot.slice(2)); - if (!existsSync(resolved)) { - fail( - `${label}: interface.screenshots[${i}] references missing path "${screenshot}"` - ); - } - } - } - - // Validate defaultPrompt - if (iface.defaultPrompt !== undefined) { - const prompts = Array.isArray(iface.defaultPrompt) - ? iface.defaultPrompt - : typeof iface.defaultPrompt === "string" - ? [iface.defaultPrompt] - : null; - - if (prompts === null) { - fail( - `${label}: interface.defaultPrompt must be a string or array of strings` - ); - } else { - if (prompts.length > MAX_DEFAULT_PROMPT_COUNT) { - warn( - `${label}: interface.defaultPrompt has ${prompts.length} entries, maximum is ${MAX_DEFAULT_PROMPT_COUNT}` - ); - } - for (const [i, prompt] of prompts.entries()) { - if (typeof prompt !== "string") { - fail( - `${label}: interface.defaultPrompt[${i}] must be a string` - ); - continue; - } - const normalized = prompt.split(/\s+/).join(" ").trim(); - if (normalized.length > MAX_DEFAULT_PROMPT_LENGTH) { - warn( - `${label}: interface.defaultPrompt[${i}] exceeds ${MAX_DEFAULT_PROMPT_LENGTH} characters` - ); - } - } - } - } -} - -// --- Skill validation (mirrors quick_validate.py) --- - -function validateSkills(pluginDir, label, skillsPath) { - const skillsDir = skillsPath - ? resolve(pluginDir, skillsPath.replace(/^\.\//, "")) - : resolve(pluginDir, "skills"); - - if (!existsSync(skillsDir) || !statSync(skillsDir).isDirectory()) return; - - for (const entry of readdirSync(skillsDir, { withFileTypes: true })) { - if (!entry.isDirectory()) continue; - const skillMdPath = resolve(skillsDir, entry.name, "SKILL.md"); - if (!existsSync(skillMdPath)) { - warn(`${label}: skill "${entry.name}" is missing SKILL.md`); - continue; - } - - const content = readFileSync(skillMdPath, "utf-8").replace(/\r\n/g, "\n"); - if (!content.startsWith("---\n")) { - fail( - `${label}: skill "${entry.name}" SKILL.md missing YAML frontmatter` - ); - continue; - } - - const closingIndex = content.indexOf("\n---\n", 4); - if (closingIndex === -1) { - fail( - `${label}: skill "${entry.name}" SKILL.md has unclosed frontmatter` - ); - continue; - } - - const frontmatter = parseFrontmatter(content.slice(4, closingIndex)); - const skillLabel = `${label} skill "${entry.name}"`; - - if (!frontmatter.name) { - fail(`${skillLabel}: missing "name" in frontmatter`); - } else { - const name = frontmatter.name.trim(); - if (!/^[a-z0-9-]+$/.test(name)) { - fail( - `${skillLabel}: name "${name}" must be hyphen-case (lowercase letters, digits, hyphens)` - ); - } else if (name.startsWith("-") || name.endsWith("-") || name.includes("--")) { - fail( - `${skillLabel}: name "${name}" cannot start/end with hyphen or contain consecutive hyphens` - ); - } - if (name.length > MAX_SKILL_NAME_LENGTH) { - fail( - `${skillLabel}: name exceeds ${MAX_SKILL_NAME_LENGTH} characters` - ); - } - } - - if (!frontmatter.description) { - fail(`${skillLabel}: missing "description" in frontmatter`); - } else { - const desc = frontmatter.description.trim(); - if (/<|>/.test(desc)) { - fail(`${skillLabel}: description cannot contain angle brackets`); - } - if (desc.length > 1024) { - fail(`${skillLabel}: description exceeds 1024 characters`); - } - } - } -} - -function parseFrontmatter(block) { - const fields = {}; - for (const line of block.split("\n")) { - const trimmed = line.trim(); - if (!trimmed || trimmed.startsWith("#")) continue; - const sep = line.indexOf(":"); - if (sep === -1) continue; - fields[line.slice(0, sep).trim()] = line.slice(sep + 1).trim(); - } - return fields; -} - -// --- Main --- - -validateMarketplace(); - -if (errors > 0) { - console.error(`\nCodex validation failed with ${errors} error(s).`); - process.exit(1); -} else { - if (warnings > 0) { - console.log(`Codex validation passed with ${warnings} warning(s).`); - } else { - console.log("Codex validation passed."); - } -} diff --git a/scripts/validate-cursor-schema.mjs b/scripts/validate-cursor-schema.mjs deleted file mode 100644 index 6a78708..0000000 --- a/scripts/validate-cursor-schema.mjs +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env node - -import { readFileSync, existsSync } from "fs"; -import { resolve, dirname } from "path"; -import { fileURLToPath } from "url"; -import Ajv from "ajv"; -import addFormats from "ajv-formats"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); -const root = resolve(__dirname, ".."); - -function loadJSON(path) { - return JSON.parse(readFileSync(path, "utf-8")); -} - -const marketplaceSchema = loadJSON( - resolve(root, "schemas/marketplace.schema.json") -); -const pluginSchema = loadJSON(resolve(root, "schemas/plugin.schema.json")); - -const ajv = new Ajv({ allErrors: true }); -addFormats(ajv); - -const validateMarketplace = ajv.compile(marketplaceSchema); -const validatePlugin = ajv.compile(pluginSchema); - -let errors = 0; - -function fail(message) { - console.error(`ERROR: ${message}`); - errors++; -} - -// 1. Validate marketplace.json -const marketplacePath = resolve(root, ".cursor-plugin/marketplace.json"); - -if (!existsSync(marketplacePath)) { - fail(".cursor-plugin/marketplace.json not found"); - process.exit(1); -} - -const marketplace = loadJSON(marketplacePath); - -if (!validateMarketplace(marketplace)) { - fail("marketplace.json schema validation failed:"); - for (const err of validateMarketplace.errors) { - console.error(` ${err.instancePath || "/"}: ${err.message}`); - } -} - -// 2. Validate each plugin -for (const entry of marketplace.plugins ?? []) { - const pluginDir = resolve(root, entry.source); - const pluginJsonPath = resolve(pluginDir, ".cursor-plugin/plugin.json"); - - // Check source directory exists - if (!existsSync(pluginDir)) { - fail( - `Plugin "${entry.name}": source directory "${entry.source}" does not exist` - ); - continue; - } - - // Check plugin.json exists - if (!existsSync(pluginJsonPath)) { - fail( - `Plugin "${entry.name}": missing .cursor-plugin/plugin.json in "${entry.source}"` - ); - continue; - } - - const pluginJson = loadJSON(pluginJsonPath); - - if (!validatePlugin(pluginJson)) { - fail( - `Plugin "${entry.name}": plugin.json schema validation failed (${entry.source}/.cursor-plugin/plugin.json):` - ); - for (const err of validatePlugin.errors) { - const detail = - err.keyword === "additionalProperties" - ? `${err.message}: "${err.params.additionalProperty}"` - : err.message; - console.error(` ${err.instancePath || "/"}: ${detail}`); - } - } - - // Check that marketplace name matches plugin name - if (pluginJson.name && pluginJson.name !== entry.name) { - fail( - `Plugin "${entry.name}": marketplace name does not match plugin.json name "${pluginJson.name}"` - ); - } -} - -// 3. Report results -if (errors > 0) { - console.error(`\nValidation failed with ${errors} error(s).`); - process.exit(1); -} else { - console.log("All plugins validated successfully."); - process.exit(0); -} diff --git a/scripts/validate-cursor-structure.mjs b/scripts/validate-cursor-structure.mjs deleted file mode 100644 index 0f1effa..0000000 --- a/scripts/validate-cursor-structure.mjs +++ /dev/null @@ -1,381 +0,0 @@ -#!/usr/bin/env node - -import { promises as fs } from "node:fs"; -import path from "node:path"; -import process from "node:process"; - -const repoRoot = process.cwd(); -const errors = []; -const warnings = []; - -const pluginNamePattern = /^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/; -const marketplaceNamePattern = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/; - -function addError(message) { - errors.push(message); -} - -function addWarning(message) { - warnings.push(message); -} - -async function pathExists(targetPath) { - try { - await fs.access(targetPath); - return true; - } catch { - return false; - } -} - -async function ensureDirectory(targetPath, context) { - try { - const stat = await fs.stat(targetPath); - if (!stat.isDirectory()) { - addError(`${context} exists but is not a directory: ${targetPath}`); - return false; - } - return true; - } catch { - addError(`${context} directory is missing: ${targetPath}`); - return false; - } -} - -async function readJsonFile(filePath, context) { - let raw; - try { - raw = await fs.readFile(filePath, "utf8"); - } catch { - addError(`${context} is missing: ${filePath}`); - return null; - } - - try { - return JSON.parse(raw); - } catch (error) { - addError(`${context} contains invalid JSON (${filePath}): ${error.message}`); - return null; - } -} - -function normalizeNewlines(content) { - return content.replace(/\r\n/g, "\n"); -} - -function parseFrontmatter(content) { - const normalized = normalizeNewlines(content); - if (!normalized.startsWith("---\n")) { - return null; - } - - const closingIndex = normalized.indexOf("\n---\n", 4); - if (closingIndex === -1) { - return null; - } - - const frontmatterBlock = normalized.slice(4, closingIndex); - const fields = {}; - - for (const line of frontmatterBlock.split("\n")) { - const trimmed = line.trim(); - if (!trimmed || trimmed.startsWith("#")) { - continue; - } - const separator = line.indexOf(":"); - if (separator === -1) { - continue; - } - const key = line.slice(0, separator).trim(); - const value = line.slice(separator + 1).trim(); - fields[key] = value; - } - - return fields; -} - -async function walkFiles(dirPath) { - const files = []; - const stack = [dirPath]; - - while (stack.length > 0) { - const current = stack.pop(); - const entries = await fs.readdir(current, { withFileTypes: true }); - for (const entry of entries) { - const entryPath = path.join(current, entry.name); - if (entry.isDirectory()) { - stack.push(entryPath); - } else if (entry.isFile()) { - files.push(entryPath); - } - } - } - - return files; -} - -function isSafeRelativePath(value) { - if (typeof value !== "string" || value.length === 0) { - return false; - } - if (value.startsWith("http://") || value.startsWith("https://")) { - return true; - } - if (path.isAbsolute(value)) { - return false; - } - const normalized = path.posix.normalize(value.replace(/\\/g, "/")); - return !normalized.startsWith("../") && normalized !== ".."; -} - -function extractPathValues(value) { - if (typeof value === "string") { - return [value]; - } - - if (Array.isArray(value)) { - return value.flatMap((entry) => extractPathValues(entry)); - } - - if (value && typeof value === "object") { - const candidates = []; - if (typeof value.path === "string") { - candidates.push(value.path); - } - if (typeof value.file === "string") { - candidates.push(value.file); - } - return candidates; - } - - return []; -} - -async function validateReferencedPath(pluginDir, fieldName, pathValue, pluginName) { - if (pathValue.startsWith("http://") || pathValue.startsWith("https://")) { - return; - } - - if (!isSafeRelativePath(pathValue)) { - addError( - `${pluginName}: field "${fieldName}" has invalid path "${pathValue}". Use a relative path without ".." or absolute prefixes.` - ); - return; - } - - const resolved = path.resolve(pluginDir, pathValue); - const exists = await pathExists(resolved); - if (!exists) { - addError(`${pluginName}: field "${fieldName}" references missing path "${pathValue}".`); - } -} - -async function validateFrontmatterFile(filePath, componentName, requiredKeys, pluginName) { - const content = await fs.readFile(filePath, "utf8"); - const parsed = parseFrontmatter(content); - const relativeFile = path.relative(repoRoot, filePath); - - if (!parsed) { - addError(`${pluginName}: ${componentName} file missing YAML frontmatter: ${relativeFile}`); - return; - } - - for (const key of requiredKeys) { - if (!parsed[key] || parsed[key].length === 0) { - addError(`${pluginName}: ${componentName} file missing "${key}" in frontmatter: ${relativeFile}`); - } - } -} - -async function validateComponentFrontmatter(pluginDir, pluginName) { - const rulesDir = path.join(pluginDir, "rules"); - if (await pathExists(rulesDir)) { - const files = await walkFiles(rulesDir); - for (const file of files) { - const ext = path.extname(file).toLowerCase(); - if (ext === ".md" || ext === ".mdc" || ext === ".markdown") { - await validateFrontmatterFile(file, "rule", ["description"], pluginName); - } - } - } - - const skillsDir = path.join(pluginDir, "skills"); - if (await pathExists(skillsDir)) { - const files = await walkFiles(skillsDir); - for (const file of files) { - if (path.basename(file) === "SKILL.md") { - await validateFrontmatterFile(file, "skill", ["name", "description"], pluginName); - } - } - } - - const agentsDir = path.join(pluginDir, "agents"); - if (await pathExists(agentsDir)) { - const files = await walkFiles(agentsDir); - for (const file of files) { - const ext = path.extname(file).toLowerCase(); - if (ext === ".md" || ext === ".mdc" || ext === ".markdown") { - await validateFrontmatterFile(file, "agent", ["name", "description"], pluginName); - } - } - } - - const commandsDir = path.join(pluginDir, "commands"); - if (await pathExists(commandsDir)) { - const files = await walkFiles(commandsDir); - for (const file of files) { - const ext = path.extname(file).toLowerCase(); - if (ext === ".md" || ext === ".mdc" || ext === ".markdown" || ext === ".txt") { - await validateFrontmatterFile(file, "command", ["name", "description"], pluginName); - } - } - } -} - -function resolveMarketplaceSource(source, pluginRoot) { - if (typeof source !== "string" || source.length === 0) { - return null; - } - if (!pluginRoot) { - return source; - } - const normalizedRoot = pluginRoot.replace(/\\/g, "/").replace(/\/+$/, ""); - const normalizedSource = source.replace(/\\/g, "/"); - if (normalizedSource === normalizedRoot || normalizedSource.startsWith(`${normalizedRoot}/`)) { - return normalizedSource; - } - return `${normalizedRoot}/${normalizedSource}`; -} - -async function main() { - const marketplacePath = path.join(repoRoot, ".cursor-plugin", "marketplace.json"); - const marketplace = await readJsonFile(marketplacePath, "Marketplace manifest"); - if (!marketplace) { - summarizeAndExit(); - return; - } - - if (typeof marketplace.name !== "string" || !marketplaceNamePattern.test(marketplace.name)) { - addError( - 'Marketplace "name" must be lowercase kebab-case and start/end with an alphanumeric character.' - ); - } - - if (!marketplace.owner || typeof marketplace.owner.name !== "string" || marketplace.owner.name.length === 0) { - addError('Marketplace "owner.name" is required.'); - } - - if (!Array.isArray(marketplace.plugins) || marketplace.plugins.length === 0) { - addError('Marketplace "plugins" must be a non-empty array.'); - summarizeAndExit(); - return; - } - - const pluginRoot = marketplace.metadata?.pluginRoot; - if (pluginRoot !== undefined) { - if (typeof pluginRoot !== "string" || !isSafeRelativePath(pluginRoot)) { - addError('Marketplace "metadata.pluginRoot" must be a safe relative path.'); - } else { - const pluginRootAbs = path.join(repoRoot, pluginRoot); - await ensureDirectory(pluginRootAbs, 'Marketplace "metadata.pluginRoot"'); - } - } - - const seenNames = new Set(); - for (const [index, entry] of marketplace.plugins.entries()) { - const label = `plugins[${index}]`; - - if (!entry || typeof entry !== "object") { - addError(`${label} must be an object.`); - continue; - } - - if (typeof entry.name !== "string" || !pluginNamePattern.test(entry.name)) { - addError(`${label}.name must be lowercase and use only alphanumerics, hyphens, and periods.`); - continue; - } - - if (seenNames.has(entry.name)) { - addError(`Duplicate plugin name in marketplace manifest: "${entry.name}"`); - } - seenNames.add(entry.name); - - const sourcePath = resolveMarketplaceSource(entry.source, pluginRoot ?? ""); - if (!sourcePath) { - addError(`${label}.source must be a string path.`); - continue; - } - if (!isSafeRelativePath(sourcePath)) { - addError(`${label}.source is not a safe relative path: "${sourcePath}"`); - continue; - } - - const pluginDir = path.join(repoRoot, sourcePath); - const pluginDirExists = await ensureDirectory(pluginDir, `${label}.source`); - if (!pluginDirExists) { - continue; - } - - const manifestPath = path.join(pluginDir, ".cursor-plugin", "plugin.json"); - const pluginManifest = await readJsonFile(manifestPath, `${entry.name} plugin manifest`); - if (!pluginManifest) { - continue; - } - - if (typeof pluginManifest.name !== "string" || !pluginNamePattern.test(pluginManifest.name)) { - addError( - `${entry.name}: "name" in plugin.json must be lowercase and use only alphanumerics, hyphens, and periods.` - ); - } - - if (pluginManifest.name && pluginManifest.name !== entry.name) { - addError( - `${entry.name}: marketplace entry name does not match plugin.json name ("${pluginManifest.name}").` - ); - } - - const manifestFields = ["logo", "rules", "skills", "agents", "commands", "hooks", "mcpServers"]; - for (const field of manifestFields) { - const values = extractPathValues(pluginManifest[field]); - for (const value of values) { - await validateReferencedPath(pluginDir, field, value, entry.name); - } - } - - await validateComponentFrontmatter(pluginDir, entry.name); - - const hooksPath = path.join(pluginDir, "hooks", "hooks.json"); - if (!(await pathExists(hooksPath))) { - addWarning(`${entry.name}: no hooks/hooks.json file found (only needed when using hooks).`); - } - - const mcpPath = path.join(pluginDir, ".mcp.json"); - if (pluginManifest.mcpServers === undefined && !(await pathExists(mcpPath))) { - addWarning(`${entry.name}: no .mcp.json file found (only needed when using MCP servers).`); - } - } - - summarizeAndExit(); -} - -function summarizeAndExit() { - if (warnings.length > 0) { - console.log("Warnings:"); - for (const warning of warnings) { - console.log(`- ${warning}`); - } - console.log(""); - } - - if (errors.length > 0) { - console.error("Validation failed:"); - for (const error of errors) { - console.error(`- ${error}`); - } - process.exit(1); - } - - console.log("Validation passed."); -} - -await main();