@rbbtsn0w/adg 0.6.0-beta.2 → 0.6.0-beta.3

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 CHANGED
@@ -156,6 +156,20 @@ adg plugins update --global
156
156
  adg plugins link --target claude --global
157
157
  ```
158
158
 
159
+ ### Example 3 — `cloudflare/skills` (auto-discovery and selective installation)
160
+
161
+ A repository containing skills for the Cloudflare Developer Platform. Although the repository doesn't explicitly declare an MCP configuration in its native `.claude-plugin/plugin.json` manifest, it includes a `.mcp.json` file in its root. ADG auto-discovers this file, allowing you to selectively choose which components, skills, or MCP servers to install:
162
+
163
+ ```bash
164
+ # Add the cloudflare plugin globally (interactive guide asks which skills/MCP servers to install)
165
+ adg plugins add https://github.com/cloudflare/skills --global
166
+
167
+ # Or install it non-interactively, limiting to specific skills and MCP servers:
168
+ adg plugins add https://github.com/cloudflare/skills --global \
169
+ --skill agents-sdk --skill cloudflare --skill durable-objects \
170
+ --mcp wrangler-mcp --mcp d1-mcp
171
+ ```
172
+
159
173
  > Both repos are pulled by `owner/repo` shorthand over a shallow clone (sparse
160
174
  > checkout when `--sparse` is given). Provenance — `{type:"github",repo,ref,path}`
161
175
  > — plus a `sha256` integrity hash land in `.plugin-lock.json`, so the install is
@@ -38,8 +38,14 @@ export function fromNativeManifest(raw, kind, pluginDir) {
38
38
  copyIfString(n, out, "agents");
39
39
  copyIfString(n, out, "hooks");
40
40
  copyIfString(n, out, "mcpServers");
41
- if (typeof out.mcpServers !== "string" && typeof n.mcp === "string")
42
- out.mcpServers = n.mcp;
41
+ if (typeof out.mcpServers !== "string") {
42
+ if (typeof n.mcp === "string") {
43
+ out.mcpServers = n.mcp;
44
+ }
45
+ else if (pluginDir && existsSync(join(pluginDir, ".mcp.json"))) {
46
+ out.mcpServers = "./.mcp.json";
47
+ }
48
+ }
43
49
  copyIfString(n, out, "apps");
44
50
  if (typeof n.author === "object" && n.author !== null) {
45
51
  manifest.author = n.author;
@@ -190,7 +190,8 @@ async function handleAdd(rest, cmd) {
190
190
  : projectPluginsDir();
191
191
  const only = resolveComponents(values.only);
192
192
  const skillsSubset = values.skill && values.skill.length > 0 ? values.skill : undefined;
193
- const narrowed = only !== undefined || skillsSubset !== undefined;
193
+ const mcpSubset = values.mcp && values.mcp.length > 0 ? values.mcp : undefined;
194
+ const narrowed = only !== undefined || skillsSubset !== undefined || mcpSubset !== undefined;
194
195
  const { order, installed, removed, converted, agents } = await addPlugins({
195
196
  spec,
196
197
  pluginsDir,
@@ -201,6 +202,7 @@ async function handleAdd(rest, cmd) {
201
202
  plugins: values.plugin,
202
203
  only,
203
204
  skillsSubset,
205
+ mcpSubset,
204
206
  withDeps: !values["no-deps"],
205
207
  marketplaceName: values["marketplace-name"],
206
208
  targets: values.target !== undefined ? resolveTargets(values.target) : undefined,
@@ -25,6 +25,7 @@ export const FLAGS = {
25
25
  author: { type: "string", hint: "<name>", help: "plugin author" },
26
26
  type: { type: "string", hint: "plugin|marketplace|all", help: "init: which .agents/ artifact to scaffold (default plugin)" },
27
27
  skill: { type: "string", short: "s", multiple: true, hint: "<name>", help: "skill name (init: seed one · add: limit to these)" },
28
+ mcp: { type: "string", short: "m", multiple: true, hint: "<name>", help: "MCP server name (add: limit to these)" },
28
29
  only: { type: "string", hint: "<types>", help: "limit to these component types (skills,agents,commands,mcp,hooks,apps)" },
29
30
  as: { type: "string", hint: "<name>", help: "plugin name to wrap the skills as" },
30
31
  prefix: { type: "string", hint: "<p>", help: "prefix imported skill names" },
@@ -49,12 +50,13 @@ export const PLUGIN_COMMANDS = {
49
50
  blurb: "In a terminal, add guides you through: scope → plugins → agents → what to install.\n" +
50
51
  "By default it installs everything; choose 'No, let me choose' to pick components,\n" +
51
52
  "or pass the flags below to skip any prompt (e.g. for scripts/CI).",
52
- flags: ["all", "plugin", "only", "skill", "target", "no-deps", "path", "ref", "sparse", "marketplace-name", ...SCOPE],
53
+ flags: ["all", "plugin", "only", "skill", "mcp", "target", "no-deps", "path", "ref", "sparse", "marketplace-name", ...SCOPE],
53
54
  examples: [
54
55
  "adg plugins add owner/repo # guided",
55
56
  "adg plugins add owner/repo --all --global # all plugins, global, non-interactive",
56
57
  "adg plugins add owner/repo --only skills # expose only the skills",
57
58
  "adg plugins add owner/repo --skill brainstorming --skill writing-plans",
59
+ "adg plugins add owner/repo --mcp server-name",
58
60
  ],
59
61
  start: true,
60
62
  },
@@ -12,6 +12,7 @@ import { packageFilter, PROJECTION_DIRS } from "../package.js";
12
12
  import { lockPath, marketplacePath, marketplaceSourcePath, pluginDir, pluginSourceCacheDir } from "../paths.js";
13
13
  import { readLock, upsertEntry, writeLock } from "../lock.js";
14
14
  import { ADG_MANIFEST_PATH, readManifest } from "../manifest.js";
15
+ import { recordTelemetryEvent } from "../telemetry.js";
15
16
  import { readMarketplace, upsertMarketplacePlugin, writeMarketplace } from "../marketplace.js";
16
17
  import { resolveInstallOrder } from "../deps.js";
17
18
  import { cloneGitHub, parseSource, scanNativePlugins, scanPlugins } from "../sources.js";
@@ -38,7 +39,7 @@ function contentHash(dir, manifest) {
38
39
  */
39
40
  export function installPlugin(opts) {
40
41
  const source = resolve(opts.source);
41
- const manifest = readManifest(source);
42
+ const manifest = readManifest(source, opts.telemetrySpan);
42
43
  const name = manifest.name;
43
44
  // Local installs stay flat; remote sources derive a per-marketplace dir from
44
45
  // their origin. The default (no origin) is a flat local copy-in.
@@ -55,6 +56,27 @@ export function installPlugin(opts) {
55
56
  // partial installs survive re-install / `marketplace upgrade`.
56
57
  const desiredSelection = normalizePluginSelection(opts.selection ?? prev?.selection);
57
58
  const selection = resolveSelectionDependencies(manifest, desiredSelection);
59
+ if (selection) {
60
+ const contents = pluginContents(source, manifest);
61
+ if (selection.skills) {
62
+ const invalid = selection.skills.filter((s) => !contents.skills.includes(s));
63
+ if (invalid.length > 0) {
64
+ throw new Error(`selected skill(s) not declared: ${invalid.join(", ")}`);
65
+ }
66
+ }
67
+ if (selection.mcp) {
68
+ const invalid = selection.mcp.filter((s) => !contents.mcp.includes(s));
69
+ if (invalid.length > 0) {
70
+ throw new Error(`selected mcp server(s) not declared: ${invalid.join(", ")}`);
71
+ }
72
+ }
73
+ recordTelemetryEvent("adg.install.selection", {
74
+ plugin: name,
75
+ "components.count": selection.components.length,
76
+ "skills.count": selection.skills ? selection.skills.length : -1,
77
+ "mcp.count": selection.mcp ? selection.mcp.length : -1,
78
+ }, opts.telemetrySpan);
79
+ }
58
80
  const sourceHash = contentHash(source, manifest);
59
81
  const cacheDir = pluginSourceCacheDir(opts.pluginsDir, name);
60
82
  return withPluginSourceCache(source, cacheDir, manifest, (snapshot) => {
@@ -187,10 +209,11 @@ async function selectPluginNames(opts, candidates, workRoot, converted) {
187
209
  */
188
210
  async function resolveSelections(opts, selected, candidates) {
189
211
  const selections = new Map();
190
- if (opts.only || opts.skillsSubset) {
212
+ if (opts.only || opts.skillsSubset || opts.mcpSubset) {
191
213
  const flagSelection = {
192
214
  components: opts.only ?? [...COMPONENT_TYPES],
193
215
  ...(opts.skillsSubset ? { skills: opts.skillsSubset } : {}),
216
+ ...(opts.mcpSubset ? { mcp: opts.mcpSubset } : {}),
194
217
  };
195
218
  for (const name of selected)
196
219
  selections.set(name, flagSelection);
@@ -205,7 +228,7 @@ async function resolveSelections(opts, selected, candidates) {
205
228
  const contents = pluginContents(cand.dir, cand.manifest);
206
229
  const present = presentComponents(contents);
207
230
  // Nothing meaningful to pick: a lone category with at most one member.
208
- if (present.length <= 1 && contents.skills.length <= 1)
231
+ if (present.length <= 1 && contents.skills.length <= 1 && contents.mcp.length <= 1)
209
232
  continue;
210
233
  const skillDescription = skillDescriptionLoader(cand.dir, cand.manifest);
211
234
  selections.set(name, await opts.selectComponents({ name, contents, present, skillDescription }));
@@ -58,5 +58,17 @@ export async function selectComponentsInteractive(req) {
58
58
  selection.skills = picked;
59
59
  }
60
60
  }
61
+ // Drill into individual MCP servers only when mcp is kept and there's a choice.
62
+ if (chosen.includes("mcp") && req.contents.mcp.length > 1) {
63
+ const message = `${pc.bold(req.name)} — which MCP servers? ${pc.dim("(space to toggle)")}`;
64
+ const options = req.contents.mcp.map((s) => ({ value: s, label: s }));
65
+ const initialValues = [...req.contents.mcp];
66
+ const servers = await p.multiselect({ message, options, initialValues, required: true });
67
+ if (!cancelled(servers)) {
68
+ const picked = servers;
69
+ if (picked.length !== req.contents.mcp.length)
70
+ selection.mcp = picked;
71
+ }
72
+ }
61
73
  return selection;
62
74
  }
@@ -84,6 +84,9 @@ export function exposedContents(contents, selection) {
84
84
  else if (c === "skills" && selection.skills) {
85
85
  out[c] = contents.skills.filter((s) => selection.skills.includes(s));
86
86
  }
87
+ else if (c === "mcp" && selection.mcp) {
88
+ out[c] = contents.mcp.filter((s) => selection.mcp.includes(s));
89
+ }
87
90
  else {
88
91
  out[c] = contents[c];
89
92
  }
@@ -46,7 +46,11 @@ export function readManifest(pluginDir, telemetrySpan) {
46
46
  throw new ManifestError([`${file} is not valid JSON: ${err.message}`]);
47
47
  }
48
48
  if (typeof raw === "object" && raw !== null && !Array.isArray(raw)) {
49
- const schemaVersion = raw.schemaVersion;
49
+ const m = raw;
50
+ if (m.mcpServers === undefined && existsSync(join(pluginDir, ".mcp.json"))) {
51
+ m.mcpServers = "./.mcp.json";
52
+ }
53
+ const schemaVersion = m.schemaVersion;
50
54
  if (typeof schemaVersion === "string") {
51
55
  recordTelemetryEvent("adg.manifest.read", {
52
56
  "schema.version": schemaVersion === ADG_SCHEMA_VERSION ? schemaVersion : "other",
@@ -3,7 +3,7 @@ import { existsSync, renameSync, rmSync } from "node:fs";
3
3
  import { basename, dirname, join, resolve } from "node:path";
4
4
  import { copyPluginDir, ensureDir, toPosix, writeJson } from "./fsutil.js";
5
5
  import { ADG_MANIFEST_PATH } from "./manifest.js";
6
- import { mcpConfigPath } from "./mcp.js";
6
+ import { filterMcpConfig, mcpConfigPath } from "./mcp.js";
7
7
  import { packageFilter } from "./package.js";
8
8
  const META_RE = /^(README|LICEN[CS]E|CHANGELOG|NOTICE)(\..+)?$/i;
9
9
  function normalizeRelative(path) {
@@ -106,6 +106,10 @@ export function materializePlugin(opts) {
106
106
  }
107
107
  try {
108
108
  copyPluginDir(opts.source, staging, effectivePackageFilter(opts.manifest, opts.selection));
109
+ const mcp = mcpConfigPath(opts.manifest);
110
+ if (mcp && opts.selection?.components.includes("mcp") && opts.selection.mcp) {
111
+ filterMcpConfig(join(staging, mcp), opts.selection.mcp);
112
+ }
109
113
  writeJson(join(staging, ADG_MANIFEST_PATH), effectiveManifest);
110
114
  opts.build(staging, effectiveManifest);
111
115
  if (existsSync(destination))
package/dist/src/mcp.js CHANGED
@@ -1,4 +1,63 @@
1
+ import { readFileSync, writeFileSync, existsSync } from "node:fs";
1
2
  /** ADG's canonical MCP config pointer. */
2
3
  export function mcpConfigPath(manifest) {
3
4
  return manifest.mcpServers;
4
5
  }
6
+ /** Filter the servers defined in the MCP config file. */
7
+ export function filterMcpConfig(file, allowedNames) {
8
+ if (!existsSync(file))
9
+ return;
10
+ try {
11
+ const json = JSON.parse(readFileSync(file, "utf8"));
12
+ if (typeof json !== "object" || json === null) {
13
+ throw new Error("MCP config root must be an object");
14
+ }
15
+ // Find and validate all defined server names
16
+ const definedNames = new Set();
17
+ let hasMcpServersOrServers = false;
18
+ for (const key of ["mcpServers", "servers"]) {
19
+ const servers = json[key];
20
+ if (servers !== undefined) {
21
+ if (typeof servers !== "object" || servers === null || Array.isArray(servers)) {
22
+ throw new Error(`MCP config "${key}" must be an object`);
23
+ }
24
+ hasMcpServersOrServers = true;
25
+ for (const name of Object.keys(servers)) {
26
+ definedNames.add(name);
27
+ }
28
+ }
29
+ }
30
+ if (allowedNames.length > 0 && !hasMcpServersOrServers) {
31
+ throw new Error("MCP config does not define any servers");
32
+ }
33
+ const missing = allowedNames.filter((name) => !definedNames.has(name));
34
+ if (missing.length > 0) {
35
+ throw new Error(`selected mcp server(s) not declared: ${missing.join(", ")}`);
36
+ }
37
+ const allowed = new Set(allowedNames);
38
+ let changed = false;
39
+ for (const key of ["mcpServers", "servers"]) {
40
+ const servers = json[key];
41
+ if (servers && typeof servers === "object" && !Array.isArray(servers)) {
42
+ const obj = servers;
43
+ const newObj = {};
44
+ for (const [name, config] of Object.entries(obj)) {
45
+ if (allowed.has(name)) {
46
+ newObj[name] = config;
47
+ }
48
+ else {
49
+ changed = true;
50
+ }
51
+ }
52
+ json[key] = newObj;
53
+ }
54
+ }
55
+ if (changed) {
56
+ writeFileSync(file, JSON.stringify(json, null, 2), "utf8");
57
+ }
58
+ }
59
+ catch (err) {
60
+ const msg = err instanceof Error ? err.message : String(err);
61
+ throw new Error("Failed to filter MCP config at " + file + ": " + msg);
62
+ }
63
+ }
package/dist/src/types.js CHANGED
@@ -12,9 +12,12 @@ export function normalizePluginSelection(selection) {
12
12
  const components = new Set(selection.components);
13
13
  if (selection.skills !== undefined)
14
14
  components.add("skills");
15
+ if (selection.mcp !== undefined)
16
+ components.add("mcp");
15
17
  return {
16
18
  components: COMPONENT_TYPES.filter((component) => components.has(component)),
17
19
  ...(selection.skills !== undefined ? { skills: [...new Set(selection.skills)].sort() } : {}),
20
+ ...(selection.mcp !== undefined ? { mcp: [...new Set(selection.mcp)].sort() } : {}),
18
21
  };
19
22
  }
20
23
  /** Expand mandatory component/skill requirements to a stable closure. */
@@ -53,6 +56,7 @@ export function resolveSelectionDependencies(manifest, selection) {
53
56
  return {
54
57
  components: COMPONENT_TYPES.filter((component) => components.has(component)),
55
58
  ...(skills ? { skills: [...skills].sort() } : {}),
59
+ ...(normalized.mcp !== undefined ? { mcp: [...new Set(normalized.mcp)].sort() } : {}),
56
60
  };
57
61
  }
58
62
  export function pluginState(entry) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbbtsn0w/adg",
3
- "version": "0.6.0-beta.2",
3
+ "version": "0.6.0-beta.3",
4
4
  "description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",