@rbbtsn0w/adg 0.3.0-beta.6 → 0.3.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.
|
@@ -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
|
|
269
|
-
|
|
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
|
}
|
|
@@ -108,13 +108,16 @@ export async function marketplaceUpgrade(opts) {
|
|
|
108
108
|
return results;
|
|
109
109
|
}
|
|
110
110
|
/** Merge per-agent sync results from several passes into one entry per agent. */
|
|
111
|
-
function mergeAgentResults(groups) {
|
|
111
|
+
export function mergeAgentResults(groups) {
|
|
112
112
|
const merged = new Map();
|
|
113
113
|
for (const r of groups.flat()) {
|
|
114
114
|
const existing = merged.get(r.agent);
|
|
115
115
|
if (existing) {
|
|
116
116
|
existing.affected = [...new Set([...existing.affected, ...r.affected])];
|
|
117
|
-
|
|
117
|
+
// Skipped only when EVERY pass skipped the agent (CLI absent throughout).
|
|
118
|
+
// If any pass ran, the agent was processed — matches addPlugins' merge so
|
|
119
|
+
// a skipped local rescan can't mask a successful remote re-activation.
|
|
120
|
+
existing.skipped = existing.skipped && r.skipped;
|
|
118
121
|
}
|
|
119
122
|
else {
|
|
120
123
|
merged.set(r.agent, { ...r, affected: [...r.affected] });
|
package/dist/src/render/ui.js
CHANGED
|
@@ -38,10 +38,14 @@ export function formatColumns(items, opts = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
/** Abbreviate the home-directory prefix of an absolute path to `~` (POSIX `/` or Windows `\`). */
|
|
40
40
|
export function abbrevHome(p) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// Compare with separators normalized to "/" so a forward-slash path still
|
|
42
|
+
// matches a backslash homedir() on Windows. Slicing the original `p` keeps
|
|
43
|
+
// its native separators in the abbreviated suffix (lengths are 1:1).
|
|
44
|
+
const home = homedir().replace(/\\/g, "/");
|
|
45
|
+
const normP = p.replace(/\\/g, "/");
|
|
46
|
+
if (normP === home)
|
|
43
47
|
return "~";
|
|
44
|
-
if (
|
|
48
|
+
if (normP.startsWith(home + "/"))
|
|
45
49
|
return "~" + p.slice(home.length);
|
|
46
50
|
return p;
|
|
47
51
|
}
|
package/dist/src/update-check.js
CHANGED
|
@@ -85,10 +85,14 @@ export function resolveLatestForChannel(currentVersion, distTags) {
|
|
|
85
85
|
export function scheduleUpdateCacheRefresh(currentVersion, env = process.env) {
|
|
86
86
|
try {
|
|
87
87
|
const req = https.get(REGISTRY_URL, { headers: { "User-Agent": `adg/${currentVersion}`, Accept: REGISTRY_ACCEPT } }, (res) => {
|
|
88
|
+
// Decode as UTF-8 at the stream level so multi-byte characters split
|
|
89
|
+
// across chunk boundaries are reassembled correctly (raw Buffers would
|
|
90
|
+
// corrupt them).
|
|
91
|
+
res.setEncoding("utf8");
|
|
88
92
|
let body = "";
|
|
89
93
|
let byteCount = 0;
|
|
90
94
|
res.on("data", (chunk) => {
|
|
91
|
-
byteCount += Buffer.byteLength(chunk);
|
|
95
|
+
byteCount += Buffer.byteLength(chunk, "utf8");
|
|
92
96
|
if (byteCount > MAX_RESPONSE_BYTES) {
|
|
93
97
|
// Oversized payload: stop reading and abort so we neither buffer
|
|
94
98
|
// unbounded memory nor parse a partial body.
|
|
@@ -96,7 +100,7 @@ export function scheduleUpdateCacheRefresh(currentVersion, env = process.env) {
|
|
|
96
100
|
req.destroy();
|
|
97
101
|
return;
|
|
98
102
|
}
|
|
99
|
-
body +=
|
|
103
|
+
body += chunk;
|
|
100
104
|
});
|
|
101
105
|
res.on("end", () => {
|
|
102
106
|
try {
|