@mmerterden/multi-agent-pipeline 20.42.0 → 20.43.1

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +7 -5
  3. package/README.tr.md +7 -5
  4. package/docs/architecture.md +3 -3
  5. package/docs/ecosystem.md +6 -6
  6. package/docs/facts.json +5 -5
  7. package/manifest.json +45 -38
  8. package/package.json +1 -1
  9. package/pipeline/commands/multi-agent/clean-disk/SKILL.md +134 -0
  10. package/pipeline/commands/multi-agent/review-priority/SKILL.md +143 -0
  11. package/pipeline/commands/multi-agent/setup/SKILL.md +1 -1
  12. package/pipeline/commands/multi-agent/sync/SKILL.md +4 -4
  13. package/pipeline/commands/multi-agent/update/SKILL.md +21 -8
  14. package/pipeline/lib/low-disk.mjs +6 -5
  15. package/pipeline/multi-agent-refs/cross-cli-contract.md +5 -5
  16. package/pipeline/multi-agent-refs/features/doctor.md +17 -2
  17. package/pipeline/multi-agent-refs/features/review-priority.md +123 -0
  18. package/pipeline/multi-agent-refs/features/usage-reporting.md +45 -5
  19. package/pipeline/multi-agent-refs/help/en.md +2 -0
  20. package/pipeline/multi-agent-refs/help/tr.md +2 -0
  21. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +1 -1
  22. package/pipeline/multi-agent-refs/review-priority/rules/example.md +137 -0
  23. package/pipeline/office/toolkit.json +1 -1
  24. package/pipeline/schemas/prefs.schema.json +19 -1
  25. package/pipeline/schemas/toolkit-path-params.json +1 -1
  26. package/pipeline/scripts/capture-resume.sh +1 -1
  27. package/pipeline/scripts/disk-cleaner.mjs +77 -63
  28. package/pipeline/scripts/doctor.mjs +140 -10
  29. package/pipeline/scripts/priority-review.mjs +912 -0
  30. package/pipeline/scripts/usage-register.mjs +86 -9
  31. package/pipeline/skills/.skill-manifest.json +14 -6
  32. package/pipeline/skills/.skills-index.json +24 -2
  33. package/pipeline/skills/shared/README.md +6 -4
  34. package/pipeline/skills/shared/core/multi-agent-clean-disk/SKILL.md +34 -0
  35. package/pipeline/skills/shared/core/multi-agent-review-priority/SKILL.md +36 -0
  36. package/pipeline/skills/shared/core/multi-agent-setup/SKILL.md +1 -1
  37. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +4 -4
  38. package/pipeline/skills/shared/core/multi-agent-update/SKILL.md +11 -5
  39. package/pipeline/skills/shared/external/disk-cleaner/SKILL.md +10 -4
  40. package/pipeline/skills/shared/external/disk-cleaner/evals/evals.json +6 -6
  41. package/pipeline/skills/shared/external/disk-cleaner/scripts/disk-cleaner.mjs +77 -63
  42. package/pipeline/skills/skills-index.md +4 -2
@@ -140,11 +140,24 @@ is named after it, with no identity check, and finding no account later does not
140
140
  undo it (`decideRegistration`). So the personal account has to be reachable only
141
141
  once, at the moment of registration.
142
142
 
143
+ A pin holds only while its token works. When a token is stored,
144
+ `usage-register.mjs` first asks the server whether it still does (see "The
145
+ stored-token check" below). A token the server rejects counts as no token: the
146
+ machine registers again in the usual order (a proof first, else the stored
147
+ `usageLog.declaredLogin`, else the pinned `registeredAs` as a declared name),
148
+ with no question, and the new token overwrites the old one in its
149
+ credential-store entry. The same declared registration under `registeredAs`
150
+ runs when the pinned machine has no stored token at all.
151
+
143
152
  `usage-register.mjs --json` reports `needsPersonalAccount: true` only when the
144
153
  machine is not pinned, no account with access was found (no gh account, no
145
- credential-helper token, no SSH key) and no name was declared. Setup and update
146
- then ask once for the person's GitHub username (free text; Skip leaves
147
- reporting off) and run:
154
+ credential-helper token, no SSH key) and no name was declared. A stored
155
+ `declaredLogin` or a pinned `registeredAs` keeps it false. Setup and update
156
+ ask a question only in two cases: on `refusal: "not_collaborator"` they say in
157
+ one line that the name is not a collaborator and ask once for it again (a
158
+ second refusal leaves reporting off); otherwise, on `needsPersonalAccount:
159
+ true`, they ask once for the person's GitHub username (free text; Skip leaves
160
+ reporting off). Either way they run:
148
161
 
149
162
  ```bash
150
163
  node "$HOME/.claude/scripts/usage-register.mjs" --login "$GITHUB_LOGIN" --json
@@ -159,7 +172,11 @@ a token only for a collaborator (the repository owner registers with a proof),
159
172
  and marks its row `claimed:<machine>`. Later runs (the Phase 0 backstop) register a declared name
160
173
  the same way, without asking again. A name that is not a collaborator answers
161
174
  `not_collaborator` (the owner's name, `proof_required`) and is forgotten, so the
162
- next setup or update asks again once the repository owner has added it.
175
+ next setup or update asks again once the repository owner has added it. When
176
+ the refused name was registered under a token the server had rejected, the pin
177
+ (`registeredAs`) is dropped too, so the same run reports `needsPersonalAccount:
178
+ true`. A declared registration is usable as soon as it is issued; there is no
179
+ approval step.
163
180
 
164
181
  A declared name never replaces a proof: it is used only when the machine proves
165
182
  no account, and never over a stored token that was issued for a proven login
@@ -206,6 +223,29 @@ is read or any key is used. Redirects are not followed by any of the calls, so
206
223
  neither a GitHub token, a signature nor the ingest token can be carried to
207
224
  another host.
208
225
 
226
+ ### The stored-token check
227
+
228
+ `POST <register url>/check` with an empty JSON body and the stored ingest token
229
+ in the `x-usage-token` header, read from the credential store into memory and
230
+ never put on an argv, in a log or in the body. It goes only where the login
231
+ proof may go (the trusted-host rule above) and is never sent for an opted-out
232
+ machine, a token in `$MULTI_AGENT_USAGE_TOKEN` or `usageLog.token`, a dry run,
233
+ or a machine with no stored token. The timeout is 4 seconds.
234
+
235
+ | Answer | `tokenCheck` in `--json` | Effect |
236
+ |--------|--------------------------|--------|
237
+ | `200 { ok: true, valid: true, u, claimed }` | `valid` | the token is kept |
238
+ | `200 { ok: true, valid: false }` | `invalid` | treated as no token: register again, replace the stored token |
239
+ | `5xx`, any other status, no verdict, timeout, network failure, redirect | `unknown` | the token is kept (no churn on an outage) |
240
+ | not sent | `skipped` | unchanged behaviour |
241
+
242
+ A rejected token that cannot be replaced (no proof, no known name) leaves the
243
+ reason as `stored token rejected; <why>`, which `--quiet` prints on stderr.
244
+ `--json` also carries `refusal` (`not_collaborator` or `proof_required`) when
245
+ a declared name was refused for that reason.
246
+
247
+ ### Register answers
248
+
209
249
  | Answer | Status line |
210
250
  |--------|-------------|
211
251
  | `401` / `403` `login_mismatch` | the login that could not be confirmed (for gh: `gh auth status` must list it) |
@@ -404,5 +444,5 @@ counts failed calls per server, per tool and per class in the window (default
404
444
  24 hours). `doctor`'s `mcp-failures` check lights INFO for a server with five or
405
445
  more failures there; `invalid-input`, `denied` and `interrupted` are the
406
446
  caller's or the user's and never count toward it. Any `disk-full` row in the
407
- window also lights INFO with the disk-cleaner skill as its step, whatever the
447
+ window also lights INFO with `/multi-agent:clean-disk` as its step, whatever the
408
448
  count, because a full disk fails every server at once.
@@ -82,6 +82,7 @@ Status & Resume:
82
82
  /multi-agent:prune-logs Delete per-task project logs (audit + metrics kept; age/project/task filters, dry-run first)
83
83
  /multi-agent:prune-prompts Zero-base prompt review: measure always-on instruction footprint, propose keep/trial/delete per rule (report first, apply on approval)
84
84
  /multi-agent:garbage-collect Sweep run residue; --abandoned reaps stopped runs
85
+ /multi-agent:clean-disk Free disk space: measure every category, choose what to delete, apply, report the space freed
85
86
  /multi-agent:purge Worktree + logs - full reset (double confirm)
86
87
  /multi-agent:autopilot-on Continuous mode on this machine: pick repos, labelled items run to a PR
87
88
  /multi-agent:autopilot-status Running, queued, awaiting an answer, today's PRs
@@ -98,6 +99,7 @@ Post-Hoc & Side-Channel:
98
99
  /multi-agent:feedback "msg" Tell the maintainer something broke; only your text is sent
99
100
  /multi-agent:review Parallel review of a PR or branch diff; no URL -> pick open GitHub/Bitbucket PRs
100
101
  /multi-agent:review-jira Grade a Jira issue's pipeline-readiness -> comment the gaps on it
102
+ /multi-agent:review-priority Grade a team's open bug priorities against its rule file (read-only; one approved change at a time)
101
103
  /multi-agent:review-issue Grade a GitHub issue's pipeline-readiness -> comment the gaps on it
102
104
  /multi-agent:analysis ["name"] Feature-spec analysis (Figma + Swagger + Confluence + repos). Asks the standard first: global (23-section dev handoff) or corporate (IG→UC→FG requirements doc). Stack optional; References built from the evidence record
103
105
  /multi-agent:analysis-resolve [doc] Resolve Section 20 open questions of an analysis doc, one at a time with source-labeled candidates
@@ -81,6 +81,7 @@ Status & Resume:
81
81
  /multi-agent:prune-logs Task bazlı proje log'larını sil (audit + metrics korunur; yaş/proje/task filtresi, önce dry-run)
82
82
  /multi-agent:prune-prompts Sıfır-tabanlı prompt incelemesi: sürekli yüklü talimat yükünü ölç, kural başına tut/dene/sil öner (önce rapor, onayla uygula)
83
83
  /multi-agent:garbage-collect Koşu artığını süpür; --abandoned durmuş koşuları toplar
84
+ /multi-agent:clean-disk Disk alanı aç: her kategoriyi ölç, neyin silineceğini seç, uygula, açılan alanı raporla
84
85
  /multi-agent:purge Worktree + log'lar - tam reset (çift onay)
85
86
  /multi-agent:autopilot-on Bu makinede sürekli mod: repo seç, etiketli maddeler PR'a kadar koşar
86
87
  /multi-agent:autopilot-status Koşan, sıradaki, cevap bekleyen, bugünkü PR'lar
@@ -97,6 +98,7 @@ Post-Hoc & Side-Channel:
97
98
  /multi-agent:feedback "mesaj" Bakımcıya bir şeyin bozulduğunu bildir; yalnızca yazdığın metin gider
98
99
  /multi-agent:review PR veya branch diff'ini paralel review et; URL yoksa -> açık GitHub/Bitbucket PR'larını seçtir
99
100
  /multi-agent:review-jira Jira maddesinin pipeline'a hazırlığını değerlendir -> eksikleri yorum olarak ekle
101
+ /multi-agent:review-priority Ekibin açık bug priority'lerini kural dosyasına göre denetle (salt okur; her seferinde tek onaylı değişiklik)
100
102
  /multi-agent:review-issue GitHub issue'nun pipeline'a hazırlığını değerlendir -> eksikleri yorum olarak ekle
101
103
  /multi-agent:analysis ["analysis-name"] Feature-spec analizi (Figma + Swagger + Confluence + repolar). Önce standardı sorar: global (23 bölümlük geliştirme dokümanı) veya kurumsal (IG→UC→FG gereksinim dokümanı). Stack opsiyonel; Referanslar kanıt kaydından üretilir
102
104
  /multi-agent:analysis-resolve [doc] Analiz dokümanının Bölüm 20 açık sorularını kaynak etiketli adaylarla teker teker çözer
@@ -166,7 +166,7 @@ For each task (respecting dependency order), on start and on end: `bash $HOME/.c
166
166
  - **ios, fallback (raw)**: same lock pair around `xcodebuild build -scheme "{scheme}" -destination "generic/platform=iOS" -derivedDataPath "{worktreePath}/.DerivedData" 2>&1 | tail -5`.
167
167
  - **android**: lock pair around `./gradlew assembleDebug 2>&1 | tail -5` (the Gradle daemon and `build/` outputs contend across parallel worktrees exactly as DerivedData does - the lock applies).
168
168
  - **backend / web**: `python -m compileall .` / run the command `node $HOME/.claude/scripts/package-manager.mjs run --dir "{worktreePath}" --script build` prints, `2>&1 | tail -5` (exit 3: no build script); no lock.
169
- 5. If build fails → fix → rebuild (max 3 attempts, track `retryCount` in state). A failure that says `ENOSPC` or no space left is not a code defect, and retrying will not fix it: save the output and run `node $HOME/.claude/lib/low-disk.mjs --scan <log>`, print its line, and stop retrying. Attended, ask once whether to run the disk-cleaner skill; unattended, record the line and halt. Never delete anything from here.
169
+ 5. If build fails → fix → rebuild (max 3 attempts, track `retryCount` in state). A failure that says `ENOSPC` or no space left is not a code defect, and retrying will not fix it: save the output and run `node $HOME/.claude/lib/low-disk.mjs --scan <log>`, print its line, and stop retrying. Attended, ask once whether to run `/multi-agent:clean-disk`; unattended, record the line and halt. Never delete anything from here.
170
170
  6. **Intermediate commit** (after each completed task in the plan):
171
171
  ```bash
172
172
  git -C "{worktreePath}" add -A
@@ -0,0 +1,137 @@
1
+ ---
2
+ team: Example Team
3
+ slug: example
4
+ ---
5
+
6
+ # Example Team - priority rules
7
+
8
+ <!-- toc -->
9
+ - [Jira selection](#jira-selection)
10
+ - [Priority scale](#priority-scale)
11
+ - [Rules](#rules)
12
+ <!-- /toc -->
13
+
14
+ A starting point for `/multi-agent:review-priority`. Copy this file into the
15
+ rules directory as `<your-slug>.md`, set `team` and `slug`, and replace the
16
+ Jira selection with your own. The rules below describe an impact-based
17
+ priority model and can be kept as they are. The file format is described in
18
+ `multi-agent-refs/features/review-priority.md`.
19
+
20
+ ## Jira selection
21
+
22
+ The presets below use placeholder values: a project key `EXAMPLE` and a
23
+ component `Example Component`. `environment` is a standard Jira field; add the
24
+ fields your team records evidence in (environment, root cause, application)
25
+ to `evidenceFields`, keyed by field id.
26
+
27
+ ```json jira-selection
28
+ {
29
+ "base": "issuetype = Bug",
30
+ "default": "open",
31
+ "presets": [
32
+ {"id": "open", "label": "Example Team, open bugs",
33
+ "jql": "project = EXAMPLE AND statusCategory != Done"},
34
+ {"id": "component-open", "label": "Example Component only, open bugs",
35
+ "jql": "project = EXAMPLE AND component = \"Example Component\" AND statusCategory != Done"}
36
+ ],
37
+ "order": "priority DESC, created DESC",
38
+ "evidenceFields": {
39
+ "environment": "Environment"
40
+ }
41
+ }
42
+ ```
43
+
44
+ ## Priority scale
45
+
46
+ Critical > High > Medium > Low. Priority states how much damage the defect
47
+ does to the system, a workflow, the integrity of data and the people using
48
+ it. How soon it must be fixed is urgency, a separate question answered in the
49
+ description, a label or the release plan. A value outside these four is
50
+ reported as off the scale.
51
+
52
+ ## Rules
53
+
54
+ Each row: a rule id, what it implies for the level, what to look for in the
55
+ issue, and why.
56
+
57
+ ### Principles
58
+
59
+ | Id | Implies | Look for | Why |
60
+ |---|---|---|---|
61
+ | PRI-001 | Judge technical impact only | How badly the defect hurts the system, a workflow, data or users | Impact and urgency are separate axes |
62
+ | PRI-002 | Out of scope -> `insufficient` | The record is a task, a change request, an incident or a question rather than a defect found in testing | The model grades defects, nothing else |
63
+ | PRI-003 | Never raises the level | The text argues from a close release date, management attention, visibility to end users, a large fix, a team asking to go first, or a sprint goal | These change the order of work, not the damage |
64
+ | PRI-004 | Never raises the level | A release-blocker label or the words "release blocker" | Blocking a release is recorded separately; a Medium may block a release |
65
+ | PRI-005 | Never raises the level alone | The defect was seen in production | Where it was seen does not measure how much it hurts |
66
+ | PRI-006 | High or Critical possible | A single user is affected and cannot finish the action at all | Spread is one input; a complete stop for one user still counts |
67
+ | PRI-007 | One band lower | A workaround that people can actually keep using | A workaround that only works on paper does not lower the level |
68
+ | PRI-008 | Medium or High possible | A UI defect that misleads the user into a wrong action or breaks the main flow | A visual defect is not Low by default |
69
+ | PRI-009 | Judge by the data | A small symptom on screen while the data written, shown or sent is wrong | The data impact decides, not the size of the symptom |
70
+
71
+ ### Critical
72
+
73
+ | Id | Implies | Look for | Why |
74
+ |---|---|---|---|
75
+ | PRI-010 | Critical | The system or a core flow cannot be used; the main path stops or keeps failing | Nothing of value can be done |
76
+ | PRI-011 | Critical | A core business function cannot complete: taking a payment, signing in or authenticating, creating an order or a booking | These functions are what the product exists for |
77
+ | PRI-012 | Critical | A crash, errors that do not stop, or corrupted data (wrong amounts, wrong records) | Damage spreads beyond the screen |
78
+ | PRI-013 | Critical | A security, legal or reputational exposure (a required check skipped, personal data visible) | The risk is outside the product's own walls |
79
+ | PRI-014 | Needed for Critical | No workaround that is workable and lasting, and no other way through | With a workable route the damage is contained |
80
+ | PRI-015 | Not Critical on its own | One secondary area is wrong while the product works; the user can finish another way; a narrow group with little spread | Real, but contained |
81
+
82
+ ### High
83
+
84
+ | Id | Implies | Look for | Why |
85
+ |---|---|---|---|
86
+ | PRI-020 | High | The main function can be reached but works badly; a step inside the main flow is seriously broken | The flow exists but cannot be relied on |
87
+ | PRI-021 | High | The flow completes but adds operational work, delay or a clearly worse experience | The cost is paid on every use |
88
+ | PRI-022 | High | It happens often and to many people | Frequency and reach multiply the impact |
89
+ | PRI-023 | High | A workaround exists but it is manual, complicated or cannot be kept up; an action succeeds only on a retry or by another route | The user carries the cost of the defect |
90
+ | PRI-024 | Not High on its own | Only a text or an icon is wrong; a rare validation mismatch with little effect | Too small to degrade the function |
91
+
92
+ ### Medium
93
+
94
+ | Id | Implies | Look for | Why |
95
+ |---|---|---|---|
96
+ | PRI-030 | Medium | The function works but departs from the business rules in a way that matters (a wrong message while the action continues, results in the wrong order) | Correctness suffers while the work gets done |
97
+ | PRI-031 | Medium | The flow continues with a workaround (an action that fails once and succeeds when repeated) | Annoying, recoverable |
98
+ | PRI-032 | Medium | Only under specific conditions (a region, a device, a sequence of steps) and with limited effect | Narrow and contained |
99
+ | PRI-033 | Medium | A functional effect while the system as a whole keeps working | Real impact, no breakdown |
100
+ | PRI-034 | Not Medium on its own | A spelling mistake with no functional effect | Cosmetic |
101
+
102
+ ### Low
103
+
104
+ | Id | Implies | Look for | Why |
105
+ |---|---|---|---|
106
+ | PRI-040 | Low | A visual, wording or usability finding while the action completes | The outcome is right |
107
+ | PRI-041 | Low | Design, alignment or labelling work that does not change the functional result | An improvement, not a failure |
108
+ | PRI-042 | Never Low | The user cannot complete the action, or needs a workaround to do so | That is a functional failure |
109
+
110
+ ### Decision order and evidence
111
+
112
+ | Id | Implies | Look for | Why |
113
+ |---|---|---|---|
114
+ | PRI-050 | Order of evaluation | 1. Is it really a defect, not missing data, misuse or the environment? 2. Which flow: the main one, a side one, one segment? 3. Can the flow complete? 4. Is there a workaround, and does it hold up in practice? 5. Is there data loss, money, security, regulatory or operational risk? 6. Choose the level; note urgency and release impact separately | Each answer narrows the next |
115
+ | PRI-060 | Missing items -> `insufficient` | The record should state the affected flow, the spread (everyone, a segment, a device, a channel), the real impact, the workaround if any, and the release or production risk as its own note | Without them the steps above cannot run |
116
+ | PRI-061 | Consistency | Similar earlier records were given the same level | One defect, one level, whoever files it |
117
+
118
+ ### Triage checklist
119
+
120
+ | Id | Implies | Look for | Why |
121
+ |---|---|---|---|
122
+ | PRI-080 | Ask before settling | Is it a defect? Which flow? Does it complete? Is the workaround real? What is at risk? Does a similar record exist? Is urgency written apart from the level? | The same questions every time keep levels comparable |
123
+
124
+ ### Decision matrix
125
+
126
+ | Id | Situation | Spread | Workaround | Implies |
127
+ |---|---|---|---|---|
128
+ | PRI-070 | Nobody can sign in | Everyone | None | Critical |
129
+ | PRI-071 | A payment fails on the first attempt and goes through on a retry | Wide | Yes | High |
130
+ | PRI-072 | A field is validated wrongly on some devices; the flow still completes | Limited | Not needed | Medium |
131
+ | PRI-073 | A typo or an alignment problem; the flow completes | Any | Not needed | Low |
132
+
133
+ ### Roles
134
+
135
+ | Id | Implies | Why |
136
+ |---|---|---|
137
+ | PRI-090 | The review proposes; people decide | The tester sets the first level from impact, a developer does not change it alone, product and analysis add business context, and triage keeps levels consistent. The review is input to that triage |
@@ -1,3 +1,3 @@
1
1
  {
2
- "toolkitVersion": "3.32.0"
2
+ "toolkitVersion": "3.32.1"
3
3
  }
@@ -1518,7 +1518,7 @@
1518
1518
  "diskCleaner": {
1519
1519
  "type": "object",
1520
1520
  "additionalProperties": false,
1521
- "description": "When the ecosystem suggests the disk-cleaner skill. lib/low-disk.mjs reads these with one statfs call from doctor's disk-space check, the SessionStart banner and the pre-push gate's failure path, and prints one line naming the skill. The suggestion never deletes anything.",
1521
+ "description": "When the ecosystem suggests /multi-agent:clean-disk. lib/low-disk.mjs reads these with one statfs call from doctor's disk-space check, the SessionStart banner and the pre-push gate's failure path, and prints one line naming the command. The suggestion never deletes anything.",
1522
1522
  "properties": {
1523
1523
  "lowDiskGb": {
1524
1524
  "type": "number",
@@ -1537,6 +1537,24 @@
1537
1537
  "type": "boolean",
1538
1538
  "default": true,
1539
1539
  "description": "false silences the suggestion everywhere, including after a disk-full failure."
1540
+ },
1541
+ "reclaimableGb": {
1542
+ "type": "number",
1543
+ "minimum": 0,
1544
+ "default": 10,
1545
+ "description": "doctor's disk-space check names /multi-agent:clean-disk when the newest disk-cleaner dry run (under a day old) found at least this many gigabytes to free, even with enough free space."
1546
+ }
1547
+ }
1548
+ },
1549
+ "reviewPriority": {
1550
+ "type": "object",
1551
+ "additionalProperties": false,
1552
+ "description": "Where /multi-agent:review-priority reads team rule files. scripts/priority-review.mjs reads it; run data goes to runs/ beside the rules directory.",
1553
+ "properties": {
1554
+ "rulesDir": {
1555
+ "type": "string",
1556
+ "default": "~/.claude/routine-assets/review-priority/rules",
1557
+ "description": "Directory holding one <slug>.md rule file per team. A leading ~ is the home directory. Unset means the default."
1540
1558
  }
1541
1559
  }
1542
1560
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$comment": "Generated by pipeline/scripts/gen-toolkit-path-params.mjs from multi-agent-toolkit-mcp tool-manifest.json; do not edit. Per toolkit tool: the parameters it writes to and the filesystem paths it reads, both confined by scripts/unattended_policy.py.",
3
- "toolkitVersion": "3.32.0",
3
+ "toolkitVersion": "3.32.1",
4
4
  "tools": {
5
5
  "agent_query_output": {
6
6
  "writes": [],
@@ -18,7 +18,7 @@
18
18
  # last review, with at least one open observation.) Offer one line. The
19
19
  # user's own work is never made to wait on it.
20
20
  # - Is the disk nearly full? lib/low-disk.mjs answers with one statfs call
21
- # and, when it is, one line naming the disk-cleaner skill. Nothing is
21
+ # and, when it is, one line naming /multi-agent:clean-disk. Nothing is
22
22
  # deleted from here.
23
23
  #
24
24
  # Usage: ./capture-resume.sh [--json]
@@ -21,11 +21,13 @@
21
21
  * - never a file the user does not own, and never a path an open file
22
22
  * handle or a running command line points into
23
23
  *
24
- * Transcripts and the Trash are opt-in (--transcripts, --trash). Orphaned
25
- * session children are only reported unless --apply --processes is given.
26
- * Unattended runs (--unattended or MULTI_AGENT_UNATTENDED=1) keep to
27
- * UNATTENDED_SAFE and never touch the Trash, transcripts, processes,
28
- * worktrees, archives or device support.
24
+ * The Trash and old session transcripts are opt-in (--trash, --transcripts):
25
+ * the Trash holds the user's own files, and resume and past-session search
26
+ * read the transcripts. Processes are never stopped: orphaned children of
27
+ * ended sessions are listed in the report under `orphans` as information, and
28
+ * nothing here can signal a process. Unattended runs (--unattended or
29
+ * MULTI_AGENT_UNATTENDED=1) keep to UNATTENDED_SAFE and never touch the Trash,
30
+ * transcripts, worktrees, archives or device support.
29
31
  *
30
32
  * Deletion uses fs.rmSync, which unlinks a symlink instead of entering it.
31
33
  * Pipeline scratch under /tmp and per-task pipeline logs are delegated to
@@ -34,11 +36,18 @@
34
36
  *
35
37
  * Usage:
36
38
  * disk-cleaner.mjs [--dry-run] [--apply] [--only=a,b] [--skip=a,b]
37
- * [--trash] [--transcripts] [--processes] [--unattended]
39
+ * [--trash] [--transcripts] [--unattended]
38
40
  * [--log-days=N] [--archive-days=N] [--transcript-days=N]
39
41
  * [--scratch-hours=N] [--build-hours=N] [--orphan-minutes=N]
40
42
  * [--root=DIR]... [--tmp-root=DIR]... [--home=DIR]
41
- * [--report=FILE] [--json] [--list]
43
+ * [--report=FILE] [--json] [--list] [--top=N]
44
+ *
45
+ * Every category in the JSON report carries `top` (its largest items, real
46
+ * paths and sizes, 5 unless --top says otherwise), `more` (how many items
47
+ * `top` leaves out) and `kept` (how many items were kept, per reason). The
48
+ * report also carries `reclaimableBytes` (categories whose tool is running
49
+ * are measured but left out) and `disk.expectedFreeBytes`. --top=N also lists
50
+ * the top items under each row of the text table.
42
51
  *
43
52
  * Exit: 0 done, 1 one or more deletions failed, 2 usage error.
44
53
  *
@@ -61,11 +70,12 @@ import { homedir, tmpdir } from "node:os";
61
70
  import { basename, dirname, join, sep } from "node:path";
62
71
  import { fileURLToPath, pathToFileURL } from "node:url";
63
72
 
64
- export const VERSION = "1.0.0";
73
+ export const VERSION = "1.1.0";
65
74
  const DAY_MS = 86_400_000;
66
75
  const HOUR_MS = 3_600_000;
67
76
  const MAX_WALK_DEPTH = 8;
68
77
  const KEEP_REPORTS = 20;
78
+ const DEFAULT_TOP = 5;
69
79
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
70
80
 
71
81
  /** Folders under $HOME that hold the user's own files or secrets. */
@@ -280,7 +290,6 @@ export function makeContext(o = {}) {
280
290
  tmpGraceMinutes: o.tmpGraceMinutes ?? 120,
281
291
  orphanMinutes: o.orphanMinutes ?? 30,
282
292
  run: o.run || realRun,
283
- kill: o.kill || ((pid) => process.kill(pid, "SIGTERM")),
284
293
  du: o.du || duBytes,
285
294
  ps: () => (psCache ??= (o.ps || realPs)()),
286
295
  openPaths: () =>
@@ -706,6 +715,16 @@ function transcriptCandidates(ctx, out) {
706
715
  }
707
716
  }
708
717
 
718
+ /** Orphaned session children, for the report only: pid and command, nothing to act on. */
719
+ export function listOrphans(ctx) {
720
+ const rows = ctx.ps();
721
+ return findOrphans(rows, {
722
+ uid: ctx.uid,
723
+ minAgeSec: ctx.orphanMinutes * 60,
724
+ selfChain: selfChain(rows),
725
+ }).map((r) => ({ pid: r.pid, command: r.command }));
726
+ }
727
+
709
728
  function selfChain(rows) {
710
729
  const parent = new Map(rows.map((r) => [r.pid, r.ppid]));
711
730
  const chain = new Set();
@@ -985,27 +1004,6 @@ export const CATEGORIES = [
985
1004
  optIn: "transcripts",
986
1005
  discover: transcriptCandidates,
987
1006
  },
988
- {
989
- id: "processes",
990
- label: "orphaned children of ended Claude or Codex sessions",
991
- unattended: false,
992
- discover(ctx, out) {
993
- const rows = ctx.ps();
994
- for (const r of findOrphans(rows, {
995
- uid: ctx.uid,
996
- minAgeSec: ctx.orphanMinutes * 60,
997
- selfChain: selfChain(rows),
998
- })) {
999
- out.candidates.push({
1000
- kind: "process",
1001
- pid: r.pid,
1002
- path: `pid ${r.pid}: ${r.command}`,
1003
- command: r.command,
1004
- bytes: 0,
1005
- });
1006
- }
1007
- },
1008
- },
1009
1007
  ];
1010
1008
 
1011
1009
  export const UNATTENDED_SAFE = new Set(CATEGORIES.filter((c) => c.unattended).map((c) => c.id));
@@ -1073,19 +1071,6 @@ function removeWorktree(ctx, c) {
1073
1071
  return r.status === 0 ? { ok: true } : { ok: false, reason: r.stderr.trim() || "git refused" };
1074
1072
  }
1075
1073
 
1076
- function stopProcess(ctx, c) {
1077
- const now = ctx.ps().find((r) => r.pid === c.pid);
1078
- if (!now || now.ppid !== 1 || now.command !== c.command) {
1079
- return { ok: false, reason: "process changed or exited" };
1080
- }
1081
- try {
1082
- ctx.kill(c.pid);
1083
- return { ok: true };
1084
- } catch (e) {
1085
- return { ok: false, reason: e.code || "kill failed" };
1086
- }
1087
- }
1088
-
1089
1074
  function runDelegate(ctx, tool, items) {
1090
1075
  const listFile = join(tmpdir(), `disk-cleaner-${tool}-${process.pid}-${Date.now()}.txt`);
1091
1076
  try {
@@ -1113,12 +1098,11 @@ function runDelegate(ctx, tool, items) {
1113
1098
 
1114
1099
  /**
1115
1100
  * Delete what `planned` lists. Every path passes the guard again first, a
1116
- * worktree is re-checked for changes, and a process is re-read before it is
1117
- * signalled.
1101
+ * worktree is re-checked for changes.
1118
1102
  */
1119
- export function applyPlan(ctx, planned, opts = {}) {
1103
+ export function applyPlan(ctx, planned) {
1120
1104
  ctx.resetProbes?.();
1121
- const result = { removed: 0, failed: 0, stopped: 0, failures: [], held: [] };
1105
+ const result = { removed: 0, failed: 0, failures: [], held: [] };
1122
1106
  for (const cat of planned.categories) {
1123
1107
  const def = CATEGORIES.find((c) => c.id === cat.id);
1124
1108
  if (cat.blocked || (def?.blocker && processRunning(ctx, def.blocker[0]))) {
@@ -1133,13 +1117,6 @@ export function applyPlan(ctx, planned, opts = {}) {
1133
1117
  else if (c.kind === "command") {
1134
1118
  const x = ctx.run(c.cmd, c.args, { timeout: 600_000 });
1135
1119
  r = x.status === 0 ? { ok: true } : { ok: false, reason: `${c.cmd} exited ${x.status}` };
1136
- } else if (c.kind === "process") {
1137
- if (!opts.processes) continue;
1138
- r = stopProcess(ctx, c);
1139
- if (r.ok) {
1140
- result.stopped++;
1141
- continue;
1142
- }
1143
1120
  } else if (c.kind === "delegate") {
1144
1121
  if (!delegates.has(c.tool)) delegates.set(c.tool, []);
1145
1122
  delegates.get(c.tool).push(c);
@@ -1183,7 +1160,6 @@ function parseCli(argv) {
1183
1160
  break;
1184
1161
  case "--trash":
1185
1162
  case "--transcripts":
1186
- case "--processes":
1187
1163
  case "--unattended":
1188
1164
  case "--json":
1189
1165
  case "--list":
@@ -1211,18 +1187,21 @@ function parseCli(argv) {
1211
1187
  case "--archive-days":
1212
1188
  o.archiveDays = num(k, v);
1213
1189
  break;
1214
- case "--transcript-days":
1215
- o.transcriptDays = num(k, v);
1216
- break;
1217
1190
  case "--scratch-hours":
1218
1191
  o.scratchHours = num(k, v);
1219
1192
  break;
1220
1193
  case "--build-hours":
1221
1194
  o.buildHours = num(k, v);
1222
1195
  break;
1196
+ case "--transcript-days":
1197
+ o.transcriptDays = num(k, v);
1198
+ break;
1223
1199
  case "--orphan-minutes":
1224
1200
  o.orphanMinutes = num(k, v);
1225
1201
  break;
1202
+ case "--top":
1203
+ o.top = num(k, v);
1204
+ break;
1226
1205
  case "-h":
1227
1206
  case "--help":
1228
1207
  o.help = true;
@@ -1259,7 +1238,24 @@ function writeReport(file, data) {
1259
1238
  for (const p of old) rmSync(p, { force: true });
1260
1239
  }
1261
1240
 
1262
- function printPlan(p, mode, disk) {
1241
+ /** The largest items of a category, how many are left out, and why items were kept. */
1242
+ export function categorySummary(c, top = DEFAULT_TOP) {
1243
+ const sorted = [...c.candidates].sort((a, b) => (b.bytes || 0) - (a.bytes || 0));
1244
+ const kept = {};
1245
+ for (const k of c.skipped) kept[k.reason] = (kept[k.reason] || 0) + 1;
1246
+ return {
1247
+ top: sorted.slice(0, top).map((x) => ({ path: x.path, bytes: x.bytes, kind: x.kind })),
1248
+ more: Math.max(0, sorted.length - top),
1249
+ kept,
1250
+ };
1251
+ }
1252
+
1253
+ /** What an apply of this plan would free: blocked categories are not applied. */
1254
+ export function reclaimable(p) {
1255
+ return p.categories.filter((c) => !c.blocked).reduce((s, c) => s + c.bytes, 0);
1256
+ }
1257
+
1258
+ function printPlan(p, mode, disk, top = 0) {
1263
1259
  const lines = [];
1264
1260
  const pct = disk.totalBytes ? ((disk.freeBytes / disk.totalBytes) * 100).toFixed(1) : "?";
1265
1261
  lines.push(
@@ -1274,6 +1270,12 @@ function printPlan(p, mode, disk) {
1274
1270
  lines.push(
1275
1271
  `${c.id.padEnd(18)} ${String(c.candidates.length).padStart(6)} ${human(c.bytes).padStart(9)} ${note}`,
1276
1272
  );
1273
+ if (top > 0) {
1274
+ const s = categorySummary(c, top);
1275
+ for (const x of s.top)
1276
+ lines.push(`${"".padEnd(18)} ${human(x.bytes).padStart(16)} ${x.path}`);
1277
+ if (s.more) lines.push(`${"".padEnd(18)} ${"".padStart(16)} + ${s.more} more`);
1278
+ }
1277
1279
  }
1278
1280
  lines.push(`${"total".padEnd(18)} ${"".padStart(6)} ${human(p.totalBytes).padStart(9)}`);
1279
1281
  return lines.join("\n");
@@ -1348,8 +1350,12 @@ export function main(argv, env = process.env) {
1348
1350
  mode,
1349
1351
  unattended,
1350
1352
  startedAt: new Date(ctx.now).toISOString(),
1351
- disk: { before },
1353
+ disk: {
1354
+ before,
1355
+ expectedFreeBytes: before.freeBytes == null ? null : before.freeBytes + reclaimable(planned),
1356
+ },
1352
1357
  totalBytes: planned.totalBytes,
1358
+ reclaimableBytes: reclaimable(planned),
1353
1359
  categories: planned.categories.map((c) => ({
1354
1360
  id: c.id,
1355
1361
  label: c.label,
@@ -1357,11 +1363,14 @@ export function main(argv, env = process.env) {
1357
1363
  note: c.note,
1358
1364
  candidates: c.candidates.map((x) => ({ path: x.path, bytes: x.bytes, kind: x.kind })),
1359
1365
  skipped: c.skipped,
1366
+ blocked: c.blocked || null,
1367
+ ...categorySummary(c, o.top ?? DEFAULT_TOP),
1360
1368
  })),
1369
+ orphans: listOrphans(ctx),
1361
1370
  };
1362
1371
  let applied = null;
1363
1372
  if (o.apply) {
1364
- applied = applyPlan(ctx, planned, { processes: Boolean(o.processes) && !unattended });
1373
+ applied = applyPlan(ctx, planned);
1365
1374
  const after = diskStatus(ctx.home);
1366
1375
  report.disk.after = after;
1367
1376
  report.applied = {
@@ -1389,10 +1398,15 @@ export function main(argv, env = process.env) {
1389
1398
  if (o.json) {
1390
1399
  process.stdout.write(JSON.stringify(report, null, 2) + "\n");
1391
1400
  } else {
1392
- const lines = [printPlan(planned, mode, before), ...summarizeSkips(planned)];
1401
+ const lines = [printPlan(planned, mode, before, o.top || 0), ...summarizeSkips(planned)];
1402
+ if (report.orphans.length) {
1403
+ lines.push(
1404
+ `orphaned session processes: ${report.orphans.length} (information only; never stopped)`,
1405
+ );
1406
+ }
1393
1407
  if (applied) {
1394
1408
  lines.push(
1395
- `removed ${applied.removed}, failed ${applied.failed}, processes stopped ${applied.stopped}; freed ${human(report.applied.freedBytes)} (df before ${human(before.freeBytes)}, after ${human(report.disk.after.freeBytes)})`,
1409
+ `removed ${applied.removed}, failed ${applied.failed}; freed ${human(report.applied.freedBytes)} (df before ${human(before.freeBytes)}, after ${human(report.disk.after.freeBytes)})`,
1396
1410
  );
1397
1411
  for (const f of applied.failures.slice(0, 10)) {
1398
1412
  lines.push(` failed ${f.category}: ${f.path} (${f.reason})`);