@rbbtsn0w/adg 0.6.0-beta.7 → 0.6.0-beta.8

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
@@ -31,6 +31,21 @@ See [docs/authoring.md](docs/authoring.md) to author a plugin, and
31
31
  - **Reproducibility** — `.plugin-lock.json` records source, version and a content
32
32
  hash for every installed plugin.
33
33
 
34
+ ## Default plugin layout
35
+
36
+ A repository without a manifest is also installable when it uses the standard
37
+ plugin locations: `skills/<name>/SKILL.md`, `hooks/hooks.json`, or `.mcp.json`.
38
+ ADG derives a default manifest from the locations that exist. Add
39
+ `.agents/.plugin.json` only when a source needs custom component paths or other
40
+ plugin metadata; its `skills`, `hooks`, and `mcpServers` fields override only
41
+ their matching defaults, while omitted fields inherit valid standard locations.
42
+ For structural sources, `--as` sets a stable installed identity and `--only`
43
+ limits both the stored payload and runtime exposure. In non-interactive runs,
44
+ discovered hooks or MCP require explicit `--only`. Default DSL applies only to
45
+ the source root. It is not a monorepo convention: every member of a
46
+ multi-plugin repository must declare its own `.agents/.plugin.json` and be
47
+ selected with `--plugin` or `--all`.
48
+
34
49
  ---
35
50
 
36
51
  # Install and quick start
@@ -266,9 +281,9 @@ adg plugins add plugins/my-plugin --project # <repo>/.agents/plugins
266
281
  adg plugins add plugins/my-plugin --global # ~/.agents/plugins
267
282
  adg plugins add plugins/asc --dir plugins # explicit target dir
268
283
 
269
- # add from GitHub (shorthand, @ref, or full URL); --path selects a monorepo subdir
284
+ # add from GitHub (shorthand, @ref, or full URL)
270
285
  adg plugins add owner/repo --dir plugins
271
- adg plugins add owner/repo@v0.1.0 --path plugins/asc --dir plugins
286
+ adg plugins add owner/repo@v0.1.0 --plugin asc --dir plugins
272
287
  adg plugins add https://github.com/owner/repo.git --ref main --dir plugins
273
288
  adg plugins add plugins/asc --dir plugins --no-deps # skip transitive deps
274
289
 
@@ -5,6 +5,7 @@ import { addPlugins } from "../commands/install.js";
5
5
  import { validatePlugin } from "../commands/validate.js";
6
6
  import { listPlugins } from "../commands/list.js";
7
7
  import { importSkills } from "../commands/import.js";
8
+ import { inspectSource } from "../commands/inspect.js";
8
9
  import { linkPlugins } from "../commands/link.js";
9
10
  import { unlinkPlugins } from "../commands/unlink.js";
10
11
  import { syncPlugins } from "../commands/sync.js";
@@ -197,7 +198,6 @@ async function handleAdd(rest, cmd) {
197
198
  pluginsDir,
198
199
  ref: values.ref,
199
200
  sparse: values.sparse,
200
- path: values.path,
201
201
  all: values.all,
202
202
  plugins: values.plugin,
203
203
  only,
@@ -205,12 +205,14 @@ async function handleAdd(rest, cmd) {
205
205
  mcpSubset,
206
206
  withDeps: !values["no-deps"],
207
207
  marketplaceName: values["marketplace-name"],
208
+ as: values.as,
208
209
  targets: values.target !== undefined ? resolveTargets(values.target) : undefined,
209
210
  selectPlugins: tty ? selectPluginsInteractive : undefined,
210
211
  selectTargets: tty && values.target === undefined ? selectTargetsInteractive : undefined,
211
212
  confirmFull: tty && !narrowed ? confirmFullInstall : undefined,
212
213
  selectComponents: tty && !narrowed ? selectComponentsInteractive : undefined,
213
214
  activate: true,
215
+ nonInteractive: !tty,
214
216
  scope: global ? "user" : "project",
215
217
  });
216
218
  for (const name of converted)
@@ -340,6 +342,15 @@ async function runPluginsVerb(verb, rest, cmd) {
340
342
  }
341
343
  return;
342
344
  }
345
+ case "inspect": {
346
+ const { values, positionals } = parseVerb(verb, cmd.flags, rest);
347
+ const result = await inspectSource({ spec: positionals[0] ?? process.cwd(), ref: values.ref });
348
+ if (values.json)
349
+ console.log(JSON.stringify(result, null, 2));
350
+ else
351
+ console.log(`${ui.ok("inspected")} ${ui.name(result.manifest.name)} ${ui.meta(`[${result.kind}] ${result.components.join(", ") || "no components"}`)}`);
352
+ return;
353
+ }
343
354
  case "add": {
344
355
  await handleAdd(rest, cmd);
345
356
  return;
@@ -8,7 +8,7 @@ export const FLAGS = {
8
8
  // Short flags are first-letter aliases. Where several long flags share a
9
9
  // first letter, the highest-frequency one wins the short and the rest stay
10
10
  // long-only: d → dir (not description) a → all (not author/as)
11
- // s → skill (not sparse) p → plugin (not path/project/prefix)
11
+ // s → skill (not sparse) p → plugin (not project/prefix)
12
12
  dir: { type: "string", short: "d", hint: "<dir>", help: "install into an explicit directory" },
13
13
  global: { type: "boolean", short: "g", help: "use ~/.agents/plugins (across all projects)" },
14
14
  project: { type: "boolean", help: "use <repo>/.agents/plugins (default)" },
@@ -16,7 +16,6 @@ export const FLAGS = {
16
16
  all: { type: "boolean", short: "a", help: "select all available plugins" },
17
17
  plugin: { type: "string", short: "p", multiple: true, hint: "<name>", help: "select a specific plugin (repeatable)" },
18
18
  "no-deps": { type: "boolean", short: "n", help: "don't install dependencies" },
19
- path: { type: "string", hint: "<subdir>", help: "install only this subdir of the source" },
20
19
  ref: { type: "string", short: "r", hint: "<ref>", help: "pin a git ref (branch/tag/sha)" },
21
20
  sparse: { type: "string", multiple: true, hint: "<path>", help: "sparse-checkout path (repeatable)" },
22
21
  "marketplace-name": { type: "string", hint: "<name>", help: "override the marketplace key" },
@@ -27,7 +26,7 @@ export const FLAGS = {
27
26
  skill: { type: "string", short: "s", multiple: true, hint: "<name>", help: "skill name (init: seed one · add: limit to these)" },
28
27
  mcp: { type: "string", short: "m", multiple: true, hint: "<name>", help: "MCP server name (add: limit to these)" },
29
28
  only: { type: "string", hint: "<types>", help: "limit to these component types (skills,agents,commands,mcp,hooks,apps)" },
30
- as: { type: "string", hint: "<name>", help: "plugin name to wrap the skills as" },
29
+ as: { type: "string", hint: "<name>", help: "installed identity for a manifest-free structural source" },
31
30
  prefix: { type: "string", hint: "<p>", help: "prefix imported skill names" },
32
31
  verbose: { type: "boolean", short: "v", help: "expand each component to its member names" },
33
32
  json: { type: "boolean", help: "print stable machine-readable JSON" },
@@ -50,7 +49,7 @@ export const PLUGIN_COMMANDS = {
50
49
  blurb: "In a terminal, add guides you through: scope → plugins → agents → what to install.\n" +
51
50
  "By default it installs everything; choose 'No, let me choose' to pick components,\n" +
52
51
  "or pass the flags below to skip any prompt (e.g. for scripts/CI).",
53
- flags: ["all", "plugin", "only", "skill", "mcp", "target", "no-deps", "path", "ref", "sparse", "marketplace-name", ...SCOPE],
52
+ flags: ["all", "plugin", "only", "skill", "mcp", "target", "no-deps", "ref", "sparse", "marketplace-name", "as", ...SCOPE],
54
53
  examples: [
55
54
  "adg plugins add owner/repo # guided",
56
55
  "adg plugins add owner/repo --all --global # all plugins, global, non-interactive",
@@ -128,6 +127,12 @@ export const PLUGIN_COMMANDS = {
128
127
  positional: "<dir> plugin directory (default: current directory)",
129
128
  flags: [],
130
129
  },
130
+ inspect: {
131
+ summary: "inspect a plugin source without installing it",
132
+ synopsis: "adg plugins inspect [<source>] [--ref <ref>]",
133
+ positional: "<source> local directory or owner/repo[@ref] (default: current directory)",
134
+ flags: ["json", "ref"],
135
+ },
131
136
  "import-skills": {
132
137
  summary: "wrap an existing skills/ dir as a plugin",
133
138
  synopsis: "adg plugins import-skills <skills-dir> --as <name>",
@@ -0,0 +1,41 @@
1
+ import { mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { basename, join, resolve } from "node:path";
4
+ import { findManifestFile, readManifest } from "../manifest.js";
5
+ import { resolveDefaultDsl } from "../default-dsl.js";
6
+ import { pluginContents } from "../components.js";
7
+ import { cloneGitHub, githubRepositoryDescription, parseSource } from "../sources.js";
8
+ /** Read-only definition resolution for a local plugin root. */
9
+ export function inspectPlugin(root, metadata) {
10
+ const dir = resolve(root);
11
+ const file = findManifestFile(dir);
12
+ const manifest = file
13
+ ? readManifest(dir)
14
+ : resolveDefaultDsl(dir, metadata ?? { name: basename(dir), description: basename(dir) }).manifest;
15
+ const contents = pluginContents(dir, manifest);
16
+ return { kind: file ? "manifest" : "default-dsl", root: dir, manifest, components: Object.entries(contents).filter(([, v]) => v.length > 0).map(([k]) => k) };
17
+ }
18
+ /** Resolve a local or GitHub source without creating a store, lock, or projection. */
19
+ export async function inspectSource(opts) {
20
+ const parsed = parseSource(opts.spec);
21
+ if (parsed.kind === "local") {
22
+ return inspectPlugin(parsed.dir);
23
+ }
24
+ if (parsed.path)
25
+ throw new Error("GitHub subdirectory sources are not supported; define a marketplace and select with --plugin or --all");
26
+ const staging = mkdtempSync(join(tmpdir(), "adg-inspect-"));
27
+ try {
28
+ cloneGitHub({ ...parsed, ref: opts.ref ?? parsed.ref }, staging, { runner: opts.gitRunner });
29
+ const manifestFile = findManifestFile(staging);
30
+ const description = manifestFile
31
+ ? undefined
32
+ : await (opts.descriptionResolver ?? githubRepositoryDescription)(parsed.source);
33
+ const result = inspectPlugin(staging, manifestFile
34
+ ? undefined
35
+ : { name: parsed.source, description: description ?? parsed.source });
36
+ return { ...result, root: "." };
37
+ }
38
+ finally {
39
+ rmSync(staging, { recursive: true, force: true });
40
+ }
41
+ }
@@ -6,7 +6,7 @@ import { ADAPTER_TARGETS } from "../adapters/index.js";
6
6
  import { fromNativeManifest } from "../adapters/reverse.js";
7
7
  import { adaptPlugin } from "./adapt.js";
8
8
  import { removePlugin } from "./remove.js";
9
- import { toPosix, writeJson } from "../fsutil.js";
9
+ import { copyPluginDir, toPosix, writeJson } from "../fsutil.js";
10
10
  import { folderHash } from "../hash.js";
11
11
  import { packageFilter, PROJECTION_DIRS } from "../package.js";
12
12
  import { lockPath, marketplacePath, marketplaceSourcePath, pluginDir, pluginSourceCacheDir } from "../paths.js";
@@ -15,12 +15,13 @@ import { ADG_MANIFEST_PATH, readManifest } from "../manifest.js";
15
15
  import { recordTelemetryEvent } from "../telemetry.js";
16
16
  import { readMarketplace, upsertMarketplacePlugin, writeMarketplace } from "../marketplace.js";
17
17
  import { resolveInstallOrder } from "../deps.js";
18
- import { cloneGitHub, gitRevision, parseSource, scanNativePlugins, scanPlugins } from "../sources.js";
18
+ import { cloneGitHub, gitRevision, githubRepositoryDescription, parseGitHubSource, parseSource, scanNativePlugins, scanPlugins } from "../sources.js";
19
19
  import { normalizePluginSelection, pluginState, resolveSelectionDependencies, sameSource, COMPONENT_TYPES } from "../types.js";
20
20
  import { pluginContents, presentComponents } from "../components.js";
21
21
  import { skillDescriptionLoader } from "../skills.js";
22
22
  import { resolveAgents } from "../agents/index.js";
23
23
  import { effectivePackageFilter, materializePlugin, withPluginSourceCache } from "../materialize.js";
24
+ import { resolveDefaultDsl } from "../default-dsl.js";
24
25
  // Generated runtime projections never count toward a plugin's content hash.
25
26
  const HASH_IGNORE = PROJECTION_DIRS;
26
27
  /** Content hash over a plugin's packaged payload (hooks files are authored content, not generated). */
@@ -126,6 +127,8 @@ export function installPlugin(opts) {
126
127
  entry.selection = desiredSelection;
127
128
  if (prev?.state)
128
129
  entry.state = prev.state;
130
+ if (opts.definition)
131
+ entry.definition = opts.definition;
129
132
  const previousEntry = prev && Object.fromEntries(Object.entries(prev).filter(([key]) => key !== "installedAt" && key !== "updatedAt"));
130
133
  const changed = !prev || !isDeepStrictEqual(previousEntry, entry);
131
134
  if (changed) {
@@ -170,7 +173,7 @@ function discoverPlugins(root) {
170
173
  return { candidates: scanPlugins(root), converted };
171
174
  }
172
175
  /** Resolve which discovered plugins to install from the selection options. */
173
- async function selectPluginNames(opts, candidates, workRoot, converted) {
176
+ async function selectPluginNames(opts, candidates, converted) {
174
177
  const names = [...candidates.keys()];
175
178
  if (opts.plugins?.length) {
176
179
  const missing = opts.plugins.filter((p) => !candidates.has(p));
@@ -179,13 +182,6 @@ async function selectPluginNames(opts, candidates, workRoot, converted) {
179
182
  }
180
183
  return opts.plugins.filter((p) => candidates.has(p));
181
184
  }
182
- if (opts.path) {
183
- const target = resolve(join(workRoot, opts.path));
184
- const hit = [...candidates.values()].find((c) => resolve(c.dir) === target);
185
- if (!hit)
186
- throw new Error(`no plugin found at --path ${opts.path}`);
187
- return [hit.manifest.name];
188
- }
189
185
  if (opts.all || candidates.size === 1)
190
186
  return names;
191
187
  if (opts.selectPlugins) {
@@ -220,6 +216,11 @@ async function resolveSelections(opts, selected, candidates) {
220
216
  selections.set(name, flagSelection);
221
217
  return selections;
222
218
  }
219
+ if (opts.replaySelection) {
220
+ for (const name of selected)
221
+ selections.set(name, opts.replaySelection);
222
+ return selections;
223
+ }
223
224
  if (!opts.confirmFull || !opts.selectComponents)
224
225
  return selections; // non-interactive default: full
225
226
  if (await opts.confirmFull(selected))
@@ -251,13 +252,12 @@ function sameRemoteSource(entry, parsed, ref) {
251
252
  * (`--plugin one` after previously installing `--all`) without leaving stale
252
253
  * runtime exports behind.
253
254
  */
254
- function reconcileRemotePlugins(opts, parsed, ref, narrowed, desired) {
255
+ function reconcileRemotePlugins(opts, parsed, ref, desired) {
255
256
  if (parsed.kind === "local")
256
257
  return [];
257
- // A path/sparse install does not prove the full source shape, so it must not
258
- // prune sibling plugins from the same repo that were intentionally excluded
259
- // from the checkout/selection window.
260
- if (narrowed || opts.sparse?.length)
258
+ // A sparse checkout does not prove the full source shape, so it must not
259
+ // prune sibling plugins from the same repo that were intentionally excluded.
260
+ if (opts.sparse?.length)
261
261
  return [];
262
262
  const lock = readLock(lockPath(opts.pluginsDir));
263
263
  const stale = Object.entries(lock.plugins)
@@ -311,21 +311,33 @@ function activateInstalled(opts, targets, installed, existingPlugins) {
311
311
  /**
312
312
  * The unified install entrypoint. Treats any source as a marketplace: clone or
313
313
  * read it, discover every plugin (ADG plus reverse-adapted native), choose a
314
- * subset (--all / --plugin / --path / sole plugin / interactive picker), then
314
+ * subset (--all / --plugin / sole plugin / interactive picker), then
315
315
  * install the selection in dependency-first order.
316
316
  */
317
317
  export async function addPlugins(opts) {
318
- const parsed = parseSource(opts.spec);
318
+ // Prepared checkouts are used only by remote marketplace update. Parse their
319
+ // persisted owner/repo key as GitHub even when the caller's CWD shadows it.
320
+ const parsed = opts.preparedSourceDir ? parseGitHubSource(opts.spec) : parseSource(opts.spec);
319
321
  const sourceRef = parsed.kind === "local" ? undefined : (opts.ref ?? parsed.ref);
320
- const inferredPath = parsed.kind === "github" ? parsed.path : undefined;
321
- const path = opts.path ?? inferredPath;
322
+ if (parsed.kind === "github" && parsed.path) {
323
+ throw new Error("GitHub subdirectory sources are not supported; define a marketplace and select with --plugin or --all");
324
+ }
322
325
  let workRoot;
323
326
  let buildOrigin;
324
327
  let resolvedRevision;
325
328
  let cleanup;
326
- if (parsed.kind === "local") {
329
+ let originDirOverride;
330
+ let definition;
331
+ let defaultDescription;
332
+ let structuralName;
333
+ if (opts.preparedSourceDir) {
334
+ workRoot = resolve(opts.preparedSourceDir);
335
+ resolvedRevision = opts.preparedResolvedRevision;
336
+ buildOrigin = (dir) => ({ type: "github", repo: parsed.kind === "github" ? parsed.source : opts.spec, ...(sourceRef ? { ref: sourceRef } : {}), path: toPosix(relative(workRoot, originDirOverride ?? dir)) || "." });
337
+ }
338
+ else if (parsed.kind === "local") {
327
339
  workRoot = resolve(parsed.dir);
328
- buildOrigin = (dir) => ({ type: "local", path: resolve(dir) });
340
+ buildOrigin = (dir) => ({ type: "local", path: resolve(originDirOverride ?? dir) });
329
341
  }
330
342
  else {
331
343
  const tmp = mkdtempSync(join(tmpdir(), "adg-clone-"));
@@ -337,15 +349,42 @@ export async function addPlugins(opts) {
337
349
  type: "github",
338
350
  repo: parsed.source,
339
351
  ...(sourceRef ? { ref: sourceRef } : {}),
340
- path: toPosix(relative(tmp, dir)) || ".",
352
+ path: toPosix(relative(tmp, originDirOverride ?? dir)) || ".",
341
353
  });
342
354
  }
343
355
  try {
344
- const { candidates, converted } = discoverPlugins(workRoot);
356
+ let { candidates, converted } = discoverPlugins(workRoot);
357
+ const existingLock = readLock(lockPath(opts.pluginsDir));
358
+ if (candidates.size > 0 && opts.as) {
359
+ throw new Error("--as is only supported for a default structural plugin source");
360
+ }
345
361
  if (candidates.size === 0) {
346
- throw new Error(`no plugin found in "${opts.spec}" (no .agents/.plugin.json, .claude-plugin or .codex-plugin manifest).`);
362
+ if (parsed.kind === "github" && !opts.preparedSourceDir && !opts.defaultDescription)
363
+ defaultDescription = await githubRepositoryDescription(parsed.source);
364
+ const structuralIdentity = opts.as ?? (parsed.kind === "github" ? parsed.source : basename(workRoot));
365
+ const generated = resolveDefaultDsl(workRoot, {
366
+ name: structuralIdentity,
367
+ description: defaultDescription ?? opts.defaultDescription ?? structuralIdentity,
368
+ });
369
+ const authorized = opts.authorizedComponents;
370
+ const unauthorizedRisk = generated.components.some((c) => (c === "hooks" || c === "mcp") && !authorized?.includes(c));
371
+ if (opts.nonInteractive && unauthorizedRisk && opts.only === undefined) {
372
+ throw new Error("default source exposes hooks or MCP; pass --only to explicitly authorize selected components");
373
+ }
374
+ const staging = mkdtempSync(join(tmpdir(), "adg-default-plugin-"));
375
+ copyPluginDir(workRoot, staging);
376
+ writeJson(join(staging, ADG_MANIFEST_PATH), generated.manifest);
377
+ candidates = scanPlugins(staging);
378
+ structuralName = generated.manifest.name;
379
+ converted = [];
380
+ originDirOverride = workRoot;
381
+ definition = { kind: "default-dsl/v1", root: ".", ...(opts.as ? { as: generated.manifest.name } : {}), description: generated.manifest.description, fingerprint: generated.fingerprint, authorizedComponents: authorized ?? (opts.only ?? generated.components) };
382
+ cleanup = (() => {
383
+ const prior = cleanup;
384
+ return () => { rmSync(staging, { recursive: true, force: true }); prior?.(); };
385
+ })();
347
386
  }
348
- const selected = await selectPluginNames({ ...opts, path }, candidates, workRoot, converted);
387
+ const selected = structuralName ? [structuralName] : await selectPluginNames(opts, candidates, converted);
349
388
  // Resolve adapter targets after the plugin choice (lets a CLI agent picker
350
389
  // run once we know what's being installed). undefined → installPlugin's all.
351
390
  const targets = opts.targets ?? (opts.selectTargets ? await opts.selectTargets() : undefined);
@@ -355,13 +394,19 @@ export async function addPlugins(opts) {
355
394
  // upstream: don't abort — return what the source still offers so the
356
395
  // caller can report the deletions.
357
396
  if (opts.missingPlugins === "skip") {
358
- const removed = reconcileRemotePlugins(opts, parsed, sourceRef, Boolean(path), new Set(selected));
397
+ const removed = reconcileRemotePlugins(opts, parsed, sourceRef, new Set(selected));
359
398
  return { order: [], installed: [], removed, converted, available };
360
399
  }
361
400
  throw new Error("no plugins selected");
362
401
  }
363
402
  // Partial-install selection per user-chosen plugin (auto-deps install full).
364
403
  const selections = await resolveSelections(opts, selected, candidates);
404
+ if (definition && structuralName) {
405
+ definition = {
406
+ ...definition,
407
+ authorizedComponents: selections.get(structuralName)?.components ?? definition.authorizedComponents,
408
+ };
409
+ }
365
410
  // Dependency-first order across every selected plugin (chains deduped).
366
411
  const order = [];
367
412
  const seen = new Set();
@@ -374,7 +419,14 @@ export async function addPlugins(opts) {
374
419
  }
375
420
  }
376
421
  }
377
- const removed = reconcileRemotePlugins(opts, parsed, sourceRef, Boolean(path), new Set(order));
422
+ // A generated Default DSL replay retains its definition profile. Only an
423
+ // explicit manifest discovered from the source may replace that profile.
424
+ const definitionSwitches = definition ? [] : order.filter((name) => existingLock.plugins[name]?.definition);
425
+ if (definitionSwitches.length > 0) {
426
+ const names = definitionSwitches.sort().map((name) => `"${name}"`).join(", ");
427
+ throw new Error(`source definition changed from default DSL to a manifest for ${names}; re-add or migrate the plugin explicitly`);
428
+ }
429
+ const removed = reconcileRemotePlugins(opts, parsed, sourceRef, new Set(order));
378
430
  // Snapshot which plugins already existed before this call mutates the lock,
379
431
  // so the activation step below can tell brand-new installs from updates.
380
432
  const existingPlugins = new Set(Object.keys(readLock(lockPath(opts.pluginsDir)).plugins));
@@ -391,6 +443,7 @@ export async function addPlugins(opts) {
391
443
  selection: selections.get(name),
392
444
  skipUnchanged: opts.skipUnchanged,
393
445
  now: opts.now,
446
+ definition: name === structuralName ? definition : undefined,
394
447
  }));
395
448
  }
396
449
  // Activate into the selected agents so the plugins are actually usable, not
@@ -1,3 +1,8 @@
1
+ import { gitRemoteRevision } from "../sources.js";
2
+ import { cloneGitHub, gitRevision, parseGitHubSource } from "../sources.js";
3
+ import { mkdtempSync, rmSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
1
6
  import { lockPath } from "../paths.js";
2
7
  import { readLock } from "../lock.js";
3
8
  import { addPlugins } from "./install.js";
@@ -113,26 +118,75 @@ export async function updatePlugins(opts) {
113
118
  const remoteAgents = [];
114
119
  for (const group of remoteGroups) {
115
120
  try {
116
- const { installed, available, agents } = await addPlugins({
117
- spec: group.source,
118
- pluginsDir: opts.pluginsDir,
119
- ref: group.ref,
120
- // Default: refresh what's installed. --all: also install anything new.
121
- ...(opts.all ? { all: true } : { plugins: group.installed }),
122
- missingPlugins: "skip", // an upstream deletion is reported, not fatal
123
- skipUnchanged: true, // detect-then-update: leave unchanged plugins alone
124
- targets: opts.targets,
125
- marketplaceName: group.source,
126
- gitRunner: opts.gitRunner,
127
- activate: opts.activate,
128
- scope: opts.agentScope,
129
- agents: opts.agents,
130
- deactivationAgents: opts.deactivationAgents,
131
- now,
121
+ const lock = readLock(lockPath(opts.pluginsDir));
122
+ const revisions = group.installed.map((name) => lock.plugins[name]?.resolvedRevision).filter((revision) => Boolean(revision));
123
+ const remoteRevision = (opts.revisionResolver ?? gitRemoteRevision)(group.source, group.ref);
124
+ if (!opts.all && remoteRevision && revisions.length === group.installed.length && revisions.every((revision) => revision === remoteRevision)) {
125
+ remote.push({ source: group.source, ...(group.ref ? { ref: group.ref } : {}), updated: [], unchanged: [...group.installed].sort(), deleted: [], available: [] });
126
+ continue;
127
+ }
128
+ const structural = group.installed.flatMap((name) => {
129
+ const definition = lock.plugins[name]?.definition;
130
+ return definition ? [{ name, definition, selection: lock.plugins[name]?.selection }] : [];
132
131
  });
133
- if (agents)
134
- remoteAgents.push(...agents);
135
- const availableSet = new Set(available);
132
+ const ordinary = group.installed.filter((name) => !lock.plugins[name]?.definition);
133
+ // A structural profile always describes the source root. Replay each
134
+ // profile independently so its stable --as identity is preserved.
135
+ const requests = [
136
+ ...structural.map(({ name, definition, selection }) => ({
137
+ plugins: [name],
138
+ as: definition.as,
139
+ defaultDescription: definition.description,
140
+ authorizedComponents: definition.authorizedComponents,
141
+ replaySelection: selection ?? (definition.authorizedComponents ? { components: definition.authorizedComponents } : undefined),
142
+ })),
143
+ // A structural profile represents the whole source root. Never append
144
+ // an --all fallback that could derive a second Default DSL identity.
145
+ ...(structural.length === 0 && (ordinary.length > 0 || opts.all)
146
+ ? [{ plugins: opts.all ? undefined : ordinary }]
147
+ : []),
148
+ ];
149
+ const installed = [];
150
+ const available = new Set();
151
+ const checkout = mkdtempSync(join(tmpdir(), "adg-marketplace-update-"));
152
+ try {
153
+ const parsed = parseGitHubSource(group.source);
154
+ cloneGitHub({ ...parsed, ref: group.ref }, checkout, { runner: opts.gitRunner });
155
+ const resolvedRevision = gitRevision(checkout);
156
+ for (const request of requests) {
157
+ const result = await addPlugins({
158
+ spec: group.source,
159
+ pluginsDir: opts.pluginsDir,
160
+ ref: group.ref,
161
+ ...(opts.all && request.plugins === undefined ? { all: true } : { plugins: request.plugins }),
162
+ missingPlugins: "skip",
163
+ skipUnchanged: true,
164
+ nonInteractive: true,
165
+ ...(request.authorizedComponents ? { authorizedComponents: request.authorizedComponents } : {}),
166
+ ...(request.replaySelection ? { replaySelection: request.replaySelection } : {}),
167
+ targets: opts.targets,
168
+ marketplaceName: group.source,
169
+ gitRunner: opts.gitRunner,
170
+ ...(request.as ? { as: request.as } : {}),
171
+ ...(request.defaultDescription ? { defaultDescription: request.defaultDescription } : {}),
172
+ activate: opts.activate,
173
+ scope: opts.agentScope,
174
+ agents: opts.agents,
175
+ deactivationAgents: opts.deactivationAgents,
176
+ now,
177
+ preparedSourceDir: checkout,
178
+ preparedResolvedRevision: resolvedRevision,
179
+ });
180
+ installed.push(...result.installed);
181
+ result.available.forEach((name) => available.add(name));
182
+ if (result.agents)
183
+ remoteAgents.push(...result.agents);
184
+ }
185
+ }
186
+ finally {
187
+ rmSync(checkout, { recursive: true, force: true });
188
+ }
189
+ const availableSet = available;
136
190
  const installedNow = new Set(installed.map((r) => r.name));
137
191
  remote.push({
138
192
  source: group.source,
@@ -140,7 +194,7 @@ export async function updatePlugins(opts) {
140
194
  updated: installed.filter((r) => r.changed).map((r) => r.name).sort(),
141
195
  unchanged: installed.filter((r) => !r.changed).map((r) => r.name).sort(),
142
196
  deleted: group.installed.filter((n) => !availableSet.has(n)).sort(),
143
- available: available.filter((n) => !installedNow.has(n) && !group.installed.includes(n)).sort(),
197
+ available: [...available].filter((n) => !installedNow.has(n) && !group.installed.includes(n)).sort(),
144
198
  });
145
199
  }
146
200
  catch (err) {
@@ -66,19 +66,21 @@ function migrateLock(pluginsDir, telemetrySpan) {
66
66
  if (!existsSync(file))
67
67
  return false;
68
68
  const raw = JSON.parse(readFileSync(file, "utf8"));
69
- if (!raw || typeof raw !== "object")
69
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
70
+ throw new Error(`${file} is not a valid lock file`);
71
+ if (Array.isArray(raw.plugins))
70
72
  throw new Error(`${file} is not a valid lock file`);
71
73
  if (raw.version === LOCK_VERSION)
72
74
  return false;
73
75
  if (typeof raw?.version === "number") {
74
- recordTelemetryEvent("adg.lock.read", { "format.version": raw.version === 2 || raw.version === 3 ? raw.version : -1 }, telemetrySpan);
76
+ recordTelemetryEvent("adg.lock.read", { "format.version": raw.version === 2 || raw.version === 3 || raw.version === 4 ? raw.version : -1 }, telemetrySpan);
75
77
  }
76
- if (raw.version === 3 && typeof raw.plugins === "object" && raw.plugins !== null) {
78
+ if ((raw.version === 3 || raw.version === 4) && typeof raw.plugins === "object" && raw.plugins !== null) {
77
79
  // v3 has the same payload model; v4 adds optional immutable provenance.
78
80
  // Existing remote entries remain explicitly legacy until an update/add
79
81
  // resolves their commit, rather than inventing a moving ref as a revision.
80
82
  writeLock(file, { ...raw, version: LOCK_VERSION });
81
- recordTelemetryEvent("adg.lock.migrate", { "from.version": 3, "to.version": LOCK_VERSION }, telemetrySpan);
83
+ recordTelemetryEvent("adg.lock.migrate", { "from.version": raw.version, "to.version": LOCK_VERSION }, telemetrySpan);
82
84
  return true;
83
85
  }
84
86
  if (raw.version !== 2 || typeof raw.plugins !== "object" || raw.plugins === null) {
@@ -1,9 +1,13 @@
1
- import { existsSync } from "node:fs";
2
- import { resolve } from "node:path";
1
+ import { existsSync, mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join, resolve } from "node:path";
3
4
  import { resolveAgents } from "../agents/index.js";
4
5
  import { installedPluginDir, lockPath, pluginSourceCacheDir } from "../paths.js";
5
6
  import { readLock } from "../lock.js";
6
7
  import { installPlugin } from "./install.js";
8
+ import { resolveDefaultDsl } from "../default-dsl.js";
9
+ import { ADG_MANIFEST_PATH } from "../manifest.js";
10
+ import { copyPluginDir, writeJson } from "../fsutil.js";
7
11
  /**
8
12
  * Refresh local sources and repair effective installations from their complete
9
13
  * source snapshots. Runtime installations are never treated as upstream input.
@@ -28,14 +32,49 @@ export function updateLock(pluginsDir, now = new Date().toISOString(), opts = {}
28
32
  missing.push(name);
29
33
  continue;
30
34
  }
31
- const result = installPlugin({
32
- source,
33
- pluginsDir,
34
- origin: entry.origin,
35
- selection: entry.selection,
36
- skipUnchanged: true,
37
- now,
38
- });
35
+ if (entry.definition && localSource && existsSync(join(localSource, ADG_MANIFEST_PATH))) {
36
+ throw new Error(`source definition changed from default DSL to a manifest for "${name}"; re-add or migrate the plugin explicitly`);
37
+ }
38
+ let installSource = source;
39
+ let staging;
40
+ let definition = entry.definition;
41
+ if (!existsSync(join(source, ADG_MANIFEST_PATH))) {
42
+ try {
43
+ const generated = resolveDefaultDsl(source, { name, description: entry.definition?.description ?? name });
44
+ const authorized = entry.definition?.authorizedComponents;
45
+ const unauthorizedRisk = generated.components.some((component) => (component === "hooks" || component === "mcp") && !authorized?.includes(component));
46
+ if (entry.definition && unauthorizedRisk) {
47
+ throw new Error(`default source exposes an unauthorized hook or MCP component for "${name}"; re-add the plugin with an explicit component selection`);
48
+ }
49
+ if (entry.definition)
50
+ definition = { ...entry.definition, description: generated.manifest.description, fingerprint: generated.fingerprint };
51
+ staging = mkdtempSync(join(tmpdir(), "adg-default-update-"));
52
+ copyPluginDir(source, staging);
53
+ writeJson(join(staging, ADG_MANIFEST_PATH), generated.manifest);
54
+ installSource = staging;
55
+ }
56
+ catch (error) {
57
+ if (!(error instanceof Error) || !error.message.includes("no default plugin component"))
58
+ throw error;
59
+ // Non-plugin local directories continue through the normal manifest path.
60
+ }
61
+ }
62
+ let result;
63
+ try {
64
+ result = installPlugin({
65
+ source: installSource,
66
+ pluginsDir,
67
+ origin: entry.origin,
68
+ selection: entry.selection ?? (entry.definition?.authorizedComponents ? { components: entry.definition.authorizedComponents } : undefined),
69
+ skipUnchanged: true,
70
+ now,
71
+ definition,
72
+ });
73
+ }
74
+ finally {
75
+ if (staging)
76
+ rmSync(staging, { recursive: true, force: true });
77
+ }
39
78
  if (result.changed)
40
79
  changedNames.push(name);
41
80
  results.push({
@@ -1,6 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { join } from "node:path";
2
+ import { basename, join } from "node:path";
3
3
  import { ADG_MANIFEST_PATH, collectIssues } from "../manifest.js";
4
+ import { resolveDefaultDsl } from "../default-dsl.js";
4
5
  /**
5
6
  * Validate a plugin's manifest against the ADG schema and check that the
6
7
  * directories/files it references actually exist.
@@ -8,7 +9,13 @@ import { ADG_MANIFEST_PATH, collectIssues } from "../manifest.js";
8
9
  export function validatePlugin(pluginDir) {
9
10
  const manifestFile = join(pluginDir, ADG_MANIFEST_PATH);
10
11
  if (!existsSync(manifestFile)) {
11
- return { ok: false, issues: [`${ADG_MANIFEST_PATH} not found in ${pluginDir}`] };
12
+ try {
13
+ resolveDefaultDsl(pluginDir, { name: basename(pluginDir), description: basename(pluginDir) });
14
+ return { ok: true, issues: [] };
15
+ }
16
+ catch (error) {
17
+ return { ok: false, issues: [error instanceof Error ? error.message : String(error)] };
18
+ }
12
19
  }
13
20
  let raw;
14
21
  try {
@@ -0,0 +1,140 @@
1
+ import { createHash } from "node:crypto";
2
+ import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { ADG_SCHEMA_VERSION } from "./types.js";
5
+ import { readSkillDescription } from "./skills.js";
6
+ import { recordTelemetryEvent } from "./telemetry.js";
7
+ /** Convert a repository directory name into the manifest's stable kebab-case identity. */
8
+ export function defaultPluginName(value) {
9
+ const normalized = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()
10
+ .replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
11
+ if (!normalized)
12
+ throw new Error("default plugin name is empty");
13
+ return normalized;
14
+ }
15
+ /**
16
+ * Resolve the intentionally small structural DSL. It only recognizes the three
17
+ * documented default locations; other directories are never guessed as runtime
18
+ * components.
19
+ */
20
+ export function resolveDefaultDsl(root, metadata, options = {}) {
21
+ const { components, manifest: componentManifest } = probeDefaultDsl(root, options);
22
+ const hasSkills = components.includes("skills");
23
+ const hasHooks = components.includes("hooks");
24
+ const hasMcp = components.includes("mcp");
25
+ const skillsRoot = join(root, "skills");
26
+ const mcpFile = join(root, ".mcp.json");
27
+ const hasher = createHash("sha256").update(JSON.stringify({ name: defaultPluginName(metadata.name), components }));
28
+ if (hasSkills)
29
+ hashTree(hasher, skillsRoot, "skills");
30
+ if (hasHooks)
31
+ hashTree(hasher, join(root, "hooks"), "hooks");
32
+ if (hasMcp)
33
+ hasher.update(".mcp.json\0").update(readFileSync(mcpFile)).update("\0");
34
+ const fingerprint = hasher.digest("hex");
35
+ if (options.recordTelemetry !== false) {
36
+ recordTelemetryEvent("adg.default_dsl.resolve", {
37
+ "definition.kind": "default-dsl/v1",
38
+ "components.count": components.length,
39
+ outcome: "success",
40
+ }, options.telemetrySpan);
41
+ }
42
+ return {
43
+ components,
44
+ fingerprint,
45
+ manifest: {
46
+ schemaVersion: ADG_SCHEMA_VERSION,
47
+ name: defaultPluginName(metadata.name),
48
+ version: `0.0.0-adg.${fingerprint}`,
49
+ description: metadata.description,
50
+ ...componentManifest,
51
+ },
52
+ };
53
+ }
54
+ /** Discover and validate conventional component locations without hashing payload contents. */
55
+ export function probeDefaultDsl(root, options = {}) {
56
+ const ignore = options.ignore ?? new Set();
57
+ const skillsRoot = join(root, "skills");
58
+ const skillFiles = !ignore.has("skills") && isDirectory(skillsRoot)
59
+ ? readdirSync(skillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && existsSync(join(skillsRoot, entry.name, "SKILL.md"))).map((entry) => join(skillsRoot, entry.name, "SKILL.md"))
60
+ : [];
61
+ const invalidSkillFile = skillFiles.find((file) => !isRegularFile(file));
62
+ if (invalidSkillFile)
63
+ throw new Error(`invalid default skill file (must be a regular file): ${invalidSkillFile}`);
64
+ const invalidSkill = skillFiles.find((file) => !readSkillDescription(file));
65
+ if (invalidSkill)
66
+ throw new Error(`default skill requires SKILL.md frontmatter with a description: ${invalidSkill}`);
67
+ const hasSkills = skillFiles.length > 0;
68
+ const hooksFile = join(root, "hooks", "hooks.json");
69
+ const hasHooks = !ignore.has("hooks") && existsSync(hooksFile) && validJson(hooksFile);
70
+ if (!ignore.has("hooks") && existsSync(hooksFile) && !hasHooks)
71
+ throw new Error(`invalid default hooks configuration: ${hooksFile}`);
72
+ const mcpFile = join(root, ".mcp.json");
73
+ const hasMcp = !ignore.has("mcp") && existsSync(mcpFile) && validMcp(mcpFile);
74
+ if (!ignore.has("mcp") && existsSync(mcpFile) && !hasMcp)
75
+ throw new Error(`invalid default MCP configuration: ${mcpFile}`);
76
+ const components = [
77
+ ...(hasSkills ? ["skills"] : []),
78
+ ...(hasHooks ? ["hooks"] : []),
79
+ ...(hasMcp ? ["mcp"] : []),
80
+ ];
81
+ if (components.length === 0)
82
+ throw new Error(`no default plugin component found in ${root}`);
83
+ return {
84
+ components,
85
+ manifest: {
86
+ ...(hasSkills ? { skills: "./skills/" } : { skills: [] }),
87
+ ...(hasHooks ? { hooks: "./hooks/" } : {}),
88
+ ...(hasMcp ? { mcpServers: "./.mcp.json" } : {}),
89
+ },
90
+ };
91
+ }
92
+ function validJson(file) {
93
+ if (!isRegularFile(file))
94
+ return false;
95
+ try {
96
+ JSON.parse(readFileSync(file, "utf8"));
97
+ return true;
98
+ }
99
+ catch {
100
+ return false;
101
+ }
102
+ }
103
+ function isDirectory(path) {
104
+ try {
105
+ return lstatSync(path).isDirectory();
106
+ }
107
+ catch {
108
+ return false;
109
+ }
110
+ }
111
+ function isRegularFile(path) {
112
+ try {
113
+ return lstatSync(path).isFile();
114
+ }
115
+ catch {
116
+ return false;
117
+ }
118
+ }
119
+ function validMcp(file) {
120
+ if (!validJson(file))
121
+ return false;
122
+ const json = JSON.parse(readFileSync(file, "utf8"));
123
+ if (json === null || typeof json !== "object" || Array.isArray(json))
124
+ return false;
125
+ const servers = json.mcpServers ?? json.servers;
126
+ return typeof servers === "object" && servers !== null && !Array.isArray(servers);
127
+ }
128
+ function hashTree(hasher, dir, rel) {
129
+ for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
130
+ const child = join(dir, entry.name);
131
+ const childRel = `${rel}/${entry.name}`;
132
+ const stat = lstatSync(child);
133
+ if (stat.isSymbolicLink())
134
+ throw new Error(`default plugin component must not contain symlinks: ${child}`);
135
+ if (stat.isDirectory())
136
+ hashTree(hasher, child, childRel);
137
+ else if (stat.isFile())
138
+ hasher.update(childRel).update("\0").update(readFileSync(child)).update("\0");
139
+ }
140
+ }
package/dist/src/lock.js CHANGED
@@ -10,25 +10,29 @@ export function readLock(file, telemetrySpan) {
10
10
  if (!existsSync(file))
11
11
  return emptyLock();
12
12
  const raw = JSON.parse(readFileSync(file, "utf8"));
13
- if (typeof raw?.version === "number") {
14
- const observed = raw.version === 2 || raw.version === 3 || raw.version === LOCK_VERSION ? raw.version : -1;
13
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
14
+ throw new Error(`${file} is not a valid .plugin-lock.json`);
15
+ }
16
+ const parsed = raw;
17
+ if (typeof parsed.version === "number") {
18
+ const observed = parsed.version === 2 || parsed.version === 3 || parsed.version === 4 || parsed.version === LOCK_VERSION ? parsed.version : -1;
15
19
  recordTelemetryEvent("adg.lock.read", { "format.version": observed }, telemetrySpan);
16
20
  }
17
- if (typeof raw.version !== "number" || typeof raw.plugins !== "object" || raw.plugins === null) {
21
+ if (typeof parsed.version !== "number" || typeof parsed.plugins !== "object" || parsed.plugins === null || Array.isArray(parsed.plugins)) {
18
22
  throw new Error(`${file} is not a valid .plugin-lock.json`);
19
23
  }
20
- if (raw.version === 3) {
21
- // Read compatibility for the immediately preceding format keeps runtime
24
+ if (parsed.version === 3 || parsed.version === 4) {
25
+ // Read compatibility for the retained v3 and v4 formats keeps runtime
22
26
  // adapters working before the user runs the explicit migration command.
23
- const upgraded = { ...raw, version: LOCK_VERSION };
24
- pendingLockMigrations.set(upgraded, 3);
27
+ const upgraded = { ...parsed, version: LOCK_VERSION };
28
+ pendingLockMigrations.set(upgraded, parsed.version);
25
29
  return upgraded;
26
30
  }
27
- if (raw.version !== LOCK_VERSION) {
28
- throw new Error(`${file} uses unsupported lock version ${raw.version}; expected ${LOCK_VERSION}. ` +
31
+ if (parsed.version !== LOCK_VERSION) {
32
+ throw new Error(`${file} uses unsupported lock version ${parsed.version}; expected ${LOCK_VERSION}. ` +
29
33
  "Run `adg plugins migrate` with the same scope flag to upgrade it.");
30
34
  }
31
- return raw;
35
+ return parsed;
32
36
  }
33
37
  export function writeLock(file, lock, telemetrySpan) {
34
38
  writeFileSync(file, JSON.stringify(lock, null, 2) + "\n");
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import { isAbsolute, join } from "node:path";
3
3
  import { ADG_SCHEMA_VERSION, COMPONENT_TYPES } from "./types.js";
4
4
  import { recordTelemetryEvent } from "./telemetry.js";
5
+ import { probeDefaultDsl } from "./default-dsl.js";
5
6
  /** Canonical, vendor-neutral source manifest location (a plugin). */
6
7
  export const ADG_MANIFEST_PATH = join(".agents", ".plugin.json");
7
8
  /** Canonical, vendor-neutral source catalog location (a marketplace). */
@@ -47,8 +48,31 @@ export function readManifest(pluginDir, telemetrySpan) {
47
48
  }
48
49
  if (typeof raw === "object" && raw !== null && !Array.isArray(raw)) {
49
50
  const m = raw;
50
- if (m.mcpServers === undefined && existsSync(join(pluginDir, ".mcp.json"))) {
51
- m.mcpServers = "./.mcp.json";
51
+ // A repository manifest is an explicit mapping only for fields it names.
52
+ // Standard skills/hooks/MCP locations remain the default DSL for omitted
53
+ // component fields, keeping source authors from repeating boilerplate.
54
+ if (typeof m.name === "string" && typeof m.description === "string") {
55
+ try {
56
+ const ignored = new Set();
57
+ if (m.skills !== undefined)
58
+ ignored.add("skills");
59
+ if (m.hooks !== undefined)
60
+ ignored.add("hooks");
61
+ if (m.mcpServers !== undefined)
62
+ ignored.add("mcp");
63
+ const defaults = probeDefaultDsl(pluginDir, { ignore: ignored }).manifest;
64
+ for (const key of ["skills", "hooks", "mcpServers"]) {
65
+ if (m[key] === undefined && defaults[key] !== undefined)
66
+ m[key] = defaults[key];
67
+ }
68
+ }
69
+ catch (error) {
70
+ // A manifest may use entirely custom locations and therefore have no
71
+ // conventional component. Any malformed conventional component that it
72
+ // *inherits*, however, is a source error and must never be hidden.
73
+ if (!(error instanceof Error) || !error.message.includes("no default plugin component"))
74
+ throw error;
75
+ }
52
76
  }
53
77
  const schemaVersion = m.schemaVersion;
54
78
  if (typeof schemaVersion === "string") {
@@ -4,6 +4,22 @@ import { join } from "node:path";
4
4
  import { readManifest, findManifestFile } from "./manifest.js";
5
5
  import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
6
6
  import { getTracer, sanitizeArgs } from "./telemetry.js";
7
+ /** Best-effort repository About lookup. Callers must retain their deterministic fallback on failure. */
8
+ export async function githubRepositoryDescription(repo) {
9
+ try {
10
+ const response = await fetch(`https://api.github.com/repos/${repo.split("/").map(encodeURIComponent).join("/")}`, {
11
+ headers: { Accept: "application/vnd.github+json", "User-Agent": "adg-cli" },
12
+ signal: AbortSignal.timeout(3000),
13
+ });
14
+ if (!response.ok)
15
+ return undefined;
16
+ const body = await response.json();
17
+ return typeof body.description === "string" && body.description.trim() ? body.description.trim() : undefined;
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ }
7
23
  const GH_SHORTHAND = /^([\w.-]+)\/([\w.-]+?)(?:@(.+))?$/;
8
24
  const GH_URL = /^(?:https?:\/\/github\.com\/|git@github\.com:)([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:@(.+))?$/;
9
25
  const GH_BLOB_URL = /^(?:https?:\/\/github\.com\/)([\w.-]+)\/([\w.-]+?)(?:\.git)?\/(?:blob|tree)\/([^/]+)\/(.+)$/;
@@ -40,6 +56,15 @@ function decodeGitHubUrlPart(value) {
40
56
  export function parseSource(spec) {
41
57
  if (existsSync(spec))
42
58
  return { kind: "local", dir: spec };
59
+ try {
60
+ return parseGitHubSource(spec);
61
+ }
62
+ catch {
63
+ throw new Error(`cannot parse install source: "${spec}" (expected a local path, owner/repo[@ref], or a github.com URL)`);
64
+ }
65
+ }
66
+ /** Parse a GitHub source without allowing an existing CWD path to override it. */
67
+ export function parseGitHubSource(spec) {
43
68
  const clean = spec.replace(/[?#].*$/, "");
44
69
  const blob = clean.match(GH_BLOB_URL);
45
70
  if (blob) {
@@ -58,7 +83,7 @@ export function parseSource(spec) {
58
83
  const [, owner, repo, ref] = short;
59
84
  return gh(owner, repo, ref);
60
85
  }
61
- throw new Error(`cannot parse install source: "${spec}" (expected a local path or owner/repo[@ref])`);
86
+ throw new Error(`cannot parse GitHub source: "${spec}" (expected owner/repo[@ref] or a github.com URL)`);
62
87
  }
63
88
  function gh(owner, repo, ref) {
64
89
  return {
@@ -142,6 +167,28 @@ export function gitRevision(dir) {
142
167
  return undefined;
143
168
  }
144
169
  }
170
+ const GIT_SHA_RE = /^[0-9a-f]{40}$/i;
171
+ /** Extract the commit SHA from `git ls-remote`, preferring an annotated tag's peeled ref. */
172
+ export function parseRemoteRevision(output, ref) {
173
+ if (!output)
174
+ return undefined;
175
+ const rows = output.split(/\r?\n/).map((line) => line.trim().split(/\s+/)).filter(([sha, name]) => GIT_SHA_RE.test(sha ?? "") && name);
176
+ const peeled = ref ? rows.find(([, name]) => name === `refs/tags/${ref}^{}`)?.[0] : undefined;
177
+ return peeled ?? rows[0]?.[0];
178
+ }
179
+ /** Lightweight remote commit probe used to avoid cloning an unchanged source. */
180
+ export function gitRemoteRevision(repo, ref) {
181
+ if (ref && GIT_SHA_RE.test(ref))
182
+ return ref.toLowerCase();
183
+ try {
184
+ const pattern = ref || "HEAD";
185
+ const output = runGit(["ls-remote", `https://github.com/${repo}.git`, pattern, `${pattern}^{}`], true);
186
+ return parseRemoteRevision(output, ref);
187
+ }
188
+ catch {
189
+ return undefined;
190
+ }
191
+ }
145
192
  /**
146
193
  * Recursively find ADG plugins under `root` (directories containing
147
194
  * `.agents/.plugin.json`, or the legacy `.adg-plugin/plugin.json`), keyed by
package/dist/src/types.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * ADG type definitions mirroring the JSON Schemas under ../schemas.
3
3
  */
4
4
  export const ADG_SCHEMA_VERSION = "adg.plugin/v1";
5
- export const LOCK_VERSION = 4;
5
+ export const LOCK_VERSION = 5;
6
6
  /** The component categories a plugin can expose. */
7
7
  export const COMPONENT_TYPES = ["skills", "agents", "commands", "mcp", "hooks", "apps"];
8
8
  /** Canonicalize user intent without adding derived component dependencies. */
@@ -80,7 +80,28 @@ are ADG-internal conventions, not declared in the manifest.
80
80
 
81
81
  ---
82
82
 
83
- ## 3. Packaging — manifest-driven allowlist
83
+ ## 3. Default directory DSL
84
+
85
+ When `.agents/.plugin.json` is absent, ADG recognizes only these fixed source
86
+ slots: `skills/<name>/SKILL.md`, `hooks/hooks.json`, and `.mcp.json`. At least
87
+ one valid slot is required. A skill needs non-empty frontmatter `description`;
88
+ hooks and MCP files must be valid JSON (MCP must contain an object of servers).
89
+
90
+ An explicit source manifest remains the only customization mechanism. Its
91
+ `skills`, `hooks`, and `mcpServers` fields replace the corresponding default
92
+ slot; omitted fields inherit valid defaults. A malformed inherited default slot
93
+ is an error, while an explicitly overridden slot is not interpreted. `--as` is
94
+ available only for structural sources. `--only` controls both copied payload and
95
+ runtime projection; non-interactive hooks/MCP discovery requires explicit
96
+ `--only`. Default DSL is source-root only.
97
+
98
+ Default DSL is deliberately **not** a monorepo discovery convention. A source
99
+ repository containing multiple plugins must declare every member with its own
100
+ `.agents/.plugin.json` (and may use `.agents/.marketplace.json` as its catalog).
101
+ Consumers select declared members with `--plugin` or `--all`; a source
102
+ subdirectory is never an install/inspect selector.
103
+
104
+ ## 4. Packaging — manifest-driven allowlist
84
105
 
85
106
  ADG first stores the complete declared payload in an internal source cache, then
86
107
  materializes an **effective installation** into the runtime-facing plugins
package/docs/authoring.md CHANGED
@@ -62,6 +62,23 @@ authoring artifact:
62
62
 
63
63
  ---
64
64
 
65
+ ## Conventional skills repositories
66
+
67
+ A repository may omit `.agents/.plugin.json` when it follows the fixed Default
68
+ DSL: `skills/<name>/SKILL.md`, `hooks/hooks.json`, and/or `.mcp.json`. ADG
69
+ derives one plugin only from the source root; it does not recursively guess
70
+ other directories.
71
+
72
+ Default DSL is not available to a member directory of a multi-plugin repository.
73
+ For a marketplace, give every member its own `.agents/.plugin.json`; consumers
74
+ select that explicit member with `--plugin` rather than by source subdirectory.
75
+
76
+ Add `.agents/.plugin.json` for non-standard paths or metadata. Its `skills`,
77
+ `hooks`, and `mcpServers` fields replace their respective defaults; omitted
78
+ fields inherit valid conventional locations. In automation, explicitly use
79
+ `--only` before enabling discovered hooks or MCP. Consumers may use `--as` only
80
+ when installing a manifest-free structural source.
81
+
65
82
  ## The `.agents/.plugin.json` DSL
66
83
 
67
84
  ```jsonc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbbtsn0w/adg",
3
- "version": "0.6.0-beta.7",
3
+ "version": "0.6.0-beta.8",
4
4
  "description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -7,7 +7,7 @@
7
7
  "required": ["version", "plugins"],
8
8
  "additionalProperties": false,
9
9
  "properties": {
10
- "version": { "type": "integer", "description": "Lock file format version.", "enum": [3, 4] },
10
+ "version": { "type": "integer", "description": "Lock file format version.", "enum": [3, 4, 5] },
11
11
  "plugins": {
12
12
  "type": "object",
13
13
  "additionalProperties": { "$ref": "#/$defs/lockEntry" }
@@ -45,6 +45,24 @@
45
45
  "enum": ["enabled", "disabled"],
46
46
  "description": "Desired cross-agent projection state. Absent means enabled."
47
47
  },
48
+ "definition": {
49
+ "type": "object",
50
+ "required": ["kind", "root", "description", "fingerprint"],
51
+ "additionalProperties": false,
52
+ "properties": {
53
+ "kind": { "const": "default-dsl/v1" },
54
+ "root": { "const": "." },
55
+ "as": { "type": "string" },
56
+ "description": { "type": "string" },
57
+ "fingerprint": { "type": "string" },
58
+ "authorizedComponents": {
59
+ "type": "array",
60
+ "items": { "enum": ["skills", "agents", "commands", "mcp", "hooks", "apps"] },
61
+ "uniqueItems": true,
62
+ "description": "Structural components explicitly authorized at install time."
63
+ }
64
+ }
65
+ },
48
66
  "dependencies": {
49
67
  "type": "object",
50
68
  "additionalProperties": { "type": "string" }