opencastle 1.1.1 → 1.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 +26 -9
- package/bin/cli.mjs +6 -0
- package/dist/cli/adapters/antigravity.d.ts +0 -1
- package/dist/cli/adapters/antigravity.d.ts.map +1 -1
- package/dist/cli/adapters/antigravity.js +2 -1
- package/dist/cli/adapters/antigravity.js.map +1 -1
- package/dist/cli/adapters/claude-code.d.ts +0 -1
- package/dist/cli/adapters/claude-code.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.js +0 -1
- package/dist/cli/adapters/claude-code.js.map +1 -1
- package/dist/cli/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/adapters/cursor.js +8 -1
- package/dist/cli/adapters/cursor.js.map +1 -1
- package/dist/cli/adapters/opencode.d.ts +12 -5
- package/dist/cli/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/adapters/opencode.js +17 -5
- package/dist/cli/adapters/opencode.js.map +1 -1
- package/dist/cli/adapters/rules-dir-base.d.ts +12 -1
- package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +43 -57
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/rules-dir-base.test.js +27 -18
- package/dist/cli/adapters/rules-dir-base.test.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +11 -0
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +44 -14
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts +2 -1
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +2 -1
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/adapters/windsurf.d.ts.map +1 -1
- package/dist/cli/adapters/windsurf.js +11 -1
- package/dist/cli/adapters/windsurf.js.map +1 -1
- package/dist/cli/agent-plugin.d.ts +119 -0
- package/dist/cli/agent-plugin.d.ts.map +1 -0
- package/dist/cli/agent-plugin.js +449 -0
- package/dist/cli/agent-plugin.js.map +1 -0
- package/dist/cli/agent-plugin.test.d.ts +2 -0
- package/dist/cli/agent-plugin.test.d.ts.map +1 -0
- package/dist/cli/agent-plugin.test.js +227 -0
- package/dist/cli/agent-plugin.test.js.map +1 -0
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +114 -34
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/ci.d.ts.map +1 -1
- package/dist/cli/ci.js +18 -4
- package/dist/cli/ci.js.map +1 -1
- package/dist/cli/codex-target.test.js +14 -1
- package/dist/cli/codex-target.test.js.map +1 -1
- package/dist/cli/convoy/gates.d.ts +2 -20
- package/dist/cli/convoy/gates.d.ts.map +1 -1
- package/dist/cli/convoy/gates.js +3 -111
- package/dist/cli/convoy/gates.js.map +1 -1
- package/dist/cli/copy.d.ts +0 -8
- package/dist/cli/copy.d.ts.map +1 -1
- package/dist/cli/copy.js +0 -21
- package/dist/cli/copy.js.map +1 -1
- package/dist/cli/dispatcher.test.js +2 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +2 -0
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +2 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/doctor.test.js +2 -2
- package/dist/cli/doctor.test.js.map +1 -1
- package/dist/cli/explain.d.ts +5 -0
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js +38 -2
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/init.test.js +78 -42
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts +8 -0
- package/dist/cli/layers.d.ts.map +1 -1
- package/dist/cli/layers.js +130 -13
- package/dist/cli/layers.js.map +1 -1
- package/dist/cli/layers.test.js +2 -2
- package/dist/cli/layers.test.js.map +1 -1
- package/dist/cli/legacy-install.test.js +8 -1
- package/dist/cli/legacy-install.test.js.map +1 -1
- package/dist/cli/lesson-command.test.d.ts +2 -0
- package/dist/cli/lesson-command.test.d.ts.map +1 -0
- package/dist/cli/lesson-command.test.js +100 -0
- package/dist/cli/lesson-command.test.js.map +1 -0
- package/dist/cli/lesson.d.ts +0 -9
- package/dist/cli/lesson.d.ts.map +1 -1
- package/dist/cli/lesson.js +212 -276
- package/dist/cli/lesson.js.map +1 -1
- package/dist/cli/lessons.d.ts +134 -0
- package/dist/cli/lessons.d.ts.map +1 -0
- package/dist/cli/lessons.js +493 -0
- package/dist/cli/lessons.js.map +1 -0
- package/dist/cli/lessons.test.d.ts +2 -0
- package/dist/cli/lessons.test.d.ts.map +1 -0
- package/dist/cli/lessons.test.js +214 -0
- package/dist/cli/lessons.test.js.map +1 -0
- package/dist/cli/managed-paths.d.ts.map +1 -1
- package/dist/cli/managed-paths.js +3 -1
- package/dist/cli/managed-paths.js.map +1 -1
- package/dist/cli/mcp-audit.d.ts.map +1 -1
- package/dist/cli/mcp-audit.js +2 -0
- package/dist/cli/mcp-audit.js.map +1 -1
- package/dist/cli/mcp-upgrade.test.js +24 -1
- package/dist/cli/mcp-upgrade.test.js.map +1 -1
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +22 -3
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/pack-plugins.d.ts +8 -0
- package/dist/cli/pack-plugins.d.ts.map +1 -0
- package/dist/cli/pack-plugins.js +70 -0
- package/dist/cli/pack-plugins.js.map +1 -0
- package/dist/cli/plugin-command.test.d.ts +2 -0
- package/dist/cli/plugin-command.test.d.ts.map +1 -0
- package/dist/cli/plugin-command.test.js +114 -0
- package/dist/cli/plugin-command.test.js.map +1 -0
- package/dist/cli/plugin.d.ts +30 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +291 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/promote-command.test.d.ts +2 -0
- package/dist/cli/promote-command.test.d.ts.map +1 -0
- package/dist/cli/promote-command.test.js +151 -0
- package/dist/cli/promote-command.test.js.map +1 -0
- package/dist/cli/promote.d.ts +12 -0
- package/dist/cli/promote.d.ts.map +1 -0
- package/dist/cli/promote.js +364 -0
- package/dist/cli/promote.js.map +1 -0
- package/dist/cli/secret-scan.d.ts +21 -0
- package/dist/cli/secret-scan.d.ts.map +1 -0
- package/dist/cli/secret-scan.js +114 -0
- package/dist/cli/secret-scan.js.map +1 -0
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +9 -0
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +5 -4
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/team-commands.test.js +14 -2
- package/dist/cli/team-commands.test.js.map +1 -1
- package/dist/cli/team-sources.test.js +10 -0
- package/dist/cli/team-sources.test.js.map +1 -1
- package/dist/cli/types.d.ts +1 -1
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +18 -0
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/windsurf-target.test.d.ts +2 -0
- package/dist/cli/windsurf-target.test.d.ts.map +1 -0
- package/dist/cli/windsurf-target.test.js +62 -0
- package/dist/cli/windsurf-target.test.js.map +1 -0
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts +2 -0
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js +32 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js.map +1 -0
- package/dist/orchestrator/plugins/registry.test.d.ts +2 -0
- package/dist/orchestrator/plugins/registry.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/registry.test.js +37 -0
- package/dist/orchestrator/plugins/registry.test.js.map +1 -0
- package/package.json +2 -1
- package/src/cli/adapters/antigravity.ts +2 -1
- package/src/cli/adapters/claude-code.ts +0 -1
- package/src/cli/adapters/cursor.ts +8 -1
- package/src/cli/adapters/opencode.ts +18 -6
- package/src/cli/adapters/rules-dir-base.test.ts +28 -18
- package/src/cli/adapters/rules-dir-base.ts +51 -90
- package/src/cli/adapters/single-file-base.ts +53 -14
- package/src/cli/adapters/vscode.ts +2 -1
- package/src/cli/adapters/windsurf.ts +11 -1
- package/src/cli/agent-plugin.test.ts +267 -0
- package/src/cli/agent-plugin.ts +469 -0
- package/src/cli/baseline.ts +115 -32
- package/src/cli/ci.ts +19 -4
- package/src/cli/codex-target.test.ts +15 -1
- package/src/cli/convoy/gates.ts +9 -142
- package/src/cli/copy.ts +0 -25
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +2 -0
- package/src/cli/doctor.test.ts +2 -2
- package/src/cli/doctor.ts +2 -0
- package/src/cli/explain.ts +36 -2
- package/src/cli/fixtures/lessons-template-1.0.md +70 -0
- package/src/cli/init.test.ts +82 -42
- package/src/cli/layers.test.ts +2 -2
- package/src/cli/layers.ts +144 -14
- package/src/cli/legacy-install.test.ts +11 -1
- package/src/cli/lesson-command.test.ts +117 -0
- package/src/cli/lesson.ts +215 -266
- package/src/cli/lessons.test.ts +254 -0
- package/src/cli/lessons.ts +540 -0
- package/src/cli/managed-paths.ts +3 -1
- package/src/cli/mcp-audit.ts +2 -0
- package/src/cli/mcp-upgrade.test.ts +26 -1
- package/src/cli/mcp.ts +22 -3
- package/src/cli/pack-plugins.ts +70 -0
- package/src/cli/plugin-command.test.ts +125 -0
- package/src/cli/plugin.ts +309 -0
- package/src/cli/promote-command.test.ts +170 -0
- package/src/cli/promote.ts +371 -0
- package/src/cli/secret-scan.ts +154 -0
- package/src/cli/sync-check.test.ts +5 -4
- package/src/cli/sync-check.ts +9 -0
- package/src/cli/team-commands.test.ts +18 -2
- package/src/cli/team-sources.test.ts +11 -0
- package/src/cli/types.ts +1 -1
- package/src/cli/update.ts +20 -0
- package/src/cli/windsurf-target.test.ts +70 -0
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/agents/researcher.agent.md +1 -1
- package/src/orchestrator/customizations/LESSONS-LEARNED.md +10 -66
- package/src/orchestrator/customizations/README.md +2 -1
- package/src/orchestrator/customizations/logs/README.md +1 -1
- package/src/orchestrator/plugins/agent-plugins.test.ts +34 -0
- package/src/orchestrator/plugins/astro/mcp.json +9 -0
- package/src/orchestrator/plugins/astro/plugin.json +21 -0
- package/src/orchestrator/plugins/chrome-devtools/mcp.json +13 -0
- package/src/orchestrator/plugins/chrome-devtools/plugin.json +21 -0
- package/src/orchestrator/plugins/cloudflare/mcp.json +9 -0
- package/src/orchestrator/plugins/cloudflare/plugin.json +21 -0
- package/src/orchestrator/plugins/contentful/mcp.json +13 -0
- package/src/orchestrator/plugins/contentful/plugin.json +21 -0
- package/src/orchestrator/plugins/convex/mcp.json +15 -0
- package/src/orchestrator/plugins/convex/plugin.json +21 -0
- package/src/orchestrator/plugins/coolify/mcp.json +13 -0
- package/src/orchestrator/plugins/coolify/plugin.json +25 -0
- package/src/orchestrator/plugins/cypress/plugin.json +21 -0
- package/src/orchestrator/plugins/drizzle/plugin.json +21 -0
- package/src/orchestrator/plugins/expo/mcp.json +9 -0
- package/src/orchestrator/plugins/expo/plugin.json +21 -0
- package/src/orchestrator/plugins/figma/mcp.json +9 -0
- package/src/orchestrator/plugins/figma/plugin.json +21 -0
- package/src/orchestrator/plugins/hetzner/plugin.json +24 -0
- package/src/orchestrator/plugins/jira/mcp.json +9 -0
- package/src/orchestrator/plugins/jira/plugin.json +21 -0
- package/src/orchestrator/plugins/linear/mcp.json +9 -0
- package/src/orchestrator/plugins/linear/plugin.json +21 -0
- package/src/orchestrator/plugins/netlify/mcp.json +13 -0
- package/src/orchestrator/plugins/netlify/plugin.json +21 -0
- package/src/orchestrator/plugins/nextjs/mcp.json +13 -0
- package/src/orchestrator/plugins/nextjs/plugin.json +21 -0
- package/src/orchestrator/plugins/notion/mcp.json +9 -0
- package/src/orchestrator/plugins/notion/plugin.json +21 -0
- package/src/orchestrator/plugins/nx/mcp.json +14 -0
- package/src/orchestrator/plugins/nx/plugin.json +21 -0
- package/src/orchestrator/plugins/playwright/mcp.json +13 -0
- package/src/orchestrator/plugins/playwright/plugin.json +21 -0
- package/src/orchestrator/plugins/prisma/mcp.json +14 -0
- package/src/orchestrator/plugins/prisma/plugin.json +21 -0
- package/src/orchestrator/plugins/registry.test.ts +42 -0
- package/src/orchestrator/plugins/resend/mcp.json +13 -0
- package/src/orchestrator/plugins/resend/plugin.json +24 -0
- package/src/orchestrator/plugins/sanity/mcp.json +9 -0
- package/src/orchestrator/plugins/sanity/plugin.json +21 -0
- package/src/orchestrator/plugins/sentry/mcp.json +12 -0
- package/src/orchestrator/plugins/sentry/plugin.json +24 -0
- package/src/orchestrator/plugins/slack/mcp.json +13 -0
- package/src/orchestrator/plugins/slack/plugin.json +24 -0
- package/src/orchestrator/plugins/strapi/mcp.json +13 -0
- package/src/orchestrator/plugins/strapi/plugin.json +21 -0
- package/src/orchestrator/plugins/stripe/mcp.json +9 -0
- package/src/orchestrator/plugins/stripe/plugin.json +21 -0
- package/src/orchestrator/plugins/supabase/mcp.json +9 -0
- package/src/orchestrator/plugins/supabase/plugin.json +21 -0
- package/src/orchestrator/plugins/teams/plugin.json +24 -0
- package/src/orchestrator/plugins/trello/mcp.json +13 -0
- package/src/orchestrator/plugins/trello/plugin.json +25 -0
- package/src/orchestrator/plugins/turborepo/plugin.json +21 -0
- package/src/orchestrator/plugins/vercel/mcp.json +9 -0
- package/src/orchestrator/plugins/vercel/plugin.json +21 -0
- package/src/orchestrator/plugins/vitest/plugin.json +21 -0
- package/src/orchestrator/skill-config-links.test.ts +2 -1
- package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +1 -1
- package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
- package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
- package/src/orchestrator/skills/memory-merger/SKILL.md +17 -21
- package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +44 -23
- package/src/orchestrator/skills/self-improvement/SKILL.md +30 -15
- /package/src/orchestrator/plugins/astro/{SKILL.md → skills/astro-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/chrome-devtools/{SKILL.md → skills/browser-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cloudflare/{SKILL.md → skills/cloudflare-platform/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/contentful/{SKILL.md → skills/contentful-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/convex/{SKILL.md → skills/convex-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/coolify/{SKILL.md → skills/coolify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cypress/{SKILL.md → skills/cypress-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/drizzle/{SKILL.md → skills/drizzle-orm/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/expo/{SKILL.md → skills/expo-development/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/figma/{SKILL.md → skills/figma-design/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/hetzner/{SKILL.md → skills/hetzner-cloud/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/jira/{SKILL.md → skills/jira-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/linear/{SKILL.md → skills/linear-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/netlify/{SKILL.md → skills/netlify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nextjs/{SKILL.md → skills/nextjs-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/notion/{SKILL.md → skills/notion-knowledge-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nx/{SKILL.md → skills/nx-workspace/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/playwright/{SKILL.md → skills/playwright-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/prisma/{SKILL.md → skills/prisma-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/resend/{SKILL.md → skills/resend-email/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sanity/{SKILL.md → skills/sanity-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sentry/{SKILL.md → skills/sentry-monitoring/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/slack/{SKILL.md → skills/slack-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/strapi/{SKILL.md → skills/strapi-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/stripe/{SKILL.md → skills/stripe-payments/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/supabase/{SKILL.md → skills/supabase-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/teams/{SKILL.md → skills/teams-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/trello/{SKILL.md → skills/trello-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/turborepo/{SKILL.md → skills/turborepo-monorepo/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vercel/{SKILL.md → skills/vercel-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vitest/{SKILL.md → skills/vitest-testing/SKILL.md} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { PluginConfig } from '../orchestrator/plugins/types.js'
|
|
2
|
+
import { EXTENSION_NAMESPACE, mcpSchemaUrl, pluginSchemaUrl } from './agent-plugin.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Each integration as an Agent Plugin: `plugin.json` and `mcp.json` beside its
|
|
6
|
+
* `skills/<name>/SKILL.md`, compiled from the integration's `config.ts`.
|
|
7
|
+
*
|
|
8
|
+
* `config.ts` stays the source: it carries what only OpenCastle reads —
|
|
9
|
+
* detection, the agents whose tools a server extends, earlier defaults to
|
|
10
|
+
* migrate from. That goes under `extensions["dev.opencastle"]`, the namespace
|
|
11
|
+
* the standard gives a client for its own data, and the portable part is what
|
|
12
|
+
* any client loads. `npm run plugins:build` writes the files and a test holds
|
|
13
|
+
* them to `config.ts`, as the website's snippets are held to it.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const REPOSITORY = 'https://github.com/monkilabs/opencastle'
|
|
17
|
+
|
|
18
|
+
/** An integration's `mcp.json` value, or null when its server cannot be written portably. */
|
|
19
|
+
export function packMcp(p: PluginConfig): Record<string, unknown> | null {
|
|
20
|
+
const cfg = p.mcpConfig
|
|
21
|
+
if (!cfg || !p.mcpServerKey) return null
|
|
22
|
+
let server: Record<string, unknown>
|
|
23
|
+
if (cfg.type === 'http') {
|
|
24
|
+
// A URL with a value only the user can supply — a tenant id — is not a
|
|
25
|
+
// portable server; the extension data says what it needs.
|
|
26
|
+
if (!cfg.url || cfg.url.includes('${')) return null
|
|
27
|
+
server = { type: 'streamable-http', url: cfg.url }
|
|
28
|
+
} else {
|
|
29
|
+
if (!cfg.command || [cfg.command, ...(cfg.args ?? [])].some((a) => a.includes('${'))) return null
|
|
30
|
+
// No `env`: the standard has no way to name a secret yet, so a server that
|
|
31
|
+
// needs a token reads it from the environment the assistant runs in, and
|
|
32
|
+
// the extension data lists which.
|
|
33
|
+
server = { type: 'stdio', command: cfg.command, ...(cfg.args && cfg.args.length > 0 && { args: cfg.args }) }
|
|
34
|
+
}
|
|
35
|
+
return { $schema: mcpSchemaUrl(), mcpServers: { [p.mcpServerKey]: server } }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** An integration's `plugin.json` value. */
|
|
39
|
+
export function packManifest(p: PluginConfig): Record<string, unknown> {
|
|
40
|
+
const mcp = packMcp(p)
|
|
41
|
+
const what = p.mcpServerKey ? (mcp ? 'skill and MCP server' : 'skill (its MCP server needs per-user setup)') : 'skill'
|
|
42
|
+
return {
|
|
43
|
+
$schema: pluginSchemaUrl(),
|
|
44
|
+
name: p.id,
|
|
45
|
+
description: `${p.name} ${what} for AI coding assistants: ${p.hint.replace(/\.$/, '')}.`,
|
|
46
|
+
homepage: p.docsUrl ?? 'https://www.opencastle.dev/docs/plugins',
|
|
47
|
+
repository: REPOSITORY,
|
|
48
|
+
license: 'MIT',
|
|
49
|
+
keywords: [p.category, p.subCategory],
|
|
50
|
+
extensions: {
|
|
51
|
+
[EXTENSION_NAMESPACE]: {
|
|
52
|
+
label: p.label,
|
|
53
|
+
category: p.category,
|
|
54
|
+
subCategory: p.subCategory,
|
|
55
|
+
authType: p.authType,
|
|
56
|
+
...(p.envVars.length > 0 && { env: p.envVars.map((e) => e.name) }),
|
|
57
|
+
...(p.mcpInputs && p.mcpInputs.length > 0 && { inputs: p.mcpInputs.map((i) => i.id) }),
|
|
58
|
+
...(p.officialDocs && { officialDocs: p.officialDocs }),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Every file an integration's directory holds besides `config.ts` and its skill, as path → text. */
|
|
65
|
+
export function packFiles(p: PluginConfig): Record<string, string> {
|
|
66
|
+
const files: Record<string, string> = { 'plugin.json': JSON.stringify(packManifest(p), null, 2) + '\n' }
|
|
67
|
+
const mcp = packMcp(p)
|
|
68
|
+
if (mcp) files['mcp.json'] = JSON.stringify(mcp, null, 2) + '\n'
|
|
69
|
+
return files
|
|
70
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `opencastle plugin` and an Agent Plugin baseline, through the built CLI.
|
|
3
|
+
*/
|
|
4
|
+
import { execFileSync, spawnSync } from 'node:child_process'
|
|
5
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
7
|
+
import { dirname, join, resolve } from 'node:path'
|
|
8
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
9
|
+
import { mcpSchemaUrl, pluginSchemaUrl } from './agent-plugin.js'
|
|
10
|
+
|
|
11
|
+
const pkgRoot = resolve(import.meta.dirname, '..', '..')
|
|
12
|
+
const cli = join(pkgRoot, 'bin', 'cli.mjs')
|
|
13
|
+
const built = existsSync(join(pkgRoot, 'dist', 'cli', 'plugin.js'))
|
|
14
|
+
|
|
15
|
+
function write(root: string, files: Record<string, string>): void {
|
|
16
|
+
for (const [rel, text] of Object.entries(files)) {
|
|
17
|
+
mkdirSync(dirname(join(root, rel)), { recursive: true })
|
|
18
|
+
writeFileSync(join(root, rel), text)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const readJson = (path: string): Record<string, unknown> => JSON.parse(readFileSync(path, 'utf8'))
|
|
23
|
+
|
|
24
|
+
describe.skipIf(!built)('opencastle plugin', () => {
|
|
25
|
+
let dir: string
|
|
26
|
+
const run = (cwd: string, ...args: string[]) => spawnSync('node', [cli, ...args], { cwd, encoding: 'utf8' })
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
dir = mkdtempSync(join(tmpdir(), 'oc-plugin-cmd-'))
|
|
29
|
+
})
|
|
30
|
+
afterEach(() => rmSync(dir, { recursive: true, force: true }))
|
|
31
|
+
|
|
32
|
+
it('a scaffolded baseline is a plugin every assistant loads, Claude Code included', () => {
|
|
33
|
+
expect(run(dir, 'baseline', 'init', 'base', '--name', '@acme/base').status).toBe(0)
|
|
34
|
+
const out = run(dir, 'plugin', 'check', 'base')
|
|
35
|
+
expect(out.status).toBe(0)
|
|
36
|
+
expect(out.stdout).toContain('Loads in GitHub Copilot, VS Code, Cursor, Codex and Kiro as it is, and in Claude Code.')
|
|
37
|
+
expect(readJson(join(dir, 'base', 'plugin.json'))).toMatchObject({ $schema: pluginSchemaUrl(), name: 'acme.base' })
|
|
38
|
+
expect(run(dir, 'baseline', 'check', 'base').status).toBe(0)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('build keeps Claude Code’s files in step with the portable ones, and keeps what only Claude Code reads', () => {
|
|
42
|
+
run(dir, 'baseline', 'init', 'base', '--name', '@acme/base')
|
|
43
|
+
const base = join(dir, 'base')
|
|
44
|
+
write(base, {
|
|
45
|
+
'mcp.json': JSON.stringify({ $schema: mcpSchemaUrl(), mcpServers: { docs: { type: 'streamable-http', url: 'https://docs.acme.example/mcp' } } }),
|
|
46
|
+
// The scaffold's example policy allows four servers; a team adding one allows it.
|
|
47
|
+
'dev.opencastle/config.json': JSON.stringify({ policy: { mcp: { allow: ['docs'], remoteHosts: ['docs.acme.example'] } } }),
|
|
48
|
+
})
|
|
49
|
+
const claude = join(base, '.claude-plugin', 'plugin.json')
|
|
50
|
+
writeFileSync(claude, JSON.stringify({ ...readJson(claude), userConfig: { region: { type: 'string', title: 'Region', description: 'Where' } } }))
|
|
51
|
+
|
|
52
|
+
const stale = run(dir, 'plugin', 'check', 'base')
|
|
53
|
+
expect(stale.status).toBe(1)
|
|
54
|
+
expect(stale.stdout).toContain('.mcp.json does not match plugin.json and mcp.json')
|
|
55
|
+
expect(run(dir, 'plugin', 'build', 'base', '--check').status).toBe(1)
|
|
56
|
+
|
|
57
|
+
expect(run(dir, 'plugin', 'build', 'base').status).toBe(0)
|
|
58
|
+
expect(readJson(join(base, '.mcp.json'))).toEqual({ mcpServers: { docs: { type: 'http', url: 'https://docs.acme.example/mcp' } } })
|
|
59
|
+
expect(readJson(claude)).toMatchObject({ name: 'acme.base', version: '0.1.0', userConfig: { region: { title: 'Region' } } })
|
|
60
|
+
expect(run(dir, 'plugin', 'check', 'base').status).toBe(0)
|
|
61
|
+
expect(run(dir, 'baseline', 'check', 'base').status).toBe(0)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('index lists every plugin for Claude Code and Copilot, Cursor and Codex', () => {
|
|
65
|
+
const plugin = (name: string): Record<string, string> => ({
|
|
66
|
+
[`plugins/${name}/plugin.json`]: JSON.stringify({ $schema: pluginSchemaUrl(), name, description: `The ${name} plugin` }),
|
|
67
|
+
})
|
|
68
|
+
write(dir, { 'package.json': JSON.stringify({ name: '@acme/agent-plugins', author: 'Acme Platform <p@acme.example>' }), ...plugin('deploy'), ...plugin('review') })
|
|
69
|
+
const out = run(dir, 'plugin', 'index')
|
|
70
|
+
expect(out.status).toBe(0)
|
|
71
|
+
const shared = {
|
|
72
|
+
name: 'acme.agent-plugins',
|
|
73
|
+
owner: { name: 'Acme Platform' },
|
|
74
|
+
metadata: { description: 'Agent Plugins from acme.agent-plugins' },
|
|
75
|
+
plugins: [
|
|
76
|
+
{ name: 'deploy', source: './plugins/deploy', description: 'The deploy plugin' },
|
|
77
|
+
{ name: 'review', source: './plugins/review', description: 'The review plugin' },
|
|
78
|
+
],
|
|
79
|
+
}
|
|
80
|
+
expect(readJson(join(dir, '.claude-plugin', 'marketplace.json'))).toEqual(shared)
|
|
81
|
+
expect(readJson(join(dir, '.cursor-plugin', 'marketplace.json'))).toEqual(shared)
|
|
82
|
+
expect(readJson(join(dir, '.agents', 'plugins', 'marketplace.json'))).toMatchObject({
|
|
83
|
+
name: 'acme.agent-plugins',
|
|
84
|
+
plugins: [{ name: 'deploy', source: { source: 'local', path: './plugins/deploy' }, policy: { installation: 'AVAILABLE' } }, { name: 'review' }],
|
|
85
|
+
})
|
|
86
|
+
expect(out.stdout).toContain('Claude Code needs .claude-plugin/plugin.json')
|
|
87
|
+
expect(run(dir, 'plugin', 'index', '--check').status).toBe(0)
|
|
88
|
+
|
|
89
|
+
write(dir, plugin('release'))
|
|
90
|
+
const behind = run(dir, 'plugin', 'index', '--check')
|
|
91
|
+
expect(behind.status).toBe(1)
|
|
92
|
+
expect(behind.stderr).toContain('.claude-plugin/marketplace.json does not list the plugins under plugins/')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('index refuses two plugins with one name', () => {
|
|
96
|
+
write(dir, {
|
|
97
|
+
'plugins/a/plugin.json': JSON.stringify({ $schema: pluginSchemaUrl(), name: 'same' }),
|
|
98
|
+
'plugins/b/plugin.json': JSON.stringify({ $schema: pluginSchemaUrl(), name: 'same' }),
|
|
99
|
+
})
|
|
100
|
+
const out = run(dir, 'plugin', 'index')
|
|
101
|
+
expect(out.status).toBe(1)
|
|
102
|
+
expect(out.stderr).toContain('are both named "same"')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('a project extending the plugin gets its skill and server in every assistant', () => {
|
|
106
|
+
run(dir, 'baseline', 'init', 'base', '--name', '@acme/base')
|
|
107
|
+
write(join(dir, 'base'), {
|
|
108
|
+
'mcp.json': JSON.stringify({ $schema: mcpSchemaUrl(), mcpServers: { docs: { type: 'streamable-http', url: 'https://docs.acme.example/mcp' } } }),
|
|
109
|
+
// The scaffold's example policy allows four servers; a team adding one allows it.
|
|
110
|
+
'dev.opencastle/config.json': JSON.stringify({ policy: { mcp: { allow: ['docs'], remoteHosts: ['docs.acme.example'] } } }),
|
|
111
|
+
})
|
|
112
|
+
const project = join(dir, 'app')
|
|
113
|
+
write(project, {
|
|
114
|
+
'CLAUDE.md': '# App\n',
|
|
115
|
+
'.opencastle/config.json': JSON.stringify({ extends: ['../../base'] }),
|
|
116
|
+
})
|
|
117
|
+
execFileSync('git', ['init', '-q'], { cwd: project })
|
|
118
|
+
const init = run(project, 'init', '--yes')
|
|
119
|
+
expect(init.status, init.stdout + init.stderr).toBe(0)
|
|
120
|
+
expect(existsSync(join(project, '.claude', 'skills', 'code-review', 'SKILL.md'))).toBe(true)
|
|
121
|
+
expect(readFileSync(join(project, 'CLAUDE.md'), 'utf8')).toContain('Engineering standards')
|
|
122
|
+
expect(readJson(join(project, '.mcp.json'))).toMatchObject({ mcpServers: { docs: { type: 'http', url: 'https://docs.acme.example/mcp' } } })
|
|
123
|
+
expect(run(project, 'sync', '--check').status).toBe(0)
|
|
124
|
+
})
|
|
125
|
+
})
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { basename, dirname, join, relative, resolve } from 'node:path'
|
|
3
|
+
import {
|
|
4
|
+
AGENT_PLUGINS_VERSION,
|
|
5
|
+
EXTENSION_NAMESPACE,
|
|
6
|
+
claudeManifestFor,
|
|
7
|
+
claudeMcpFor,
|
|
8
|
+
isAgentPlugin,
|
|
9
|
+
pluginNameFrom,
|
|
10
|
+
readAgentPlugin,
|
|
11
|
+
type PluginReport,
|
|
12
|
+
} from './agent-plugin.js'
|
|
13
|
+
import { c } from './prompt.js'
|
|
14
|
+
import type { CliContext } from './types.js'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* `opencastle plugin`: check, complete and list Agent Plugins.
|
|
18
|
+
*
|
|
19
|
+
* The standard leaves two things to each client: Claude Code reads its own
|
|
20
|
+
* manifest (`.claude-plugin/plugin.json`) and its own MCP file (`.mcp.json`),
|
|
21
|
+
* and every client indexes a marketplace in its own file. Keeping those by hand
|
|
22
|
+
* is three copies of one fact, which is the drift this tool exists to stop —
|
|
23
|
+
* so they are compiled from the portable files and checked in CI like any
|
|
24
|
+
* other generated output.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const HELP = `
|
|
28
|
+
opencastle plugin <check|build|index> [dir] [options]
|
|
29
|
+
|
|
30
|
+
Agent Plugins 1.0 is the open package format for skills and MCP servers
|
|
31
|
+
(agent-plugins.org): plugin.json, skills/<name>/SKILL.md and mcp.json.
|
|
32
|
+
GitHub Copilot, VS Code, Cursor, Codex and Kiro install one as it is.
|
|
33
|
+
|
|
34
|
+
check [dir] Check a plugin the way a conformant client loads it: the
|
|
35
|
+
manifest, every skill against the Agent Skills spec, every
|
|
36
|
+
MCP server, and that Claude Code's files match the portable ones.
|
|
37
|
+
build [dir] Write Claude Code's .claude-plugin/plugin.json and .mcp.json
|
|
38
|
+
from plugin.json and mcp.json. Claude Code reads only those.
|
|
39
|
+
index [dir] Write the marketplace files for every plugin under plugins/:
|
|
40
|
+
.claude-plugin/marketplace.json (Claude Code, Copilot CLI),
|
|
41
|
+
.cursor-plugin/marketplace.json (Cursor) and
|
|
42
|
+
.agents/plugins/marketplace.json (Codex).
|
|
43
|
+
|
|
44
|
+
Options:
|
|
45
|
+
--check build and index: change nothing; exit 1 if a file is out of date
|
|
46
|
+
--name <name> index: the marketplace name (default: from package.json or the directory)
|
|
47
|
+
--owner <name> index: who maintains it (default: from package.json)
|
|
48
|
+
--json check: machine-readable output
|
|
49
|
+
--help, -h Show this help
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
function json(value: unknown): string {
|
|
53
|
+
return JSON.stringify(value, null, 2) + '\n'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readJsonFile(path: string): Record<string, unknown> | null {
|
|
57
|
+
try {
|
|
58
|
+
const v = JSON.parse(readFileSync(path, 'utf8'))
|
|
59
|
+
return v && typeof v === 'object' && !Array.isArray(v) ? (v as Record<string, unknown>) : null
|
|
60
|
+
} catch {
|
|
61
|
+
return null
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── build ─────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What Claude Code's two files should hold, as path → text, or `null` for a
|
|
69
|
+
* file that should not exist.
|
|
70
|
+
*
|
|
71
|
+
* `.claude-plugin/plugin.json` is co-owned: the portable fields are compiled
|
|
72
|
+
* in, and anything only Claude Code reads — `userConfig`, `hooks`, `agents`,
|
|
73
|
+
* inline `mcpServers` — is the author's and kept. `.mcp.json` is compiled
|
|
74
|
+
* whole from `mcp.json` when the plugin has portable servers; a server only
|
|
75
|
+
* Claude Code should start belongs inline in the manifest.
|
|
76
|
+
*/
|
|
77
|
+
export function claudeFiles(root: string, report: PluginReport): Record<string, string | null> {
|
|
78
|
+
if (!report.manifest) return {}
|
|
79
|
+
const manifestPath = join(root, '.claude-plugin', 'plugin.json')
|
|
80
|
+
const existing = readJsonFile(manifestPath) ?? {}
|
|
81
|
+
const generated = claudeManifestFor(report.manifest)
|
|
82
|
+
const portable = ['name', 'version', 'description', 'author', 'homepage', 'repository', 'license', 'keywords']
|
|
83
|
+
const kept = Object.fromEntries(Object.entries(existing).filter(([k]) => !portable.includes(k)))
|
|
84
|
+
const files: Record<string, string | null> = { '.claude-plugin/plugin.json': json({ ...generated, ...kept }) }
|
|
85
|
+
// With no portable servers there is nothing to compile, and a `.mcp.json`
|
|
86
|
+
// already there is one the author wrote for Claude Code alone.
|
|
87
|
+
if (Object.keys(report.servers).length > 0) files['.mcp.json'] = json(claudeMcpFor(report.servers))
|
|
88
|
+
return files
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Write (or with `check`, compare) a set of generated files. Returns the ones that differ. */
|
|
92
|
+
function apply(root: string, files: Record<string, string | null>, check: boolean): string[] {
|
|
93
|
+
const changed: string[] = []
|
|
94
|
+
for (const [rel, text] of Object.entries(files)) {
|
|
95
|
+
const abs = join(root, rel)
|
|
96
|
+
const current = existsSync(abs) ? readFileSync(abs, 'utf8') : null
|
|
97
|
+
if (current === text) continue
|
|
98
|
+
changed.push(rel)
|
|
99
|
+
if (check) continue
|
|
100
|
+
if (text === null) rmSync(abs, { force: true })
|
|
101
|
+
else {
|
|
102
|
+
mkdirSync(dirname(abs), { recursive: true })
|
|
103
|
+
writeFileSync(abs, text)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return changed
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ── index ─────────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
interface Listed {
|
|
112
|
+
dir: string
|
|
113
|
+
name: string
|
|
114
|
+
description?: string
|
|
115
|
+
claude: boolean
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function marketplaceIdentity(root: string, nameFlag?: string, ownerFlag?: string): { name: string; owner: string; description: string } {
|
|
119
|
+
const pkg = readJsonFile(join(root, 'package.json')) ?? {}
|
|
120
|
+
const pkgName = typeof pkg.name === 'string' ? pkg.name : undefined
|
|
121
|
+
const author = pkg.author
|
|
122
|
+
const authorName = typeof author === 'string' ? author.replace(/\s*[<(].*$/, '') : author && typeof author === 'object' ? (author as { name?: string }).name : undefined
|
|
123
|
+
const name = nameFlag ?? pluginNameFrom(pkgName ?? basename(resolve(root)))
|
|
124
|
+
return {
|
|
125
|
+
name,
|
|
126
|
+
owner: ownerFlag ?? authorName ?? name,
|
|
127
|
+
description: typeof pkg.description === 'string' ? pkg.description : `Agent Plugins from ${name}`,
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The three marketplace files for the plugins under `plugins/`. */
|
|
132
|
+
export function marketplaceFiles(
|
|
133
|
+
plugins: Listed[],
|
|
134
|
+
identity: { name: string; owner: string; description: string },
|
|
135
|
+
): Record<string, string> {
|
|
136
|
+
const entries = plugins.map((p) => ({
|
|
137
|
+
name: p.name,
|
|
138
|
+
source: `./plugins/${p.dir}`,
|
|
139
|
+
...(p.description && { description: p.description }),
|
|
140
|
+
}))
|
|
141
|
+
// One shape both read: Cursor's schema is a strict subset of Claude Code's.
|
|
142
|
+
const shared = json({
|
|
143
|
+
name: identity.name,
|
|
144
|
+
owner: { name: identity.owner },
|
|
145
|
+
metadata: { description: identity.description },
|
|
146
|
+
plugins: entries,
|
|
147
|
+
})
|
|
148
|
+
const codex = json({
|
|
149
|
+
name: identity.name,
|
|
150
|
+
interface: { displayName: identity.name },
|
|
151
|
+
plugins: plugins.map((p) => ({
|
|
152
|
+
name: p.name,
|
|
153
|
+
source: { source: 'local', path: `./plugins/${p.dir}` },
|
|
154
|
+
policy: { installation: 'AVAILABLE', authentication: 'ON_INSTALL' },
|
|
155
|
+
})),
|
|
156
|
+
})
|
|
157
|
+
return {
|
|
158
|
+
'.claude-plugin/marketplace.json': shared,
|
|
159
|
+
'.cursor-plugin/marketplace.json': shared,
|
|
160
|
+
'.agents/plugins/marketplace.json': codex,
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function listPlugins(root: string): { plugins: Listed[]; problems: string[] } {
|
|
165
|
+
const dir = join(root, 'plugins')
|
|
166
|
+
const plugins: Listed[] = []
|
|
167
|
+
const problems: string[] = []
|
|
168
|
+
if (!existsSync(dir)) return { plugins, problems: [`${relative(process.cwd(), dir) || 'plugins'}/ does not exist — a marketplace lists plugins/<name>/`] }
|
|
169
|
+
for (const entry of readdirSync(dir).sort()) {
|
|
170
|
+
const at = join(dir, entry)
|
|
171
|
+
if (!existsSync(join(at, 'plugin.json'))) continue
|
|
172
|
+
if (!isAgentPlugin(at)) {
|
|
173
|
+
problems.push(`plugins/${entry}: plugin.json does not declare an Agent Plugins version — run opencastle plugin check plugins/${entry}`)
|
|
174
|
+
continue
|
|
175
|
+
}
|
|
176
|
+
const report = readAgentPlugin(at)
|
|
177
|
+
if (!report.manifest) {
|
|
178
|
+
problems.push(`plugins/${entry}: ${report.errors[0]}`)
|
|
179
|
+
continue
|
|
180
|
+
}
|
|
181
|
+
plugins.push({
|
|
182
|
+
dir: entry,
|
|
183
|
+
name: report.manifest.name,
|
|
184
|
+
description: report.manifest.description,
|
|
185
|
+
claude: existsSync(join(at, '.claude-plugin', 'plugin.json')),
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
const names = new Map<string, string>()
|
|
189
|
+
for (const p of plugins) {
|
|
190
|
+
const other = names.get(p.name)
|
|
191
|
+
if (other) problems.push(`plugins/${p.dir} and plugins/${other} are both named "${p.name}"; a marketplace lists a name once`)
|
|
192
|
+
names.set(p.name, p.dir)
|
|
193
|
+
}
|
|
194
|
+
return { plugins, problems }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ── command ───────────────────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
function flagValue(args: string[], flag: string): string | undefined {
|
|
200
|
+
const at = args.indexOf(flag)
|
|
201
|
+
if (at === -1) return undefined
|
|
202
|
+
const v = args[at + 1]
|
|
203
|
+
if (!v || v.startsWith('--')) {
|
|
204
|
+
console.error(` ${c.red('✗')} ${flag} needs a value`)
|
|
205
|
+
process.exit(1)
|
|
206
|
+
}
|
|
207
|
+
return v
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function printReport(dir: string, report: PluginReport, claudeStale: string[]): void {
|
|
211
|
+
const m = report.manifest
|
|
212
|
+
console.log(`\n 🏰 ${c.bold('Agent Plugin')} ${m?.name ?? dir}${m?.version ? c.dim(` ${m.version}`) : ''}${report.version ? c.dim(` · Agent Plugins ${report.version}`) : ''}\n`)
|
|
213
|
+
if (m) {
|
|
214
|
+
console.log(` Skills: ${report.skills.length > 0 ? report.skills.join(', ') : c.dim('none')}`)
|
|
215
|
+
console.log(` MCP servers: ${Object.keys(report.servers).length > 0 ? Object.keys(report.servers).join(', ') : c.dim('none')}`)
|
|
216
|
+
if (existsSync(join(report.root, EXTENSION_NAMESPACE))) {
|
|
217
|
+
console.log(` ${EXTENSION_NAMESPACE}/: ${c.dim('OpenCastle content — check it with opencastle baseline check')}`)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
for (const e of report.errors) console.log(` ${c.red('✗')} ${e}`)
|
|
221
|
+
for (const s of claudeStale) console.log(` ${c.red('✗')} ${s} does not match plugin.json and mcp.json ${c.dim('— run opencastle plugin build')}`)
|
|
222
|
+
for (const w of report.warnings) console.log(` ${c.yellow('!')} ${c.dim(w)}`)
|
|
223
|
+
if (report.errors.length === 0 && claudeStale.length === 0) {
|
|
224
|
+
console.log(`\n ${c.green('✓')} Loads in GitHub Copilot, VS Code, Cursor, Codex and Kiro as it is` +
|
|
225
|
+
(existsSync(join(report.root, '.claude-plugin', 'plugin.json')) ? ', and in Claude Code.\n' : `.\n ${c.dim('Run opencastle plugin build to add the files Claude Code reads.')}\n`))
|
|
226
|
+
} else {
|
|
227
|
+
console.log(`\n ${c.red(`${report.errors.length + claudeStale.length} problem(s) to fix.`)}\n`)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Claude Code's files that exist and no longer match the portable ones. */
|
|
232
|
+
export function staleClaudeFiles(root: string, report: PluginReport): string[] {
|
|
233
|
+
if (!existsSync(join(root, '.claude-plugin', 'plugin.json')) && !existsSync(join(root, '.mcp.json'))) return []
|
|
234
|
+
return apply(root, claudeFiles(root, report), true)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export default async function plugin({ args }: CliContext): Promise<void> {
|
|
238
|
+
const [sub, ...rest] = args
|
|
239
|
+
if (!sub || args.includes('--help') || args.includes('-h') || !['check', 'build', 'index'].includes(sub)) {
|
|
240
|
+
console.log(HELP)
|
|
241
|
+
if (sub && !['check', 'build', 'index', '--help', '-h'].includes(sub)) process.exit(1)
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
const valued = new Set(['--name', '--owner'])
|
|
245
|
+
const positional = rest.filter((a, i) => !a.startsWith('--') && !valued.has(rest[i - 1]))
|
|
246
|
+
const dir = positional[0] ?? '.'
|
|
247
|
+
const root = resolve(dir)
|
|
248
|
+
const check = rest.includes('--check')
|
|
249
|
+
|
|
250
|
+
if (sub === 'check') {
|
|
251
|
+
const report = readAgentPlugin(root)
|
|
252
|
+
const stale = report.manifest ? staleClaudeFiles(root, report) : []
|
|
253
|
+
if (rest.includes('--json')) {
|
|
254
|
+
console.log(json({ ...report, root: dir, claudeOutOfDate: stale, spec: AGENT_PLUGINS_VERSION }))
|
|
255
|
+
} else {
|
|
256
|
+
printReport(dir, report, stale)
|
|
257
|
+
}
|
|
258
|
+
if (report.errors.length > 0 || stale.length > 0) process.exit(1)
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (sub === 'build') {
|
|
263
|
+
const report = readAgentPlugin(root)
|
|
264
|
+
if (!report.manifest) {
|
|
265
|
+
for (const e of report.errors) console.error(` ${c.red('✗')} ${e}`)
|
|
266
|
+
process.exit(1)
|
|
267
|
+
}
|
|
268
|
+
const changed = apply(root, claudeFiles(root, report), check)
|
|
269
|
+
if (check) {
|
|
270
|
+
if (changed.length > 0) {
|
|
271
|
+
for (const f of changed) console.error(` ${c.red('✗')} ${f} does not match plugin.json and mcp.json — run opencastle plugin build`)
|
|
272
|
+
process.exit(1)
|
|
273
|
+
}
|
|
274
|
+
console.log(` ${c.green('✓')} Claude Code's files match plugin.json and mcp.json`)
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
console.log(changed.length > 0 ? ` ${c.green('✓')} Wrote ${changed.join(', ')}` : ` ${c.green('✓')} Claude Code's files were already up to date`)
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// index
|
|
282
|
+
const { plugins, problems } = listPlugins(root)
|
|
283
|
+
for (const p of problems) console.error(` ${c.red('✗')} ${p}`)
|
|
284
|
+
if (problems.length > 0) process.exit(1)
|
|
285
|
+
if (plugins.length === 0) {
|
|
286
|
+
console.error(` ${c.red('✗')} no Agent Plugin under ${dir}/plugins/ — each is a directory with a plugin.json`)
|
|
287
|
+
process.exit(1)
|
|
288
|
+
}
|
|
289
|
+
const identity = marketplaceIdentity(root, flagValue(rest, '--name'), flagValue(rest, '--owner'))
|
|
290
|
+
const changed = apply(root, marketplaceFiles(plugins, identity), check)
|
|
291
|
+
const noClaude = plugins.filter((p) => !p.claude)
|
|
292
|
+
if (check) {
|
|
293
|
+
if (changed.length > 0) {
|
|
294
|
+
for (const f of changed) console.error(` ${c.red('✗')} ${f} does not list the plugins under plugins/ — run opencastle plugin index`)
|
|
295
|
+
process.exit(1)
|
|
296
|
+
}
|
|
297
|
+
console.log(` ${c.green('✓')} The marketplace files list all ${plugins.length} plugin(s)`)
|
|
298
|
+
return
|
|
299
|
+
}
|
|
300
|
+
console.log(
|
|
301
|
+
changed.length > 0
|
|
302
|
+
? ` ${c.green('✓')} Listed ${plugins.length} plugin(s) in ${changed.join(', ')}`
|
|
303
|
+
: ` ${c.green('✓')} The marketplace files already list all ${plugins.length} plugin(s)`,
|
|
304
|
+
)
|
|
305
|
+
if (noClaude.length > 0) {
|
|
306
|
+
console.log(` ${c.yellow('!')} ${noClaude.map((p) => `plugins/${p.dir}`).join(', ')} ${c.dim('— Claude Code needs .claude-plugin/plugin.json; run opencastle plugin build in each')}`)
|
|
307
|
+
}
|
|
308
|
+
console.log(` ${c.dim(`Add it: claude plugin marketplace add <owner>/<repo>, copilot plugin marketplace add <owner>/<repo>, codex plugin marketplace add <owner>/<repo>; in Cursor, Dashboard → Plugins → Team Marketplaces → Import.`)}`)
|
|
309
|
+
}
|