@mmerterden/multi-agent-pipeline 23.0.0 → 23.1.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.
@@ -25,6 +25,7 @@
25
25
  // node routine-share.mjs fetch --id <id>
26
26
  // node routine-share.mjs share --name <n> --visibility private|members|selected
27
27
  // [--logins a,b] [--base-version <n>] [--dry-run]
28
+ // node routine-share.mjs share --all --visibility private [--dry-run]
28
29
  // node routine-share.mjs import --id <id> --digest <digest> [--sha <sha256>] [--as <local name>]
29
30
  // node routine-share.mjs updates
30
31
  // node routine-share.mjs diff --name <local name>
@@ -37,6 +38,17 @@
37
38
  // must pass the host rule above; an override that does not is refused
38
39
  // (endpoint-not-allowed) before any request, never replaced by the default.
39
40
  //
41
+ // share --all publishes every saved routine this machine wrote, privately,
42
+ // in one run. It skips imported routines (source shared:...), every name this
43
+ // login already published (GET /api/routines, mine: true), so a bulk run never
44
+ // narrows a routine shared wider or bumps its version, and every routine whose
45
+ // payload or secret scan fails; the rest continue. It stops at the first 429
46
+ // (the server's hourly publish budget), leaving the remaining names
47
+ // not-attempted. results[] holds one row per saved routine: published,
48
+ // skipped (reason), failed (error), would-publish (dry run) or not-attempted.
49
+ // ok is false, error rate-limited or partial, when it stopped or a publish
50
+ // failed.
51
+ //
40
52
  // Output: one JSON document on stdout. {ok:false, error, ...} on refusal.
41
53
  // share, import, update and delete refuse under MULTI_AGENT_UNATTENDED=1, and
42
54
  // the guard blocks the same subcommands by name (unattended-policy.json).
@@ -77,6 +89,7 @@ const SHA_RE = /^[0-9a-f]{64}$/;
77
89
  const MAX_LOGINS = 50;
78
90
  const UNATTENDED_REFUSED = new Set(["share", "import", "update", "delete"]);
79
91
  const DIFF_CELL_LIMIT = 4_000_000;
92
+ const SHARED_SOURCE = "shared:";
80
93
 
81
94
  class Refusal extends Error {
82
95
  constructor(error, extra = {}) {
@@ -199,6 +212,10 @@ function payloadOf(routine) {
199
212
  return p;
200
213
  }
201
214
 
215
+ function isImported(entry) {
216
+ return String(entry?.source || "").startsWith(SHARED_SOURCE);
217
+ }
218
+
202
219
  function localVersion(entry) {
203
220
  const m = /@(\d+)$/.exec(entry?.source || "");
204
221
  return m ? Number(m[1]) : null;
@@ -206,7 +223,7 @@ function localVersion(entry) {
206
223
 
207
224
  function importedEntry(home, name) {
208
225
  const entry = listRoutines(home).find((r) => r.name === name);
209
- if (!entry || !entry.sharedId || !String(entry.source || "").startsWith("shared:")) {
226
+ if (!entry || !entry.sharedId || !isImported(entry)) {
210
227
  throw new Refusal("not-imported", { name });
211
228
  }
212
229
  return entry;
@@ -261,6 +278,91 @@ function parseLogins(text) {
261
278
  return list;
262
279
  }
263
280
 
281
+ /** The shareable payload of one routine, or the reason it may not be sent. */
282
+ function bulkCandidate(home, name, env) {
283
+ let payload;
284
+ try {
285
+ payload = exportRoutine(home, name);
286
+ } catch (err) {
287
+ if (err instanceof RoutineError) return { skip: { reason: "invalid", detail: err.message } };
288
+ throw err;
289
+ }
290
+ const problems = payloadProblems(payload);
291
+ if (problems.length) return { skip: { reason: problems[0], problems } };
292
+ const findings = scanPayload(home, payload, env);
293
+ if (findings.length) return { skip: { reason: "secret-detected", findings } };
294
+ return { payload };
295
+ }
296
+
297
+ async function shareAll(home, args, env) {
298
+ if (args.visibility !== "private")
299
+ throw new Refusal("invalid-visibility", { all: "private-only" });
300
+ for (const flag of ["name", "logins", "base-version"]) {
301
+ if (args[flag] !== undefined) throw new Refusal("invalid-flags", { flag });
302
+ }
303
+ const ctx = context(home, env);
304
+ const dryRun = Boolean(args["dry-run"]);
305
+ // The skip list is what keeps a bulk run from narrowing a routine already
306
+ // shared wider, so a response that is not a list stops the run.
307
+ const listing = await call(ctx, "GET", "");
308
+ if (!Array.isArray(listing?.routines))
309
+ throw new Refusal("upstream-inconsistent", { reason: "routine list unreadable" });
310
+ const mine = new Set(listing.routines.filter((r) => r?.mine === true).map((r) => r.name));
311
+ const results = [];
312
+ let stopped = null;
313
+ for (const entry of listRoutines(home)) {
314
+ const name = entry.name;
315
+ if (stopped) {
316
+ results.push({ name, status: "not-attempted" });
317
+ continue;
318
+ }
319
+ if (isImported(entry)) {
320
+ results.push({ name, status: "skipped", reason: "imported" });
321
+ continue;
322
+ }
323
+ if (mine.has(name)) {
324
+ results.push({ name, status: "skipped", reason: "already-published" });
325
+ continue;
326
+ }
327
+ const { payload, skip } = bulkCandidate(home, name, env);
328
+ if (skip) {
329
+ results.push({ name, status: "skipped", ...skip });
330
+ continue;
331
+ }
332
+ if (dryRun) {
333
+ results.push({
334
+ name,
335
+ status: "would-publish",
336
+ description: payload.description,
337
+ sha256: payload.sha256,
338
+ bytes: Buffer.byteLength(payload.body, "utf8"),
339
+ });
340
+ continue;
341
+ }
342
+ try {
343
+ const { routine } = await call(ctx, "POST", "", { ...payload, visibility: "private" });
344
+ results.push({ name, status: "published", id: routine?.id, version: routine?.version });
345
+ } catch (err) {
346
+ if (!(err instanceof Refusal)) throw err;
347
+ if (err.extra.status === 429) {
348
+ stopped = { error: "rate-limited", ...err.extra };
349
+ results.push({ name, status: "not-attempted" });
350
+ } else {
351
+ const { status: httpStatus, ...detail } = err.extra;
352
+ results.push({ name, ...detail, status: "failed", error: err.message, httpStatus });
353
+ }
354
+ }
355
+ }
356
+ const counts = {};
357
+ for (const r of results) counts[r.status] = (counts[r.status] ?? 0) + 1;
358
+ const failed = counts.failed > 0;
359
+ const report = { all: true, visibility: "private", counts, results };
360
+ if (dryRun) return { ok: true, dryRun: true, url: ctx.base, ...report };
361
+ if (stopped) return { ok: false, error: "rate-limited", stopped, ...report };
362
+ if (failed) return { ok: false, error: "partial", ...report };
363
+ return { ok: true, ...report };
364
+ }
365
+
264
366
  const commands = {
265
367
  async browse(home, args, env) {
266
368
  const ctx = context(home, env);
@@ -285,6 +387,7 @@ const commands = {
285
387
  },
286
388
 
287
389
  async share(home, args, env) {
390
+ if (args.all === true) return shareAll(home, args, env);
288
391
  const visibility = args.visibility;
289
392
  if (!VISIBILITIES.has(visibility)) throw new Refusal("invalid-visibility");
290
393
  const logins = parseLogins(args.logins);
@@ -321,9 +424,7 @@ const commands = {
321
424
  },
322
425
 
323
426
  async updates(home, _args, env) {
324
- const imported = listRoutines(home).filter(
325
- (r) => r.sharedId && String(r.source || "").startsWith("shared:"),
326
- );
427
+ const imported = listRoutines(home).filter((r) => r.sharedId && isImported(r));
327
428
  if (imported.length === 0) return { ok: true, updates: [], unavailable: [] };
328
429
  const { routines = [] } = await call(context(home, env), "GET", "");
329
430
  const byId = new Map(routines.map((r) => [r.id, r]));
@@ -232,6 +232,57 @@ function credHealth() {
232
232
  return { on, svc };
233
233
  }
234
234
 
235
+ export const MAX_SERVICES = 40;
236
+ const SERVICE_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._:@-]{0,63}$/;
237
+
238
+ function serverNames(config) {
239
+ const servers = config?.mcpServers;
240
+ return servers && typeof servers === "object" && !Array.isArray(servers)
241
+ ? Object.keys(servers)
242
+ : [];
243
+ }
244
+
245
+ /**
246
+ * Which apps this machine is connected to, by name only: every onboarded
247
+ * credential's logical key (kind "token"; connected while it is mapped and its
248
+ * last service check did not fail) and every MCP server registered with
249
+ * Claude Code (user scope and each project) or Copilot CLI (kind "mcp").
250
+ * Mapping values, server configs and paths are never read into the result,
251
+ * and a name that is not a plain identifier is dropped, so nothing but the
252
+ * key itself can leave. A missing or unparsable config adds nothing.
253
+ *
254
+ * @returns {{name: string, kind: "token"|"mcp", connected: boolean}[]}
255
+ */
256
+ export function machineServices({ globalPrefs, home = homedir() } = {}) {
257
+ const g = globalPrefs ?? resolveGlobalPrefs();
258
+ const out = [];
259
+ const seen = new Set();
260
+ const add = (name, kind, connected) => {
261
+ if (typeof name !== "string" || !SERVICE_NAME_RE.test(name)) return;
262
+ const key = `${kind}:${name}`;
263
+ if (seen.has(key) || out.length >= MAX_SERVICES) return;
264
+ seen.add(key);
265
+ out.push({ name, kind, connected });
266
+ };
267
+ const mapping = g?.keychainMapping;
268
+ const status = g?.serviceStatus ?? {};
269
+ if (mapping && typeof mapping === "object" && !Array.isArray(mapping)) {
270
+ for (const [name, value] of Object.entries(mapping)) {
271
+ const mapped = typeof value === "string" && value.trim() !== "";
272
+ add(name, "token", mapped && status?.[name]?.ok !== false);
273
+ }
274
+ }
275
+ const claude = readJson(join(home, ".claude.json"));
276
+ const mcp = [...serverNames(claude)];
277
+ const projects = claude?.projects;
278
+ if (projects && typeof projects === "object") {
279
+ for (const project of Object.values(projects)) mcp.push(...serverNames(project));
280
+ }
281
+ mcp.push(...serverNames(readJson(join(home, ".copilot", "mcp-config.json"))));
282
+ for (const name of mcp) add(name, "mcp", true);
283
+ return out;
284
+ }
285
+
235
286
  // A repo-local skill is named by whoever owns the repo, and a fallback toolkit
236
287
  // that the public marketplace does not carry is somebody's private plugin:
237
288
  // neither name is sent. Each is replaced by a constant naming its source, so
@@ -293,6 +344,7 @@ function deriveContext(state) {
293
344
  plug: enabledPlugins(state),
294
345
  apps: integrationTags(state),
295
346
  creds: credHealth(),
347
+ services: machineServices(),
296
348
  calls: invokedCalls(state),
297
349
  };
298
350
  }
@@ -744,6 +796,7 @@ function buildEvent(state, { event = null, login = null } = {}) {
744
796
  plug: ctx.plug,
745
797
  apps: ctx.apps,
746
798
  creds: ctx.creds,
799
+ services: ctx.services,
747
800
  calls: ctx.calls,
748
801
  errs: deriveErrors(state, spend.failed),
749
802
  v: packageVersion(),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": "1.0.0",
3
- "generatedAt": "2026-11-09T13:40:29Z",
3
+ "generatedAt": "2026-11-09T18:35:11Z",
4
4
  "skillCount": 255,
5
5
  "entries": [
6
6
  {
@@ -53,7 +53,7 @@
53
53
  },
54
54
  {
55
55
  "path": "shared/core/multi-agent-clean-disk/SKILL.md",
56
- "sha256": "714716431fe7aa30c3f0d79a384766d8fa055f4362d4f4c17b9e208983cd38cb"
56
+ "sha256": "a071ee9561eee7c313ed798dfb0f777093b3d8c77d95b6c743b513ef9b6cbebe"
57
57
  },
58
58
  {
59
59
  "path": "shared/core/multi-agent-complaint-analysis/SKILL.md",
@@ -229,7 +229,7 @@
229
229
  },
230
230
  {
231
231
  "path": "shared/core/multi-agent-routines-share/SKILL.md",
232
- "sha256": "0bfe1bb95811ae1305e0846c97634b6ec7fcab0988bb799b5dc664d0035c6c31"
232
+ "sha256": "690e081da3457c02e28b433003cfece50e0575620f0e5e4435bc9d6beb201614"
233
233
  },
234
234
  {
235
235
  "path": "shared/core/multi-agent-routines-update/SKILL.md",
@@ -529,7 +529,7 @@
529
529
  },
530
530
  {
531
531
  "path": "shared/external/disk-cleaner/SKILL.md",
532
- "sha256": "91028e79c5acd8aa76f899e80eb2b0a3605efaacdb102b13222651855df53fce"
532
+ "sha256": "d91086dc71747159e11218fbf1e46e33f6341a86bb13752a96f422204651bf27"
533
533
  },
534
534
  {
535
535
  "path": "shared/external/docker-expert/SKILL.md",
@@ -18,17 +18,22 @@ stops a process.
18
18
  2. Before asking anything, show per category its item count and size, its
19
19
  five largest items with real paths and sizes plus "and N more", and why
20
20
  items were kept or a category is blocked; then the total reclaimable,
21
- the free space now and the free space expected after. Reclaimable 0 B:
22
- stop.
21
+ the free space now and the free space expected after. Add one line each
22
+ when `held.aged` (items kept only for being touched recently, with
23
+ `held.agedBytes`) or `unreadable.count` (folders it could not read) is
24
+ above 0. Reclaimable 0 B: stop.
23
25
  3. Unattended: `node "$DC" --apply --unattended`, then report. Never ask.
24
26
  4. Attended, ask: all safe categories (the ones `--list` tags
25
27
  `unattended-safe`), choose categories, or none. Ask about the Trash on its
26
28
  own (it holds the user's files) and about old transcripts on their own
27
29
  (`/resume` and past-session search read them), each only when it measured
28
- above 0 B, each defaulting to keep. Nothing chosen changes nothing.
30
+ above 0 B, each defaulting to keep. When `held.aged` is above 0, ask on
31
+ its own whether to include the recently touched items, defaulting to
32
+ keep. Nothing chosen changes nothing.
29
33
  5. Skip list: every id from `node "$DC" --list` that was not chosen, without
30
34
  `trash` and `transcripts`. Run `node "$DC" --apply --skip="$SKIP"` plus
31
- `--trash` / `--transcripts` only when their own question chose them.
35
+ `--trash` / `--transcripts` / `--include-recent` only when their own
36
+ question chose them.
32
37
  6. Report removed and failed counts, `freed` with df before and after, every
33
38
  `held` and `failed` line, and the report path. Never retry a refused path
34
39
  with `rm` or a loop of your own.
@@ -2,7 +2,7 @@
2
2
  name: multi-agent-routines-share
3
3
  description: "Publish a saved routine to site members after a secret scan and a full preview. Use when asked to share a routine."
4
4
  user-invocable: true
5
- argument-hint: "<name>"
5
+ argument-hint: "[<name>] [--all]"
6
6
  metadata:
7
7
  language: en
8
8
  ---
@@ -21,9 +21,12 @@ ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
21
21
 
22
22
  ## Flow
23
23
 
24
- `$ARGUMENTS` is the local routine name. Empty: say a name is required, point to `/multi-agent:routines` for the list, and stop.
24
+ `$ARGUMENTS` is the local routine name, or `--all`. Empty: say a name or `--all` is required, point to `/multi-agent:routines` for the list, and stop.
25
25
 
26
- Read `$HOME/.claude/multi-agent-refs/features/routine-sharing.md` and follow its **share `<name>`** flow exactly, with `R` = `node "$HOME/.copilot/scripts/routine-share.mjs"`. The same file holds the credential, the payload limits and every exit code. Scan, ask for visibility, show the full request, publish only on an explicit publish answer. A secret-scan finding stops it; there is no override.
26
+ Read `$HOME/.claude/multi-agent-refs/features/routine-sharing.md` and follow its **share `<name>`** flow exactly, or its **share --all** flow when `$ARGUMENTS` is `--all`, with `R` = `node "$HOME/.copilot/scripts/routine-share.mjs"`. The same file holds the credential, the payload limits and every exit code.
27
+
28
+ - One name: scan, ask for visibility, show the full request, publish only on an explicit publish answer. A secret-scan finding stops it; there is no override.
29
+ - `--all`: one dry run, one preview listing every name with what will happen to it (publish privately, or skipped and why), one publish / cancel question. Publishing is always private; a name already published from this login, an imported routine and a routine with secret-scan findings are skipped and named, never sent.
27
30
 
28
31
  ## Notes
29
32
 
@@ -3,7 +3,7 @@ name: disk-cleaner
3
3
  description: "Frees macOS dev disk space by deleting regenerable data only (build output, caches, merged agent worktrees, old logs) after measuring, and lists orphaned session children without stopping them. Use when the disk is nearly full, a run hits ENOSPC, or the user asks to free space."
4
4
  metadata:
5
5
  source: multi-agent-pipeline
6
- version: 1.1.0
6
+ version: 1.2.0
7
7
  ---
8
8
 
9
9
  # Disk cleaner
@@ -47,14 +47,22 @@ running (Xcode, Simulator, a Gradle daemon) is measured but never applied.
47
47
  (`top`, 5 unless `--top=N`), how many it leaves out (`more`) and how many were
48
48
  kept per reason (`kept`), plus `reclaimableBytes`, `disk.expectedFreeBytes`
49
49
  and `orphans`, the leftover session processes it found. `--top=N` also lists
50
- the top items under each row of the text table.
50
+ the top items under each row of the text table. Simulator items carry the
51
+ device name (`label`).
52
+
53
+ `held` counts what was kept and measures it: `aged` and `agedBytes` are the
54
+ items kept only because they were touched recently (a build may still be
55
+ writing there), `live` the ones in use or belonging to the current session.
56
+ `unreadable` counts folders the scan could not read (permission denied); a
57
+ non-zero count means the report is incomplete, not that the disk is clean.
51
58
 
52
59
  ## 2. Decide what to apply
53
60
 
54
61
  | Situation | What runs |
55
62
  |---|---|
56
- | Attended | Show the table, then ask once which categories to apply. Default to every listed category except `archives` and `device-support`, which the user names explicitly. |
57
- | Unattended (autopilot, a scheduled job, `MULTI_AGENT_UNATTENDED=1`) | `--unattended --apply`. The script keeps to its safe set: no Trash, no transcripts, no worktrees, no archives, no device support. Never ask. |
63
+ | Attended | Show the table, then ask once which categories to apply. Default to every listed category except `archives`, `device-support` and `sim-runtimes`, which the user names explicitly. A deleted simulator runtime is downloaded again before that OS can run. |
64
+ | Unattended (autopilot, a scheduled job, `MULTI_AGENT_UNATTENDED=1`) | `--unattended --apply`. The script keeps to its safe set: no Trash, no transcripts, no worktrees, no archives, no device support, no simulator runtimes, no `--include-recent`. Never ask. |
65
+ | `held.aged` is above 0 and the user wants that space too | Add `--include-recent` after asking. Items in use and session scratch touched within `--scratch-hours`, which may belong to another open session, stay held at any age. |
58
66
  | The user asked to empty the Trash | Add `--trash`. Only on that explicit request. |
59
67
  | The user asked to delete old transcripts | Add `--transcripts` (older than `--transcript-days`, default 90). Past transcripts are searched for history, so this is opt-in and never the current session. |
60
68
  | The user asked to stop hanging sessions | Show the report's `orphans` list as information. The script never stops a process; stopping one is the user's own step. Live sessions are never listed. |
@@ -62,11 +70,15 @@ the top items under each row of the text table.
62
70
  Narrow a run with `--only=a,b` or `--skip=a,b`. Ages: `--log-days`
63
71
  (default 30), `--archive-days` (90), `--scratch-hours` (48),
64
72
  `--build-hours` (12, for in-repo `.build` and DerivedData and XCTest
65
- clones), `--orphan-minutes` (30). Extra dev roots for in-repo build output,
66
- `.DS_Store` and worktrees:
67
- `--root=<dir>`, repeatable. By default these are the git repos directly
68
- under `$HOME` and under `~/Developer`, `~/Projects`, `~/src`, `~/code`,
69
- `~/repos`, `~/work` and `~/git`.
73
+ clones), `--orphan-minutes` (30), `--runtime-days` (30, for simulator
74
+ runtimes; the newest runtime per platform and one backing a booted device
75
+ are kept at any age). Extra dev roots for in-repo build output, `.DS_Store`
76
+ and worktrees: `--root=<dir>`, repeatable, searched `--depth=N` levels deep
77
+ (8). By default these are the git repos directly under `$HOME` and under
78
+ `~/Developer`, `~/Projects`, `~/src`, `~/code`, `~/repos`, `~/work` and
79
+ `~/git`. A dev-root walk never enters `~/Library`, the Trash,
80
+ `~/Applications`, media libraries or the folders listed below.
81
+ `--exclude=<path>`, repeatable, keeps that path and any item holding it.
70
82
 
71
83
  ## 3. Apply
72
84