opencastle 1.1.1 → 1.2.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.
Files changed (221) hide show
  1. package/README.md +22 -5
  2. package/bin/cli.mjs +6 -0
  3. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  4. package/dist/cli/adapters/single-file-base.js +24 -2
  5. package/dist/cli/adapters/single-file-base.js.map +1 -1
  6. package/dist/cli/agent-plugin.d.ts +119 -0
  7. package/dist/cli/agent-plugin.d.ts.map +1 -0
  8. package/dist/cli/agent-plugin.js +449 -0
  9. package/dist/cli/agent-plugin.js.map +1 -0
  10. package/dist/cli/agent-plugin.test.d.ts +2 -0
  11. package/dist/cli/agent-plugin.test.d.ts.map +1 -0
  12. package/dist/cli/agent-plugin.test.js +227 -0
  13. package/dist/cli/agent-plugin.test.js.map +1 -0
  14. package/dist/cli/baseline.d.ts.map +1 -1
  15. package/dist/cli/baseline.js +99 -26
  16. package/dist/cli/baseline.js.map +1 -1
  17. package/dist/cli/convoy/gates.d.ts +2 -20
  18. package/dist/cli/convoy/gates.d.ts.map +1 -1
  19. package/dist/cli/convoy/gates.js +3 -111
  20. package/dist/cli/convoy/gates.js.map +1 -1
  21. package/dist/cli/copy.d.ts +0 -8
  22. package/dist/cli/copy.d.ts.map +1 -1
  23. package/dist/cli/copy.js +0 -21
  24. package/dist/cli/copy.js.map +1 -1
  25. package/dist/cli/dispatcher.test.js +2 -2
  26. package/dist/cli/dispatcher.test.js.map +1 -1
  27. package/dist/cli/docs-accuracy.test.js +2 -0
  28. package/dist/cli/docs-accuracy.test.js.map +1 -1
  29. package/dist/cli/doctor.d.ts.map +1 -1
  30. package/dist/cli/doctor.js +2 -0
  31. package/dist/cli/doctor.js.map +1 -1
  32. package/dist/cli/init.test.js +36 -24
  33. package/dist/cli/init.test.js.map +1 -1
  34. package/dist/cli/layers.d.ts +8 -0
  35. package/dist/cli/layers.d.ts.map +1 -1
  36. package/dist/cli/layers.js +130 -13
  37. package/dist/cli/layers.js.map +1 -1
  38. package/dist/cli/layers.test.js +2 -2
  39. package/dist/cli/layers.test.js.map +1 -1
  40. package/dist/cli/legacy-install.test.js +8 -1
  41. package/dist/cli/legacy-install.test.js.map +1 -1
  42. package/dist/cli/lesson-command.test.d.ts +2 -0
  43. package/dist/cli/lesson-command.test.d.ts.map +1 -0
  44. package/dist/cli/lesson-command.test.js +100 -0
  45. package/dist/cli/lesson-command.test.js.map +1 -0
  46. package/dist/cli/lesson.d.ts +0 -9
  47. package/dist/cli/lesson.d.ts.map +1 -1
  48. package/dist/cli/lesson.js +212 -276
  49. package/dist/cli/lesson.js.map +1 -1
  50. package/dist/cli/lessons.d.ts +134 -0
  51. package/dist/cli/lessons.d.ts.map +1 -0
  52. package/dist/cli/lessons.js +493 -0
  53. package/dist/cli/lessons.js.map +1 -0
  54. package/dist/cli/lessons.test.d.ts +2 -0
  55. package/dist/cli/lessons.test.d.ts.map +1 -0
  56. package/dist/cli/lessons.test.js +214 -0
  57. package/dist/cli/lessons.test.js.map +1 -0
  58. package/dist/cli/pack-plugins.d.ts +8 -0
  59. package/dist/cli/pack-plugins.d.ts.map +1 -0
  60. package/dist/cli/pack-plugins.js +70 -0
  61. package/dist/cli/pack-plugins.js.map +1 -0
  62. package/dist/cli/plugin-command.test.d.ts +2 -0
  63. package/dist/cli/plugin-command.test.d.ts.map +1 -0
  64. package/dist/cli/plugin-command.test.js +114 -0
  65. package/dist/cli/plugin-command.test.js.map +1 -0
  66. package/dist/cli/plugin.d.ts +30 -0
  67. package/dist/cli/plugin.d.ts.map +1 -0
  68. package/dist/cli/plugin.js +291 -0
  69. package/dist/cli/plugin.js.map +1 -0
  70. package/dist/cli/promote-command.test.d.ts +2 -0
  71. package/dist/cli/promote-command.test.d.ts.map +1 -0
  72. package/dist/cli/promote-command.test.js +151 -0
  73. package/dist/cli/promote-command.test.js.map +1 -0
  74. package/dist/cli/promote.d.ts +12 -0
  75. package/dist/cli/promote.d.ts.map +1 -0
  76. package/dist/cli/promote.js +364 -0
  77. package/dist/cli/promote.js.map +1 -0
  78. package/dist/cli/secret-scan.d.ts +21 -0
  79. package/dist/cli/secret-scan.d.ts.map +1 -0
  80. package/dist/cli/secret-scan.js +114 -0
  81. package/dist/cli/secret-scan.js.map +1 -0
  82. package/dist/cli/sync-check.d.ts.map +1 -1
  83. package/dist/cli/sync-check.js +9 -0
  84. package/dist/cli/sync-check.js.map +1 -1
  85. package/dist/cli/team-commands.test.js +2 -2
  86. package/dist/cli/team-commands.test.js.map +1 -1
  87. package/dist/cli/update.d.ts.map +1 -1
  88. package/dist/cli/update.js +18 -0
  89. package/dist/cli/update.js.map +1 -1
  90. package/dist/orchestrator/plugins/agent-plugins.test.d.ts +2 -0
  91. package/dist/orchestrator/plugins/agent-plugins.test.d.ts.map +1 -0
  92. package/dist/orchestrator/plugins/agent-plugins.test.js +32 -0
  93. package/dist/orchestrator/plugins/agent-plugins.test.js.map +1 -0
  94. package/package.json +2 -1
  95. package/src/cli/adapters/single-file-base.ts +23 -2
  96. package/src/cli/agent-plugin.test.ts +267 -0
  97. package/src/cli/agent-plugin.ts +469 -0
  98. package/src/cli/baseline.ts +99 -26
  99. package/src/cli/convoy/gates.ts +9 -142
  100. package/src/cli/copy.ts +0 -25
  101. package/src/cli/dispatcher.test.ts +2 -2
  102. package/src/cli/docs-accuracy.test.ts +2 -0
  103. package/src/cli/doctor.ts +2 -0
  104. package/src/cli/fixtures/lessons-template-1.0.md +70 -0
  105. package/src/cli/init.test.ts +37 -24
  106. package/src/cli/layers.test.ts +2 -2
  107. package/src/cli/layers.ts +144 -14
  108. package/src/cli/legacy-install.test.ts +11 -1
  109. package/src/cli/lesson-command.test.ts +117 -0
  110. package/src/cli/lesson.ts +215 -266
  111. package/src/cli/lessons.test.ts +254 -0
  112. package/src/cli/lessons.ts +540 -0
  113. package/src/cli/pack-plugins.ts +70 -0
  114. package/src/cli/plugin-command.test.ts +125 -0
  115. package/src/cli/plugin.ts +309 -0
  116. package/src/cli/promote-command.test.ts +170 -0
  117. package/src/cli/promote.ts +371 -0
  118. package/src/cli/secret-scan.ts +154 -0
  119. package/src/cli/sync-check.ts +9 -0
  120. package/src/cli/team-commands.test.ts +2 -2
  121. package/src/cli/update.ts +20 -0
  122. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  123. package/src/orchestrator/agents/researcher.agent.md +1 -1
  124. package/src/orchestrator/customizations/LESSONS-LEARNED.md +10 -66
  125. package/src/orchestrator/customizations/README.md +2 -1
  126. package/src/orchestrator/customizations/logs/README.md +1 -1
  127. package/src/orchestrator/plugins/agent-plugins.test.ts +34 -0
  128. package/src/orchestrator/plugins/astro/mcp.json +9 -0
  129. package/src/orchestrator/plugins/astro/plugin.json +21 -0
  130. package/src/orchestrator/plugins/chrome-devtools/mcp.json +13 -0
  131. package/src/orchestrator/plugins/chrome-devtools/plugin.json +21 -0
  132. package/src/orchestrator/plugins/cloudflare/mcp.json +9 -0
  133. package/src/orchestrator/plugins/cloudflare/plugin.json +21 -0
  134. package/src/orchestrator/plugins/contentful/mcp.json +13 -0
  135. package/src/orchestrator/plugins/contentful/plugin.json +21 -0
  136. package/src/orchestrator/plugins/convex/mcp.json +15 -0
  137. package/src/orchestrator/plugins/convex/plugin.json +21 -0
  138. package/src/orchestrator/plugins/coolify/mcp.json +13 -0
  139. package/src/orchestrator/plugins/coolify/plugin.json +25 -0
  140. package/src/orchestrator/plugins/cypress/plugin.json +21 -0
  141. package/src/orchestrator/plugins/drizzle/plugin.json +21 -0
  142. package/src/orchestrator/plugins/expo/mcp.json +9 -0
  143. package/src/orchestrator/plugins/expo/plugin.json +21 -0
  144. package/src/orchestrator/plugins/figma/mcp.json +9 -0
  145. package/src/orchestrator/plugins/figma/plugin.json +21 -0
  146. package/src/orchestrator/plugins/hetzner/plugin.json +24 -0
  147. package/src/orchestrator/plugins/jira/mcp.json +9 -0
  148. package/src/orchestrator/plugins/jira/plugin.json +21 -0
  149. package/src/orchestrator/plugins/linear/mcp.json +9 -0
  150. package/src/orchestrator/plugins/linear/plugin.json +21 -0
  151. package/src/orchestrator/plugins/netlify/mcp.json +13 -0
  152. package/src/orchestrator/plugins/netlify/plugin.json +21 -0
  153. package/src/orchestrator/plugins/nextjs/mcp.json +13 -0
  154. package/src/orchestrator/plugins/nextjs/plugin.json +21 -0
  155. package/src/orchestrator/plugins/notion/mcp.json +9 -0
  156. package/src/orchestrator/plugins/notion/plugin.json +21 -0
  157. package/src/orchestrator/plugins/nx/mcp.json +14 -0
  158. package/src/orchestrator/plugins/nx/plugin.json +21 -0
  159. package/src/orchestrator/plugins/playwright/mcp.json +13 -0
  160. package/src/orchestrator/plugins/playwright/plugin.json +21 -0
  161. package/src/orchestrator/plugins/prisma/mcp.json +14 -0
  162. package/src/orchestrator/plugins/prisma/plugin.json +21 -0
  163. package/src/orchestrator/plugins/resend/mcp.json +13 -0
  164. package/src/orchestrator/plugins/resend/plugin.json +24 -0
  165. package/src/orchestrator/plugins/sanity/mcp.json +9 -0
  166. package/src/orchestrator/plugins/sanity/plugin.json +21 -0
  167. package/src/orchestrator/plugins/sentry/mcp.json +12 -0
  168. package/src/orchestrator/plugins/sentry/plugin.json +24 -0
  169. package/src/orchestrator/plugins/slack/mcp.json +13 -0
  170. package/src/orchestrator/plugins/slack/plugin.json +24 -0
  171. package/src/orchestrator/plugins/strapi/mcp.json +13 -0
  172. package/src/orchestrator/plugins/strapi/plugin.json +21 -0
  173. package/src/orchestrator/plugins/stripe/mcp.json +9 -0
  174. package/src/orchestrator/plugins/stripe/plugin.json +21 -0
  175. package/src/orchestrator/plugins/supabase/mcp.json +9 -0
  176. package/src/orchestrator/plugins/supabase/plugin.json +21 -0
  177. package/src/orchestrator/plugins/teams/plugin.json +24 -0
  178. package/src/orchestrator/plugins/trello/mcp.json +13 -0
  179. package/src/orchestrator/plugins/trello/plugin.json +25 -0
  180. package/src/orchestrator/plugins/turborepo/plugin.json +21 -0
  181. package/src/orchestrator/plugins/vercel/mcp.json +9 -0
  182. package/src/orchestrator/plugins/vercel/plugin.json +21 -0
  183. package/src/orchestrator/plugins/vitest/plugin.json +21 -0
  184. package/src/orchestrator/skill-config-links.test.ts +2 -1
  185. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +1 -1
  186. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  187. package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
  188. package/src/orchestrator/skills/memory-merger/SKILL.md +17 -21
  189. package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +44 -23
  190. package/src/orchestrator/skills/self-improvement/SKILL.md +30 -15
  191. /package/src/orchestrator/plugins/astro/{SKILL.md → skills/astro-framework/SKILL.md} +0 -0
  192. /package/src/orchestrator/plugins/chrome-devtools/{SKILL.md → skills/browser-testing/SKILL.md} +0 -0
  193. /package/src/orchestrator/plugins/cloudflare/{SKILL.md → skills/cloudflare-platform/SKILL.md} +0 -0
  194. /package/src/orchestrator/plugins/contentful/{SKILL.md → skills/contentful-cms/SKILL.md} +0 -0
  195. /package/src/orchestrator/plugins/convex/{SKILL.md → skills/convex-database/SKILL.md} +0 -0
  196. /package/src/orchestrator/plugins/coolify/{SKILL.md → skills/coolify-deployment/SKILL.md} +0 -0
  197. /package/src/orchestrator/plugins/cypress/{SKILL.md → skills/cypress-testing/SKILL.md} +0 -0
  198. /package/src/orchestrator/plugins/drizzle/{SKILL.md → skills/drizzle-orm/SKILL.md} +0 -0
  199. /package/src/orchestrator/plugins/expo/{SKILL.md → skills/expo-development/SKILL.md} +0 -0
  200. /package/src/orchestrator/plugins/figma/{SKILL.md → skills/figma-design/SKILL.md} +0 -0
  201. /package/src/orchestrator/plugins/hetzner/{SKILL.md → skills/hetzner-cloud/SKILL.md} +0 -0
  202. /package/src/orchestrator/plugins/jira/{SKILL.md → skills/jira-management/SKILL.md} +0 -0
  203. /package/src/orchestrator/plugins/linear/{SKILL.md → skills/linear-task-management/SKILL.md} +0 -0
  204. /package/src/orchestrator/plugins/netlify/{SKILL.md → skills/netlify-deployment/SKILL.md} +0 -0
  205. /package/src/orchestrator/plugins/nextjs/{SKILL.md → skills/nextjs-framework/SKILL.md} +0 -0
  206. /package/src/orchestrator/plugins/notion/{SKILL.md → skills/notion-knowledge-management/SKILL.md} +0 -0
  207. /package/src/orchestrator/plugins/nx/{SKILL.md → skills/nx-workspace/SKILL.md} +0 -0
  208. /package/src/orchestrator/plugins/playwright/{SKILL.md → skills/playwright-testing/SKILL.md} +0 -0
  209. /package/src/orchestrator/plugins/prisma/{SKILL.md → skills/prisma-database/SKILL.md} +0 -0
  210. /package/src/orchestrator/plugins/resend/{SKILL.md → skills/resend-email/SKILL.md} +0 -0
  211. /package/src/orchestrator/plugins/sanity/{SKILL.md → skills/sanity-cms/SKILL.md} +0 -0
  212. /package/src/orchestrator/plugins/sentry/{SKILL.md → skills/sentry-monitoring/SKILL.md} +0 -0
  213. /package/src/orchestrator/plugins/slack/{SKILL.md → skills/slack-notifications/SKILL.md} +0 -0
  214. /package/src/orchestrator/plugins/strapi/{SKILL.md → skills/strapi-cms/SKILL.md} +0 -0
  215. /package/src/orchestrator/plugins/stripe/{SKILL.md → skills/stripe-payments/SKILL.md} +0 -0
  216. /package/src/orchestrator/plugins/supabase/{SKILL.md → skills/supabase-database/SKILL.md} +0 -0
  217. /package/src/orchestrator/plugins/teams/{SKILL.md → skills/teams-notifications/SKILL.md} +0 -0
  218. /package/src/orchestrator/plugins/trello/{SKILL.md → skills/trello-task-management/SKILL.md} +0 -0
  219. /package/src/orchestrator/plugins/turborepo/{SKILL.md → skills/turborepo-monorepo/SKILL.md} +0 -0
  220. /package/src/orchestrator/plugins/vercel/{SKILL.md → skills/vercel-deployment/SKILL.md} +0 -0
  221. /package/src/orchestrator/plugins/vitest/{SKILL.md → skills/vitest-testing/SKILL.md} +0 -0
@@ -0,0 +1,267 @@
1
+ /**
2
+ * Agent Plugins 1.0, as a conformant client reads one — and as a team's
3
+ * baseline, compiled into every assistant.
4
+ *
5
+ * The spec's own examples are used where it gives them, so a reading that
6
+ * drifts from the published text fails here first.
7
+ */
8
+ import { mkdtempSync, mkdirSync, writeFileSync, rmSync, readFileSync } from 'node:fs'
9
+ import { tmpdir } from 'node:os'
10
+ import { join, resolve, dirname } from 'node:path'
11
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest'
12
+ import {
13
+ checkSkill,
14
+ claudeMcpFor,
15
+ isAgentPlugin,
16
+ mcpSchemaUrl,
17
+ pluginNameFrom,
18
+ pluginSchemaUrl,
19
+ readAgentPlugin,
20
+ serverProblem,
21
+ teamServerFor,
22
+ } from './agent-plugin.js'
23
+ import { resolveSources, materialize, hasErrors } from './layers.js'
24
+ import type { StackConfig } from './types.js'
25
+
26
+ const pkgRoot = resolve(import.meta.dirname, '..', '..')
27
+ const noTools: StackConfig = { ides: ['claude-code'], techTools: [], teamTools: [] }
28
+
29
+ function write(root: string, files: Record<string, string>): void {
30
+ for (const [rel, text] of Object.entries(files)) {
31
+ const abs = join(root, rel)
32
+ mkdirSync(dirname(abs), { recursive: true })
33
+ writeFileSync(abs, text)
34
+ }
35
+ }
36
+
37
+ const skill = (name: string, description = `${name} does a thing. Use when it matters.`): string =>
38
+ `---\nname: ${name}\ndescription: "${description}"\n---\n\n# ${name}\n`
39
+
40
+ const manifest = (extra: Record<string, unknown> = {}): string =>
41
+ JSON.stringify({ $schema: pluginSchemaUrl(), name: 'acme.standard', version: '1.2.0', ...extra })
42
+
43
+ const mcp = (servers: Record<string, unknown>): string => JSON.stringify({ $schema: mcpSchemaUrl(), mcpServers: servers })
44
+
45
+ describe('reading a plugin', () => {
46
+ let dir: string
47
+ beforeEach(() => {
48
+ dir = mkdtempSync(join(tmpdir(), 'oc-ap-'))
49
+ })
50
+ afterEach(() => rmSync(dir, { recursive: true, force: true }))
51
+
52
+ it('loads the spec’s layout: manifest, skills and servers', () => {
53
+ write(dir, {
54
+ 'plugin.json': manifest(),
55
+ 'skills/summarize/SKILL.md': skill('summarize'),
56
+ 'skills/summarize/references/checklist.md': '- one\n',
57
+ 'skills/notes.txt': 'not a skill',
58
+ 'mcp.json': mcp({
59
+ 'local-validator': { type: 'stdio', command: './bin/validator', args: ['--data', '${PLUGIN_DATA}/validator'], env: { CONFIG: '${PLUGIN_ROOT}/config.json' }, cwd: '${PLUGIN_ROOT}' },
60
+ 'deployment-api': { type: 'streamable-http', url: 'https://deploy.example.com/mcp', headers: { 'X-Tenant': 'public-tenant' } },
61
+ 'legacy-events': { type: 'sse', url: 'https://legacy.example.com/sse' },
62
+ }),
63
+ })
64
+ const r = readAgentPlugin(dir)
65
+ expect(r.errors).toEqual([])
66
+ expect(r.warnings).toEqual([])
67
+ expect(r.version).toBe('1.0.0')
68
+ expect(r.skills).toEqual(['summarize'])
69
+ expect(Object.keys(r.servers)).toEqual(['local-validator', 'deployment-api', 'legacy-events'])
70
+ expect(isAgentPlugin(dir)).toBe(true)
71
+ })
72
+
73
+ it('refuses a manifest a client must reject, and names the field', () => {
74
+ for (const [bad, said] of [
75
+ [{ name: 'My-Plugin' }, '"name" must be'],
76
+ [{ name: 'has--double' }, '"name" must be'],
77
+ [{ version: 2 }, '"version" must be a string'],
78
+ [{ author: { name: 'A', team: 'B' } }, '"author" may hold only'],
79
+ [{ keywords: 'x' }, '"keywords" must be a list'],
80
+ ] as const) {
81
+ write(dir, { 'plugin.json': manifest(bad) })
82
+ const r = readAgentPlugin(dir)
83
+ expect(r.manifest).toBeUndefined()
84
+ expect(r.errors.join('\n')).toContain(said)
85
+ }
86
+ write(dir, { 'plugin.json': JSON.stringify({ $schema: 'https://example.com/x.json', name: 'a' }) })
87
+ expect(readAgentPlugin(dir).errors[0]).toContain('"$schema" must be')
88
+ expect(isAgentPlugin(dir)).toBe(false)
89
+ })
90
+
91
+ it('reports and ignores an unknown field, as a client must', () => {
92
+ write(dir, { 'plugin.json': manifest({ logo: 'x.png', commands: [] }) })
93
+ const r = readAgentPlugin(dir)
94
+ expect(r.errors).toEqual([])
95
+ expect(r.manifest?.name).toBe('acme.standard')
96
+ expect(r.warnings.join('\n')).toMatch(/"logo" is not an Agent Plugins field[\s\S]*"commands"/)
97
+ })
98
+
99
+ it('accepts the 1.1.0 draft, which changes only the number', () => {
100
+ write(dir, {
101
+ 'plugin.json': JSON.stringify({ $schema: pluginSchemaUrl('1.1.0'), name: 'a' }),
102
+ 'mcp.json': JSON.stringify({ $schema: mcpSchemaUrl('1.0.0'), mcpServers: {} }),
103
+ })
104
+ const r = readAgentPlugin(dir)
105
+ expect(r.version).toBe('1.1.0')
106
+ expect(r.errors).toEqual(['mcp.json: targets Agent Plugins 1.0.0 while plugin.json targets 1.1.0, so no server loads'])
107
+ })
108
+
109
+ it('skips one bad server and keeps the rest', () => {
110
+ write(dir, {
111
+ 'plugin.json': manifest(),
112
+ 'mcp.json': mcp({ bad: { type: 'stdio', command: 'npx -y thing' }, good: { type: 'stdio', command: 'npx', args: ['-y', 'thing@1.0.0'] } }),
113
+ })
114
+ const r = readAgentPlugin(dir)
115
+ expect(Object.keys(r.servers)).toEqual(['good'])
116
+ expect(r.errors[0]).toContain('command must be one executable')
117
+ })
118
+ })
119
+
120
+ describe('a server entry', () => {
121
+ it.each([
122
+ [{ type: 'stdio', command: '../bin/server' }, 'must start with ./'],
123
+ [{ type: 'stdio', command: 'node', cwd: 'data' }, 'cwd must start with'],
124
+ [{ type: 'stdio', command: 'node', env: { PLUGIN_ROOT: '/x' } }, 'cannot set PLUGIN_ROOT'],
125
+ [{ type: 'stdio', command: '${PLUGIN_ROOT}/bin/x' }, 'command is not expanded'],
126
+ [{ type: 'streamable-http', url: 'http://api.example.com/mcp' }, 'needs https'],
127
+ [{ type: 'streamable-http', url: 'https://user:pw@api.example.com/mcp' }, 'user or password'],
128
+ [{ type: 'streamable-http', url: 'https://api.example.com/mcp#x' }, 'fragment'],
129
+ [{ type: 'streamable-http', url: 'https://a.example.com', headers: { 'X-A': '1', 'x-a': '2' } }, 'given twice'],
130
+ [{ type: 'streamable-http', url: 'https://a.example.com', command: 'x' }, 'cannot have'],
131
+ [{ type: 'websocket', url: 'wss://a' }, 'type must be'],
132
+ ])('refuses %j', (raw, said) => {
133
+ expect(serverProblem('s', raw)).toContain(said)
134
+ })
135
+
136
+ it('lets a loopback server use plain http', () => {
137
+ expect(serverProblem('s', { type: 'streamable-http', url: 'http://127.0.0.1:3845/mcp' })).toBeNull()
138
+ expect(serverProblem('s', { type: 'streamable-http', url: 'http://localhost:3845/mcp' })).toBeNull()
139
+ })
140
+ })
141
+
142
+ describe('a skill, against the Agent Skills spec', () => {
143
+ let dir: string
144
+ beforeEach(() => {
145
+ dir = mkdtempSync(join(tmpdir(), 'oc-skill-'))
146
+ })
147
+ afterEach(() => rmSync(dir, { recursive: true, force: true }))
148
+
149
+ it('must be named as its directory', () => {
150
+ write(dir, { 'deploy/SKILL.md': skill('deploy-runbook') })
151
+ expect(checkSkill(join(dir, 'deploy')).errors[0]).toContain('must match its directory, deploy/')
152
+ })
153
+
154
+ it('needs a description of at most 1024 characters', () => {
155
+ write(dir, { 'a/SKILL.md': skill('a', 'x'.repeat(1025)), 'b/SKILL.md': '---\nname: b\n---\n' })
156
+ expect(checkSkill(join(dir, 'a')).errors[0]).toContain('1025 characters')
157
+ expect(checkSkill(join(dir, 'b')).errors[0]).toContain('has no description')
158
+ })
159
+
160
+ it('names fields the spec does not define, and lets assistant ones pass', () => {
161
+ write(dir, { 'a/SKILL.md': '---\nname: a\ndescription: "Does a. Use when a."\nuser-invocable: true\napplyTo: "**"\n---\n' })
162
+ const r = checkSkill(join(dir, 'a'))
163
+ expect(r.errors).toEqual([])
164
+ expect(r.warnings).toEqual(['skills/a/SKILL.md: applyTo is not an Agent Skills field; other assistants ignore it'])
165
+ })
166
+ })
167
+
168
+ describe('Claude Code’s copies', () => {
169
+ it('resolves ./ and the plugin variables in Claude Code’s spelling', () => {
170
+ expect(
171
+ claudeMcpFor({
172
+ local: { type: 'stdio', command: './bin/server', args: ['${PLUGIN_ROOT}/a', '${PLUGIN_DATA}/b'] },
173
+ remote: { type: 'streamable-http', url: 'https://x.example.com/mcp' },
174
+ old: { type: 'sse', url: 'https://y.example.com/sse' },
175
+ }),
176
+ ).toEqual({
177
+ mcpServers: {
178
+ local: { command: '${CLAUDE_PLUGIN_ROOT}/bin/server', args: ['${CLAUDE_PLUGIN_ROOT}/a', '${CLAUDE_PLUGIN_DATA}/b'] },
179
+ remote: { type: 'http', url: 'https://x.example.com/mcp' },
180
+ old: { type: 'sse', url: 'https://y.example.com/sse' },
181
+ },
182
+ })
183
+ })
184
+ })
185
+
186
+ describe('naming', () => {
187
+ it('makes a plugin name from a package name', () => {
188
+ expect(pluginNameFrom('@acme/ai-standard')).toBe('acme.ai-standard')
189
+ expect(pluginNameFrom('My Plugin!')).toBe('my-plugin')
190
+ })
191
+ })
192
+
193
+ describe('a plugin as a team’s baseline', () => {
194
+ let project: string
195
+ beforeEach(() => {
196
+ project = mkdtempSync(join(tmpdir(), 'oc-ap-layer-'))
197
+ })
198
+ afterEach(() => rmSync(project, { recursive: true, force: true }))
199
+
200
+ const plugin = (root: string, files: Record<string, string> = {}): void =>
201
+ write(join(project, root), {
202
+ 'plugin.json': manifest(),
203
+ 'skills/secure-coding/SKILL.md': skill('secure-coding'),
204
+ 'mcp.json': mcp({
205
+ docs: { type: 'streamable-http', url: 'https://docs.acme.example/mcp' },
206
+ lint: { type: 'stdio', command: './bin/lint', args: ['--config', '${PLUGIN_ROOT}/lint.json'] },
207
+ cache: { type: 'stdio', command: 'node', args: ['${PLUGIN_DATA}/x.js'] },
208
+ }),
209
+ 'dev.opencastle/instructions/standards.md': '# Standards\n\nBe kind.\n',
210
+ 'dev.opencastle/config.json': JSON.stringify({ policy: { contextBudget: 9000 } }),
211
+ ...files,
212
+ })
213
+
214
+ it('compiles its skills, its portable servers and its OpenCastle layer', () => {
215
+ plugin('standard')
216
+ write(project, { '.opencastle/config.json': JSON.stringify({ extends: ['../standard'] }) })
217
+ const r = resolveSources({ pkgRoot, projectRoot: project, stack: noTools })
218
+ expect(hasErrors(r)).toBe(false)
219
+ expect(r.items.get('skills/secure-coding')?.layer).toBe('standard')
220
+ expect(r.items.get('instructions/standards')?.layer).toBe('standard')
221
+ expect(r.policy.contextBudget).toEqual({ tokens: 9000, by: 'standard' })
222
+ expect(r.servers.get('docs')).toMatchObject({ server: { type: 'http', url: 'https://docs.acme.example/mcp' }, where: 'standard/mcp.json' })
223
+ expect(r.servers.get('lint')?.server).toEqual({ type: 'stdio', command: './standard/bin/lint', args: ['--config', './standard/lint.json'] })
224
+ expect(r.servers.has('cache')).toBe(false)
225
+ expect(r.issues.map((i) => i.message).join('\n')).toContain('MCP server "cache" uses ${PLUGIN_DATA}')
226
+ const src = materialize(r, pkgRoot)
227
+ try {
228
+ expect(readFileSync(join(src.root, 'skills', 'secure-coding', 'SKILL.md'), 'utf8')).toContain('secure-coding')
229
+ } finally {
230
+ src.dispose()
231
+ }
232
+ })
233
+
234
+ it('extends one published to npm as it is, with no OpenCastle declaration', () => {
235
+ plugin('node_modules/@acme/standard', { 'package.json': JSON.stringify({ name: '@acme/standard', version: '1.2.0' }) })
236
+ write(project, { '.opencastle/config.json': JSON.stringify({ extends: ['@acme/standard'] }) })
237
+ const r = resolveSources({ pkgRoot, projectRoot: project, stack: noTools })
238
+ expect(hasErrors(r)).toBe(false)
239
+ expect(r.layers.find((l) => l.id === '@acme/standard')?.version).toBe('1.2.0')
240
+ expect(r.servers.get('lint')?.server).toMatchObject({ command: './node_modules/@acme/standard/bin/lint' })
241
+ })
242
+
243
+ it('refuses a server defined in both mcp.json and config.json', () => {
244
+ plugin('standard', {
245
+ 'dev.opencastle/config.json': JSON.stringify({ mcpServers: { docs: { url: 'https://docs.acme.example/mcp' } } }),
246
+ })
247
+ write(project, { '.opencastle/config.json': JSON.stringify({ extends: ['../standard'] }) })
248
+ const r = resolveSources({ pkgRoot, projectRoot: project, stack: noTools })
249
+ expect(r.issues.find((i) => i.level === 'error')?.message).toBe('defines MCP server "docs", which standard/dev.opencastle/config.json defines too')
250
+ })
251
+
252
+ it('refuses one a conformant client would reject', () => {
253
+ write(join(project, 'broken'), { 'plugin.json': JSON.stringify({ $schema: pluginSchemaUrl(), name: 'Bad Name' }) })
254
+ write(project, { '.opencastle/config.json': JSON.stringify({ extends: ['../broken'] }) })
255
+ const r = resolveSources({ pkgRoot, projectRoot: project, stack: noTools })
256
+ expect(hasErrors(r)).toBe(true)
257
+ expect(r.issues[0].message).toContain('which is not a valid Agent Plugin: plugin.json: "name" must be')
258
+ })
259
+
260
+ it('compiles a portable server the way a team server is compiled', () => {
261
+ expect(teamServerFor({ type: 'stdio', command: 'npx', args: ['-y', 'x@1.0.0'] }, 'node_modules/x')).toEqual({
262
+ server: { type: 'stdio', command: 'npx', args: ['-y', 'x@1.0.0'] },
263
+ })
264
+ expect(teamServerFor({ type: 'sse', url: 'https://a.example.com/sse' }, 'x').skipped).toContain('legacy SSE')
265
+ expect(teamServerFor({ type: 'stdio', command: 'node', cwd: './data' }, 'x').skipped).toContain('runs in ./data')
266
+ })
267
+ })