@rbbtsn0w/adg 0.3.0-beta.6 → 0.3.0-beta.7

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.
@@ -243,6 +243,9 @@ export async function addPlugins(opts) {
243
243
  }
244
244
  }
245
245
  }
246
+ // Snapshot which plugins already existed before this call mutates the lock,
247
+ // so the activation step below can tell brand-new installs from updates.
248
+ const existingPlugins = new Set(Object.keys(readLock(lockPath(opts.pluginsDir)).plugins));
246
249
  const installed = [];
247
250
  for (const name of order) {
248
251
  const candidate = candidates.get(name);
@@ -265,8 +268,28 @@ export async function addPlugins(opts) {
265
268
  let agents;
266
269
  const toActivate = opts.skipUnchanged ? installed.filter((r) => r.changed) : installed;
267
270
  if (opts.activate && toActivate.length > 0) {
268
- const ctx = { pluginsDir: opts.pluginsDir, plugins: toActivate.map((r) => r.name), scope: opts.scope ?? "project" };
269
- agents = (opts.agents ?? resolveAgents(targets)).map((a) => a.activate(ctx));
271
+ const resolved = opts.agents ?? resolveAgents(targets);
272
+ const scope = opts.scope ?? "project";
273
+ const ctxFor = (names) => ({ pluginsDir: opts.pluginsDir, plugins: names, scope });
274
+ // A "changed" plugin is either brand new (no prior lock entry) or an update
275
+ // to an already-installed one. Only updates go through refresh — agents that
276
+ // cache a copy (Claude) must drop the stale one and re-pull. Brand-new
277
+ // plugins must use activate: refresh would issue an uninstall for something
278
+ // never installed, which warns/errors in those agents. On the add path
279
+ // (skipUnchanged off) everything is a fresh activate.
280
+ const activateNames = (opts.skipUnchanged ? toActivate.filter((r) => !existingPlugins.has(r.name)) : toActivate).map((r) => r.name);
281
+ const refreshNames = opts.skipUnchanged ? toActivate.filter((r) => existingPlugins.has(r.name)).map((r) => r.name) : [];
282
+ agents = resolved.map((a) => {
283
+ // An agent may run both lifecycles (new installs + updates) in one pass;
284
+ // merge into the existing affected/skipped contract so downstream report
285
+ // and consolidation (renderAgentReport, mergeAgentResults) stay unchanged.
286
+ const parts = [];
287
+ if (activateNames.length > 0)
288
+ parts.push(a.activate(ctxFor(activateNames)));
289
+ if (refreshNames.length > 0)
290
+ parts.push(a.refresh(ctxFor(refreshNames)));
291
+ return parts.reduce((acc, r) => ({ agent: r.agent, affected: [...acc.affected, ...r.affected], skipped: acc.skipped && r.skipped }), { agent: a.id, affected: [], skipped: true });
292
+ });
270
293
  }
271
294
  return { order, installed, converted, available: [...candidates.keys()], agents };
272
295
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbbtsn0w/adg",
3
- "version": "0.3.0-beta.6",
3
+ "version": "0.3.0-beta.7",
4
4
  "description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",