@dibssoftware/dibs 0.0.181 → 0.0.195
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/CHANGELOG.md +103 -1
- package/README.md +10 -8
- package/bin/dibs.mjs +370 -73
- package/docs/agents.md +303 -0
- package/docs/council.md +88 -0
- package/docs/files.md +3 -3
- package/docs/guard.md +86 -11
- package/docs/json.md +211 -0
- package/docs/later.md +5 -5
- package/docs/machines.md +6 -6
- package/docs/questions.md +104 -3
- package/docs/reference.md +124 -30
- package/docs/relay.md +120 -9
- package/docs/releasing.md +7 -1
- package/docs/scheduling.md +28 -6
- package/docs/secrets.md +53 -0
- package/docs/simulators.md +3 -3
- package/package.json +1 -1
- package/skills/dibs/SKILL.md +79 -149
- package/src/about.mjs +341 -0
- package/src/acquire.mjs +111 -27
- package/src/after.mjs +127 -0
- package/src/agents.mjs +2 -1
- package/src/alerts.mjs +95 -42
- package/src/answers.mjs +2 -2
- package/src/board.mjs +21 -16
- package/src/broker.mjs +23 -7
- package/src/carry.mjs +287 -0
- package/src/codex.mjs +132 -0
- package/src/commands.mjs +243 -82
- package/src/config.mjs +85 -14
- package/src/connect.mjs +4 -2
- package/src/cool.mjs +27 -11
- package/src/council.mjs +482 -0
- package/src/cwd.mjs +9 -0
- package/src/decisions.mjs +250 -0
- package/src/declare.mjs +96 -0
- package/src/diskreport.mjs +306 -0
- package/src/diskuse.mjs +420 -0
- package/src/diskwarn.mjs +68 -13
- package/src/doctor.mjs +149 -0
- package/src/doors.mjs +547 -0
- package/src/durable.mjs +143 -0
- package/src/envs.mjs +372 -0
- package/src/events.mjs +7 -2
- package/src/files.mjs +118 -6
- package/src/guard.mjs +239 -86
- package/src/guardd.mjs +8 -1
- package/src/halt.mjs +63 -0
- package/src/handoffs.mjs +362 -0
- package/src/history.mjs +34 -4
- package/src/hogs.mjs +36 -8
- package/src/jobprogress.mjs +283 -0
- package/src/later.mjs +21 -10
- package/src/lock.mjs +33 -9
- package/src/measure.mjs +42 -11
- package/src/media.mjs +240 -0
- package/src/news.mjs +31 -0
- package/src/notes.mjs +49 -8
- package/src/notices.mjs +126 -43
- package/src/ondemand.mjs +25 -2
- package/src/outcome.mjs +163 -0
- package/src/overlap.mjs +2 -2
- package/src/override.mjs +149 -79
- package/src/owner.mjs +15 -2
- package/src/people.mjs +236 -0
- package/src/pickup.mjs +72 -0
- package/src/picture.mjs +321 -0
- package/src/plain.mjs +84 -18
- package/src/platform.mjs +19 -0
- package/src/preempt.mjs +123 -15
- package/src/primer.mjs +91 -20
- package/src/prints.mjs +99 -0
- package/src/proc.mjs +1 -1
- package/src/progress.mjs +49 -3
- package/src/proof.mjs +102 -0
- package/src/push.mjs +271 -0
- package/src/questions.mjs +328 -57
- package/src/quota.mjs +1 -1
- package/src/recap.mjs +205 -0
- package/src/relay.mjs +139 -20
- package/src/remote.mjs +23 -10
- package/src/reviewgate.mjs +268 -0
- package/src/reviews.mjs +377 -0
- package/src/route.mjs +263 -0
- package/src/rules.mjs +216 -0
- package/src/schedule.mjs +238 -44
- package/src/schema.mjs +62 -0
- package/src/scratch.mjs +2 -2
- package/src/serve.mjs +3 -2
- package/src/signed.mjs +97 -0
- package/src/simpool.mjs +46 -1
- package/src/spend.mjs +375 -0
- package/src/state.mjs +43 -17
- package/src/talk.mjs +1078 -133
- package/src/thin.sh +2 -0
- package/src/trail.mjs +290 -0
- package/src/trailnote.mjs +209 -0
- package/src/util.mjs +7 -0
- package/src/vault.mjs +435 -0
- package/src/vendors.mjs +327 -0
- package/src/version.mjs +1 -1
- package/src/web.mjs +353 -60
- package/src/work.mjs +487 -0
- package/src/worker.mjs +7 -1
package/src/handoffs.mjs
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
// Handing work from one agent to another. A handoff is a task (a title and its context) for a
|
|
2
|
+
// named agent or for whichever agent takes it first. The receiver hears it like any message
|
|
3
|
+
// (src/talk.mjs), takes it, and finishes it or gives it back; the sender hears when it's taken
|
|
4
|
+
// and when it's done, with the receiver's note. Open and taken ones show on the board.
|
|
5
|
+
//
|
|
6
|
+
// Handoffs keep their own file and lock (handoffs.json), like messages and questions: nothing
|
|
7
|
+
// here decides who runs next, so nothing here waits on the state lock. A taken handoff whose
|
|
8
|
+
// taker's session is gone goes back to open on the next read, and its sender is told.
|
|
9
|
+
//
|
|
10
|
+
// Work a session left unfinished when it ended is a handoff too (src/carry.mjs): from the agent
|
|
11
|
+
// that stopped, with carry holding what dibs knows of it. The person can give any open one to an
|
|
12
|
+
// agent (dibs handoff give), and that agent hears it.
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { HOME } from './config.mjs';
|
|
16
|
+
import { makeAlive, sessionFiles } from './proc.mjs';
|
|
17
|
+
import { actor, logChange } from './owner.mjs';
|
|
18
|
+
import { whoAmI, messageTo, send, tellAll, toldLine, unreachable, delivery, projectName } from './talk.mjs';
|
|
19
|
+
import { underLock, commit } from './lock.mjs';
|
|
20
|
+
import { minutes } from './plain.mjs';
|
|
21
|
+
import { bold, dim, columns } from './style.mjs';
|
|
22
|
+
import { die, now, say, fakeFull } from './util.mjs';
|
|
23
|
+
import { gather, proofLine } from './proof.mjs';
|
|
24
|
+
import { readJSON } from './durable.mjs';
|
|
25
|
+
|
|
26
|
+
const FILE = path.join(HOME, 'handoffs.json');
|
|
27
|
+
const LOCK = path.join(HOME, 'handoffs.lock');
|
|
28
|
+
// Writes take milliseconds: a live holder past this is stuck on something else, and the caller hears so.
|
|
29
|
+
const LOCK_WAIT = 15e3;
|
|
30
|
+
// A week, as messages keep: an open handoff for a named agent nobody took in that time is stale,
|
|
31
|
+
// and a closed one is history.
|
|
32
|
+
const KEEP_FOR = 7 * 24 * 36e5;
|
|
33
|
+
// An open item for whoever takes it is a backlog, not a message: it waits a month for an agent
|
|
34
|
+
// with time for it. An older dibs still lets it go after KEEP_FOR when it writes the file, which
|
|
35
|
+
// only matters while both run, during an update.
|
|
36
|
+
const KEEP_OPEN = 30 * 24 * 36e5;
|
|
37
|
+
// An item offered to an idle agent (src/pickup.mjs) is its alone this long; unclaimed by then,
|
|
38
|
+
// it goes to the next idle agent. Long enough to read it, look at the code and decide.
|
|
39
|
+
export const OFFER_FOR = 10 * 6e4;
|
|
40
|
+
// The offer standing on an open item, or null.
|
|
41
|
+
export const liveOffer = (x, t = now()) => (x.state === OPEN && x.offer && t - x.offer.at < OFFER_FOR ? x.offer : null);
|
|
42
|
+
const KEEP_DONE = 200;
|
|
43
|
+
// A title is a line; the context says the rest, as long as a message may be.
|
|
44
|
+
const MAX_TITLE = 200;
|
|
45
|
+
const MAX_CONTEXT = 4000;
|
|
46
|
+
// The list shows this many of the most recently closed.
|
|
47
|
+
const RECENT = 5;
|
|
48
|
+
|
|
49
|
+
const USAGE = `dibs handoff "title" [--to <agent>] [-m "context"] [--project <name>]
|
|
50
|
+
hand a task over (no --to: whichever agent on its project takes it first)
|
|
51
|
+
dibs handoff take <id> it's yours now; its sender is told
|
|
52
|
+
dibs handoff give <id> <agent> an open one is that agent's to take; it hears it now
|
|
53
|
+
dibs handoff done <id> ["what you did"] finished; its sender gets your note
|
|
54
|
+
dibs handoff back <id> ["why"] you can't: open again for any agent; its sender is told
|
|
55
|
+
dibs handoff cancel <id> drop it
|
|
56
|
+
dibs handoff list [--all] [--json] open and taken ones (--all: closed ones too)`;
|
|
57
|
+
|
|
58
|
+
export const OPEN = 'open', TAKEN = 'taken';
|
|
59
|
+
|
|
60
|
+
export function locked(fn) {
|
|
61
|
+
let back = [];
|
|
62
|
+
const r = underLock(LOCK, h => {
|
|
63
|
+
const s = load();
|
|
64
|
+
const before = JSON.stringify(s);
|
|
65
|
+
back = reap(s);
|
|
66
|
+
const out = fn(s);
|
|
67
|
+
if (JSON.stringify(s) !== before) commit(h, FILE, JSON.stringify(s, null, 1), { fake: () => fakeFull('state') });
|
|
68
|
+
return out;
|
|
69
|
+
}, { wait: LOCK_WAIT, files: [FILE] });
|
|
70
|
+
if (!r) die(`${LOCK} is held by a dibs that's still running, and stayed held for ${LOCK_WAIT / 1000}s. Nothing was changed: run the same command again.`, 75);
|
|
71
|
+
// Told after the lock: a message takes the messages lock.
|
|
72
|
+
for (const x of back) if (x.from) tryTell(x.from, `Your handoff ${hid(x)} ("${x.title}") is open again: ${x.gone} took it, and its session ended before it was done.`);
|
|
73
|
+
return r.out;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Writes are renames, so reading without the lock always sees a whole file.
|
|
77
|
+
export function load() {
|
|
78
|
+
let s = {};
|
|
79
|
+
try { s = readJSON(FILE); } catch (e) {
|
|
80
|
+
if (e.code !== 'ENOENT') say(`${FILE} was unreadable (${e.message}); starting with no handoffs.`);
|
|
81
|
+
}
|
|
82
|
+
s.seq ||= 0; s.handoffs ||= [];
|
|
83
|
+
return s;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// A taken handoff goes back to open once its taker's Claude Code session is gone (a resumed
|
|
87
|
+
// session runs under a new pid, so its session's live process counts too). Open ones expire after
|
|
88
|
+
// KEEP_FOR; closed ones stay that long for the list. Returns the ones it opened again.
|
|
89
|
+
export function reap(s, t = now()) {
|
|
90
|
+
// A taker outside Claude Code with no process on record can't be checked: it keeps its handoff.
|
|
91
|
+
const taken = s.handoffs.filter(x => x.state === TAKEN && (x.taker?.spid || x.taker?.session));
|
|
92
|
+
const back = [];
|
|
93
|
+
if (taken.length) {
|
|
94
|
+
const files = sessionFiles();
|
|
95
|
+
const up = makeAlive([...taken.map(x => x.taker.spid), ...files.map(f => f.pid)].filter(Boolean));
|
|
96
|
+
const live = new Set(files.filter(f => up(f.pid)).map(f => f.sessionId));
|
|
97
|
+
for (const x of taken) {
|
|
98
|
+
if ((x.taker.spid && up(x.taker.spid, x.taker.sstart)) || (x.taker.session && live.has(x.taker.session))) continue;
|
|
99
|
+
(x.returns ||= []).push({ by: x.taker.name, why: 'its session ended', at: t, ...(x.taker.session && { session: x.taker.session }) });
|
|
100
|
+
back.push({ ...x, gone: x.taker.name });
|
|
101
|
+
Object.assign(x, { state: OPEN, taker: null, takenAt: null });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (const x of s.handoffs) if (x.state === OPEN && t - x.at > (x.to ? KEEP_FOR : KEEP_OPEN)) Object.assign(x, { state: 'expired', closedAt: t });
|
|
105
|
+
const closed = s.handoffs.filter(x => x.state !== OPEN && x.state !== TAKEN && t - (x.closedAt || x.at) < KEEP_FOR).slice(-KEEP_DONE);
|
|
106
|
+
s.handoffs = s.handoffs.filter(x => x.state === OPEN || x.state === TAKEN || closed.includes(x));
|
|
107
|
+
return back;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// One id prefix everywhere: a handoff is a work item (src/work.mjs). h3 still reads as w3.
|
|
111
|
+
export const hid = x => `w${x.id}`;
|
|
112
|
+
export const fromName = x => x.from?.name || 'the person';
|
|
113
|
+
export const nameOf = me => me?.name || actor().name;
|
|
114
|
+
// An agent as an item stores it: whoAmI's shape, less the project it's on now.
|
|
115
|
+
export const withoutProject = ({ project, ...me }) => me;
|
|
116
|
+
// A message to an agent about its handoff. Best effort: the handoff changed whether or not it lands.
|
|
117
|
+
export function tryTell(to, text) { try { messageTo(to, text); } catch {} }
|
|
118
|
+
|
|
119
|
+
// The items x waits on (dibs work add --after) that aren't done yet. One no longer kept was
|
|
120
|
+
// closed over a week ago, so it waits on nothing. A dropped one still blocks: the person or
|
|
121
|
+
// an agent decides whether the work goes ahead without it.
|
|
122
|
+
export const waitingOn = (s, x) => (x.after || []).map(n => find(s, n)).filter(d => d && d.state !== 'done');
|
|
123
|
+
// Why x can't be taken now, or null: it says it's blocked, or it waits on another item.
|
|
124
|
+
export function blockedWhy(s, x) {
|
|
125
|
+
if (x.blocked) return x.blocked.why || `blocked by ${x.blocked.by}`;
|
|
126
|
+
const w = waitingOn(s, x);
|
|
127
|
+
if (!w.length) return null;
|
|
128
|
+
return `waits on ${w.map(d => `w${d.id} ("${d.title}", ${d.state === TAKEN ? `${d.taker.name} has it` : d.state === OPEN ? 'not claimed yet' : d.state})`).join(', ')}`;
|
|
129
|
+
}
|
|
130
|
+
// Items an item's being done lets go: those waiting on it with nothing else in their way.
|
|
131
|
+
export const freedBy = (s, x) => s.handoffs.filter(y => y.state === OPEN && (y.after || []).includes(x.id) && !blockedWhy(s, y));
|
|
132
|
+
|
|
133
|
+
// The handoff an id names (w3, h3 or 3). A refusal is returned, not said, so it's said after the lock.
|
|
134
|
+
const refuse = (err, code = 1) => ({ err, code });
|
|
135
|
+
// w3 names an item, and h3, from before handoffs and items were one list, names the same one.
|
|
136
|
+
export const idOf = (arg, how = 'which handoff? Its id is the w number: dibs handoff take w3. Open ones: dibs handoff list') => {
|
|
137
|
+
const n = Number(String(arg ?? '').replace(/^[hw]/i, ''));
|
|
138
|
+
return arg && Number.isInteger(n) && n > 0 ? n : die(how);
|
|
139
|
+
};
|
|
140
|
+
export const find = (s, n) => s.handoffs.find(x => x.id === n);
|
|
141
|
+
const gone = n => refuse(`no handoff w${n}. Open ones: dibs handoff list`);
|
|
142
|
+
const said = r => (r.err ? die(r.err, r.code) : r);
|
|
143
|
+
|
|
144
|
+
export function handoff(args) {
|
|
145
|
+
const sub = args[0];
|
|
146
|
+
if (sub === 'take') return take(args);
|
|
147
|
+
if (sub === 'give') return give(args);
|
|
148
|
+
if (sub === 'done') return finish(args, 'done');
|
|
149
|
+
if (sub === 'back') return finish(args, 'back');
|
|
150
|
+
if (sub === 'cancel') return finish(args, 'cancel');
|
|
151
|
+
if (sub === 'list' || !args.length || (args.every(a => a.startsWith('--')) && args.length <= 2)) return listAfterSweep(args.filter(a => a !== 'list'));
|
|
152
|
+
if (sub === 'help' || sub === '-h' || sub === '--help') return console.log(USAGE);
|
|
153
|
+
return create(args);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function create(args) {
|
|
157
|
+
const o = { words: [] };
|
|
158
|
+
for (let i = 0; i < args.length; i++) {
|
|
159
|
+
const a = args[i], next = () => args[++i] ?? die(`${a} needs a value.\n${USAGE}`);
|
|
160
|
+
if (a === '--to') o.to = next();
|
|
161
|
+
else if (a === '--project') o.project = projectName(next());
|
|
162
|
+
else if (a === '-m' || a === '--msg') o.context = next().trim();
|
|
163
|
+
else if (a === '--json') o.json = true;
|
|
164
|
+
else if (a.startsWith('-')) die(`unknown flag ${a}.\n${USAGE}`);
|
|
165
|
+
else o.words.push(a);
|
|
166
|
+
}
|
|
167
|
+
const title = o.words.join(' ').trim();
|
|
168
|
+
if (!title) die(`hand over what? dibs handoff "fix the flaky login test" -m "fails 1 in 5 on CI; logs in /tmp/ci"\n${USAGE}`);
|
|
169
|
+
if (title.length > MAX_TITLE) die(`a title is one line (under ${MAX_TITLE} characters); put the rest in -m "...". Nothing was handed over.`);
|
|
170
|
+
if ((o.context || '').length > MAX_CONTEXT) die(`the context is ${o.context.length} characters; keep it under ${MAX_CONTEXT}, or point to a file. Nothing was handed over.`);
|
|
171
|
+
if (o.to) { const no = unreachable(o.to); if (no) die(no, 1); }
|
|
172
|
+
const { project: own, ...from } = whoAmI('handoff', args) || {};
|
|
173
|
+
const project = o.project || own || null;
|
|
174
|
+
if (o.to && from.name && o.to === from.name) die("that's you. Hand it to another agent, or leave out --to for whichever takes it first.");
|
|
175
|
+
const x = locked(s => {
|
|
176
|
+
const x = { id: ++s.seq, title, ...(o.context && { context: o.context }), from: from.name ? from : null, to: o.to || null, state: OPEN, at: now(), ...(project && { project }) };
|
|
177
|
+
s.handoffs.push(x);
|
|
178
|
+
return { ...x };
|
|
179
|
+
});
|
|
180
|
+
logChange('handoff', { id: hid(x), ...(x.to && { to: x.to }) });
|
|
181
|
+
const how = `When it's done: dibs handoff done ${hid(x)} "what you did". If you can't: dibs handoff back ${hid(x)} "why".`;
|
|
182
|
+
const what = `"${title}"${x.context ? `. ${x.context}` : ''}`;
|
|
183
|
+
if (x.to) {
|
|
184
|
+
const r = send(x.to, `Handoff ${hid(x)} for you: ${what}\nTake it: dibs handoff take ${hid(x)}. ${how}`, 'handoff', args);
|
|
185
|
+
if (o.json) return console.log(JSON.stringify({ handoff: shown(x), to: r.to }));
|
|
186
|
+
const d = delivery(r);
|
|
187
|
+
return console.log(`${hid(x)} is handed to ${r.to}${d.startsWith('but ') ? ', ' : ': '}${d} You hear when it's taken and when it's done.`);
|
|
188
|
+
}
|
|
189
|
+
// Only agents on its project hear of it (dibs project): one on another product shouldn't be pulled off it.
|
|
190
|
+
const told = project ? tellAll(`Handoff ${hid(x)}, for whichever agent on ${project} takes it first: ${what}\nTake it if you can: dibs handoff take ${hid(x)} (the first to take it gets it). ${how}`, 'handoff', args, { project }) : [];
|
|
191
|
+
if (o.json) return console.log(JSON.stringify({ handoff: shown(x), told }));
|
|
192
|
+
const nobody = project ? `No other agent on ${project} is running here now; it waits on the board.`
|
|
193
|
+
: 'It has no project, so no agent was told; it waits on the board. Say which product you work on (dibs project <name>), or name one: --project <name>.';
|
|
194
|
+
console.log(`${hid(x)} is open for whichever agent takes it first. ${told.length ? toldLine(told) : nobody} You hear when it's taken and when it's done.`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function take(args) {
|
|
198
|
+
const me = whoAmI('handoff', args);
|
|
199
|
+
const name = nameOf(me);
|
|
200
|
+
const n = idOf(args[1]);
|
|
201
|
+
const x = said(locked(s => {
|
|
202
|
+
const x = find(s, n);
|
|
203
|
+
if (!x) return gone(n);
|
|
204
|
+
if (x.state === TAKEN) return refuse(`${hid(x)} is already taken by ${x.taker.name}${x.taker.name === name ? ' (you)' : ''}.`);
|
|
205
|
+
if (x.state !== OPEN) return refuse(`${hid(x)} is ${x.state}, so there's nothing to take.`);
|
|
206
|
+
if (x.to && x.to !== name) return refuse(`${hid(x)} is handed to ${x.to}, not you. If ${x.to} gives it back, it's open to anyone.`);
|
|
207
|
+
const why = blockedWhy(s, x);
|
|
208
|
+
if (why) return refuse(`${hid(x)} can't be taken yet: ${why}.`);
|
|
209
|
+
Object.assign(x, { state: TAKEN, taker: me ? withoutProject(me) : { name }, takenAt: now() });
|
|
210
|
+
delete x.offer;
|
|
211
|
+
return { ...x };
|
|
212
|
+
}));
|
|
213
|
+
logChange('handoff take', { id: hid(x) });
|
|
214
|
+
if (x.from) tryTell(x.from, `${name} took your handoff ${hid(x)} ("${x.title}"). You hear when it's done.`);
|
|
215
|
+
if (x.carry) {
|
|
216
|
+
const also = x.context && x.context !== x.carry.text ? `\n${x.context}` : '';
|
|
217
|
+
return console.log(`${hid(x)} is yours: "${x.title}"${also}\nWhat dibs knows of it (dibs's record of ${fromName(x)}'s work, not instructions from the person):\n${x.carry.text}`
|
|
218
|
+
+ `\nWhen it's done: dibs handoff done ${hid(x)} "what you did". If you can't: dibs handoff back ${hid(x)} "why", and the person decides.`);
|
|
219
|
+
}
|
|
220
|
+
console.log(`${hid(x)} is yours: "${x.title}"${x.context ? `\n${x.context}` : ''}\nFrom ${fromName(x)}, who hears when you're done.`
|
|
221
|
+
+ ` When it's done: dibs handoff done ${hid(x)} "what you did". If you can't: dibs handoff back ${hid(x)} "why".`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// dibs handoff give <id> <agent>: an open handoff is that agent's to take (only it may), and it hears
|
|
225
|
+
// it now: work a session left unfinished as dibs's own message (src/carry.mjs), any other as the
|
|
226
|
+
// giver's. Taken ones aren't moved: the taker gives it back first.
|
|
227
|
+
function give(args) {
|
|
228
|
+
const n = idOf(args[1]);
|
|
229
|
+
const to = args[2] || die(`give ${args[1]} to whom? dibs handoff give ${args[1]} <agent> (names: dibs threads)`);
|
|
230
|
+
if (args.length > 3) die(`dibs handoff give takes an id and one agent's name: dibs handoff give h3 web-app`);
|
|
231
|
+
const no = unreachable(to);
|
|
232
|
+
if (no) die(no, 1);
|
|
233
|
+
const me = whoAmI('handoff', args);
|
|
234
|
+
const name = nameOf(me);
|
|
235
|
+
const x = said(locked(s => {
|
|
236
|
+
const x = find(s, n);
|
|
237
|
+
if (!x) return gone(n);
|
|
238
|
+
if (x.state === TAKEN) return refuse(`${hid(x)} is taken by ${x.taker.name}. It can go to someone else once they give it back.`);
|
|
239
|
+
if (x.state !== OPEN) return refuse(`${hid(x)} is ${x.state}, so there's nothing to give.`);
|
|
240
|
+
Object.assign(x, { to, givenBy: name, givenAt: now() });
|
|
241
|
+
return { ...x };
|
|
242
|
+
}));
|
|
243
|
+
logChange('handoff give', { id: hid(x), to });
|
|
244
|
+
const how = `Take it: dibs handoff take ${hid(x)}. When it's done: dibs handoff done ${hid(x)} "what you did". If you can't: dibs handoff back ${hid(x)} "why".`;
|
|
245
|
+
const r = x.carry
|
|
246
|
+
? send(to, `${name === 'the person' ? 'The person' : name} gave you ${hid(x)} ("${x.title}"), which ${fromName(x)} left unfinished when its session ended.\n${x.carry.text}\n${how}`, 'handoff', args, null, { carry: true })
|
|
247
|
+
: send(to, `Handoff ${hid(x)} for you: "${x.title}"${x.context ? `. ${x.context}` : ''}\n${how}`, 'handoff', args);
|
|
248
|
+
const d = delivery(r);
|
|
249
|
+
console.log(`${hid(x)} is ${r.to}'s to take${d.startsWith('but ') ? ', ' : ': '}${d}`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// done, back and cancel: anyone may, as with any job, and the sender hears who did it.
|
|
253
|
+
function finish(args, verb) {
|
|
254
|
+
const me = whoAmI('handoff', args);
|
|
255
|
+
const name = nameOf(me);
|
|
256
|
+
const note = args.slice(2).join(' ').trim().slice(0, MAX_CONTEXT);
|
|
257
|
+
const n = idOf(args[1]);
|
|
258
|
+
// Gathered before the lock: it reads the event log and asks git.
|
|
259
|
+
const before = verb === 'done' ? find(load(), n) : null;
|
|
260
|
+
const proof = before?.taker ? gather({ who: before.taker.who || before.taker.name, since: before.takenAt || before.at }) : null;
|
|
261
|
+
let freed = [];
|
|
262
|
+
const x = said(locked(s => {
|
|
263
|
+
const x = find(s, n);
|
|
264
|
+
if (!x) return gone(n);
|
|
265
|
+
if (x.state !== OPEN && x.state !== TAKEN) return refuse(`${hid(x)} is already ${x.state}.`);
|
|
266
|
+
if (verb === 'done' && x.state !== TAKEN) return refuse(`nobody has taken ${hid(x)} yet. Take it first: dibs handoff take ${hid(x)}`);
|
|
267
|
+
const was = { ...x };
|
|
268
|
+
if (verb === 'done') {
|
|
269
|
+
Object.assign(x, { state: 'done', closedAt: now(), doneBy: name, ...(note && { note }), ...(proof && { proof }) });
|
|
270
|
+
freed = freedBy(s, x).map(y => ({ ...y }));
|
|
271
|
+
}
|
|
272
|
+
else if (verb === 'cancel') Object.assign(x, { state: 'cancelled', closedAt: now(), cancelledBy: name });
|
|
273
|
+
else {
|
|
274
|
+
// Given back, it's open to anyone: the one it was handed to can't do it.
|
|
275
|
+
(x.returns ||= []).push({ by: name, ...(note && { why: note }), at: now() });
|
|
276
|
+
Object.assign(x, { state: OPEN, to: null, taker: null, takenAt: null });
|
|
277
|
+
delete x.offer;
|
|
278
|
+
}
|
|
279
|
+
return { x: { ...x }, was };
|
|
280
|
+
}));
|
|
281
|
+
logChange(`handoff ${verb}`, { id: hid(x.x) });
|
|
282
|
+
const h = x.x, t = `${hid(h)} ("${h.title}")`;
|
|
283
|
+
const mine = me && h.from && me.session === h.from.session && me.agentId === h.from.agentId;
|
|
284
|
+
if (verb === 'done') {
|
|
285
|
+
if (h.from && !mine) tryTell(h.from, `${name} finished your handoff ${t}.${note ? ` Their note: ${/[.!?]$/.test(note) ? note : `${note}.`}` : ''} Done, ${proofLine(h.proof)}.`);
|
|
286
|
+
tellFreed(freed);
|
|
287
|
+
return console.log(`${hid(h)} is done.${h.from ? ` ${fromName(h)} gets your note.` : ''}`);
|
|
288
|
+
}
|
|
289
|
+
if (verb === 'back') {
|
|
290
|
+
if (h.from && !mine) tryTell(h.from, `${name} gave back your handoff ${t}${note ? `: ${note}` : ''}. It's open to any agent now; drop it with dibs handoff cancel ${hid(h)}.`);
|
|
291
|
+
return console.log(`${hid(h)} is open again, for any agent.${h.from ? ` ${fromName(h)} is told.` : ''}`);
|
|
292
|
+
}
|
|
293
|
+
if (x.was.taker && x.was.taker.session && !(me && me.session === x.was.taker.session && me.agentId === x.was.taker.agentId))
|
|
294
|
+
tryTell(x.was.taker, `Handoff ${t} was cancelled by ${name}: stop working on it.`);
|
|
295
|
+
console.log(`${hid(h)} is cancelled.`);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Agents an item was handed to hear when the last thing it waited on is done.
|
|
299
|
+
export function tellFreed(items) {
|
|
300
|
+
for (const y of items) {
|
|
301
|
+
if (!y.to || unreachable(y.to)) continue;
|
|
302
|
+
try { send(y.to, `Work item w${y.id} ("${y.title}") for you can be claimed now: what it waited on is done. Claim it: dibs work claim w${y.id}`, 'work', []); } catch {}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// What the board, the page and --json show of one: names, never sessions or pids.
|
|
307
|
+
const shown = x => ({ id: hid(x), title: x.title, context: x.context || null, from: fromName(x), to: x.to || null, state: x.state, at: x.at,
|
|
308
|
+
taker: x.taker?.name || null, takenAt: x.takenAt || null, closedAt: x.closedAt || null, note: x.note || null, ...(x.kind && { kind: x.kind }), project: x.project || null,
|
|
309
|
+
...(x.carry && { carry: carryShown(x) }) });
|
|
310
|
+
// Work a session left unfinished: what the screens say of it. Paths and names, never sessions.
|
|
311
|
+
const carryShown = x => ({ who: x.carry.who || fromName(x), at: x.carry.at || x.at, stoppedAt: x.carry.stoppedAt || x.at, project: x.carry.project || null, branch: x.carry.branch || null,
|
|
312
|
+
changed: x.carry.git?.changed ?? null, unpushed: x.carry.git?.unpushed ?? null, offered: x.carry.offered?.name || null,
|
|
313
|
+
offeredAt: x.carry.offered?.at || null, returned: (x.returns || []).some(r => r.at >= (x.carry.offered?.at || x.at)), text: x.carry.text });
|
|
314
|
+
|
|
315
|
+
// Open and taken handoffs, oldest first, for the board. Read without the lock; the reaping isn't saved.
|
|
316
|
+
export function handoffsNow(t = now()) {
|
|
317
|
+
if (!fs.existsSync(FILE)) return [];
|
|
318
|
+
const s = load();
|
|
319
|
+
reap(s, t);
|
|
320
|
+
return s.handoffs.filter(x => x.state === OPEN || x.state === TAKEN).map(shown);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Every handoff on record, closed ones too, as the screens see them: for the recap, which says what
|
|
324
|
+
// came of work sessions left unfinished. Read without the lock; the reaping isn't saved.
|
|
325
|
+
export function handoffsAll(t = now()) {
|
|
326
|
+
if (!fs.existsSync(FILE)) return [];
|
|
327
|
+
const s = load();
|
|
328
|
+
reap(s, t);
|
|
329
|
+
return s.handoffs.map(shown);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// One line for the board: what it is and where it stands.
|
|
333
|
+
export const handoffLine = (x, t = now()) => `${x.id} "${x.title}" ${x.carry ? `left by ${x.carry.who} when its session ended` : `from ${x.from}`}, `
|
|
334
|
+
+ (x.state === TAKEN ? `taken by ${x.taker} ${t - x.takenAt < 6e4 ? 'just now' : `${minutes(t - x.takenAt)} ago`}`
|
|
335
|
+
: x.to ? `for ${x.to}, not taken yet` : x.carry?.offered ? `offered to ${x.carry.offered}, not taken yet` : 'open for any agent');
|
|
336
|
+
|
|
337
|
+
// The list looks for sessions that ended mid-task first (src/carry.mjs), so it's never behind.
|
|
338
|
+
async function listAfterSweep(args) {
|
|
339
|
+
try { await (await import('./carry.mjs')).sweep({ force: true }); } catch (e) { say(`couldn't look for work left unfinished: ${e.message}`); }
|
|
340
|
+
list(args);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function list(args) {
|
|
344
|
+
const json = args.includes('--json'), all = args.includes('--all');
|
|
345
|
+
const bad = args.find(a => a !== '--json' && a !== '--all');
|
|
346
|
+
if (bad) die(`unknown ${bad}.\n${USAGE}`);
|
|
347
|
+
const t = now();
|
|
348
|
+
const s = locked(x => x);
|
|
349
|
+
const live = s.handoffs.filter(x => x.state === OPEN || x.state === TAKEN);
|
|
350
|
+
const closed = s.handoffs.filter(x => !live.includes(x)).sort((a, b) => (b.closedAt || 0) - (a.closedAt || 0));
|
|
351
|
+
if (json) return console.log(JSON.stringify({ handoffs: [...live, ...(all ? closed : [])].map(shown) }, null, 1));
|
|
352
|
+
if (!live.length && !closed.length) return console.log(`No handoffs. Hand a task to another agent: dibs handoff "title" --to <agent> -m "context"`);
|
|
353
|
+
const out = [bold(live.length ? `${live.length} open or taken:` : 'Nothing open.')];
|
|
354
|
+
out.push(...columns(live.map(x => [hid(x), handoffLine(shown(x), t).replace(/^w\d+ /, '')])));
|
|
355
|
+
const old = all ? closed : closed.slice(0, RECENT);
|
|
356
|
+
if (old.length) {
|
|
357
|
+
out.push('', dim(all ? 'Closed:' : 'Closed lately:'));
|
|
358
|
+
out.push(...columns(old.map(x => [hid(x), dim(`"${x.title}" ${x.state}${x.doneBy ? ` by ${x.doneBy}` : x.cancelledBy ? ` by ${x.cancelledBy}` : ''}${x.note ? `: ${x.note}` : ''}`)])));
|
|
359
|
+
}
|
|
360
|
+
out.push('', dim('Take one: dibs handoff take <id>. Everything: dibs handoff help'));
|
|
361
|
+
console.log(out.join('\n'));
|
|
362
|
+
}
|
package/src/history.mjs
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// (src/events.mjs). summarize() is a pure function of the events, so the
|
|
3
3
|
// tests can feed it a made-up week.
|
|
4
4
|
import { withState } from './state.mjs';
|
|
5
|
-
import
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import { readEvents, EVENTS, OLDER } from './events.mjs';
|
|
6
7
|
import { short } from './files.mjs';
|
|
7
|
-
import { dur, clock, die, now } from './util.mjs';
|
|
8
|
+
import { dur, clock, die, now, SCHEMA } from './util.mjs';
|
|
8
9
|
import { named } from './plain.mjs';
|
|
9
10
|
import { bold, dim } from './style.mjs';
|
|
10
11
|
|
|
@@ -112,8 +113,11 @@ export function summarize(events, current, since, until) {
|
|
|
112
113
|
|
|
113
114
|
const shown = events.filter(e => e.kind !== 'sample' && inWindow(e)).slice(-EVENT_CAP)
|
|
114
115
|
.map(e => ({ ...e, res: (e.res || []).map(name), who: e.who ?? null, prio: e.prio ?? null, code: e.code ?? null, ms: e.ms ?? null }));
|
|
116
|
+
// Who stepped aside for whom (src/preempt.mjs, the yield protocol), newest last.
|
|
117
|
+
const yields = events.filter(e => e.kind === 'yield' && inWindow(e)).map(e => ({ at: e.at, id: e.id, who: e.who, prio: e.prio, purpose: e.purpose ?? null,
|
|
118
|
+
to: e.to, toWho: e.toWho, toPrio: e.toPrio, toPurpose: e.toPurpose ?? null, why: e.why, how: e.how, ran: e.ran ?? null }));
|
|
115
119
|
// The last three are for the plain report; --json leaves them out.
|
|
116
|
-
return { since, until, resources, agents, hourly, events: shown,
|
|
120
|
+
return { since, until, resources, agents, hourly, events: shown, yields,
|
|
117
121
|
waitIntervals: allWaits.map(w => ({ ...w, res: w.res.map(name) })), started: starts.length, gaveUp: timeouts.length };
|
|
118
122
|
}
|
|
119
123
|
|
|
@@ -190,10 +194,36 @@ export function report(h, label, cfg = { resources: {} }) {
|
|
|
190
194
|
for (const x of busy)
|
|
191
195
|
out.push(` ${day(x.hour)} ${clock(x.hour).padEnd(8)} ${x.waiting} waiting, ${x.held} running${x.load != null ? `, load average ${x.load}` : ''}`);
|
|
192
196
|
}
|
|
197
|
+
if (h.yields?.length) out.push('', bold('Yields'), ...h.yields.slice(-10).map(y => ` ${day(y.at)} ${clock(y.at).padEnd(8)} ${yieldLine(y)}`));
|
|
193
198
|
out.push('', dim('Another span: dibs history --since 24h (or 30d). For a program: dibs history --json'));
|
|
194
199
|
return out;
|
|
195
200
|
}
|
|
196
201
|
|
|
202
|
+
// Yields in the last day that involve this agent's jobs, either way, for dibs why.
|
|
203
|
+
const DAY = 24 * HOUR;
|
|
204
|
+
// Only lines that mention a yield are parsed: dibs why is called often, and the log can be 20 MB.
|
|
205
|
+
export function yieldsOf(who, t = now()) {
|
|
206
|
+
const out = [];
|
|
207
|
+
for (const f of [OLDER, EVENTS]) {
|
|
208
|
+
let text = '';
|
|
209
|
+
try { text = fs.readFileSync(f, 'utf8'); } catch {}
|
|
210
|
+
for (const l of text.split('\n')) {
|
|
211
|
+
if (!l.includes('"kind":"yield"')) continue;
|
|
212
|
+
try { const e = JSON.parse(l); if (t - e.at < DAY && (e.who === who || e.toName === who)) out.push(e); } catch {}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return out.sort((a, b) => a.at - b.at);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// One yield in a sentence: "alex-d5's #26920 ("pokerlab solver") stepped aside for builder's urgent
|
|
219
|
+
// #27001 ("ship the fix"), for memory, after 3h10m of running: saved its progress and went back in line".
|
|
220
|
+
const WHY = { slot: 'a slot', memory: 'memory', pressure: 'memory (pressure high)', swap: 'memory (swapping)', ram: 'memory', oversize: 'memory' };
|
|
221
|
+
export function yieldLine(y) {
|
|
222
|
+
const job = (who, prio, id, purpose) => `${who}'s ${prio && prio !== 'normal' ? `${prio} ` : ''}#${id}${purpose ? ` ("${purpose}")` : ''}`;
|
|
223
|
+
return `${job(y.who, y.prio, y.id, y.purpose)} ${y.how === 'pause' ? 'was paused' : 'stepped aside'} for ${job(y.toWho, y.toPrio, y.to, y.toPurpose)}, for ${WHY[y.why] || y.why}`
|
|
224
|
+
+ `${y.ran != null ? `, after ${dur(y.ran)} of running` : ''}: ${y.how === 'pause' ? 'it resumed when that job ended' : 'asked to save its progress, then put back in line behind it'}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
197
227
|
export function history(o, cfg) {
|
|
198
228
|
const until = now();
|
|
199
229
|
const since = until - span(o.since);
|
|
@@ -205,7 +235,7 @@ export function history(o, cfg) {
|
|
|
205
235
|
const h = summarize(readEvents(until), current, since, until);
|
|
206
236
|
if (o.json) {
|
|
207
237
|
const { waitIntervals, started, gaveUp, ...app } = h;
|
|
208
|
-
return console.log(JSON.stringify(app, null, 1));
|
|
238
|
+
return console.log(JSON.stringify({ schema: SCHEMA, ...app, events: app.events.map(e => ({ id: null, ...e })) }, null, 1));
|
|
209
239
|
}
|
|
210
240
|
console.log(report(h, o.since || '7d', cfg).join('\n'));
|
|
211
241
|
}
|
package/src/hogs.mjs
CHANGED
|
@@ -46,7 +46,7 @@ function write(x) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// Every session folder under the temp roots, by its real path.
|
|
49
|
-
function sessionFolders() {
|
|
49
|
+
export function sessionFolders() {
|
|
50
50
|
const out = new Set();
|
|
51
51
|
for (const root of claudeTmp()) {
|
|
52
52
|
let projects = [];
|
|
@@ -89,14 +89,26 @@ function contents(folder) {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
walk(folder, 0);
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
// A count of node_modules alone said nothing about size: 2026-11-24's "3 node_modules folders"
|
|
93
|
+
// were 10 MB together, and the agent told to free them found nothing to free.
|
|
94
|
+
return worktrees > 1 ? `${worktrees} git worktrees${modules >= worktrees ? ', node_modules in each' : modules ? `, ${modules} node_modules folders` : ''}` : '';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Where a folder's weight is: its subfolders holding at least a quarter of it, biggest first, with
|
|
98
|
+
// their sizes. On 2026-11-24 a session's 6.5 GB was scratch/ and scratchpad/ about evenly, and its
|
|
99
|
+
// agent, told of "your scratch folder", looked only in scratchpad/ and found half.
|
|
100
|
+
function heavy(folder, size) {
|
|
101
|
+
const total = size[folder] || 0, pre = folder + '/';
|
|
102
|
+
const subs = Object.entries(size).filter(([p, b]) => p.startsWith(pre) && !p.slice(pre.length).includes('/') && b >= total / 4)
|
|
103
|
+
.sort((a, b) => b[1] - a[1]).slice(0, 2).map(([p, b]) => `${p.slice(pre.length)}/ ${GB(b)}`);
|
|
104
|
+
const pad = contents(path.join(folder, 'scratchpad')) || contents(folder);
|
|
105
|
+
return [subs.join(', '), pad].filter(Boolean).join('; ');
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
// Who to tell about a session's folder: the session's name from dibs's own
|
|
97
109
|
// records, and the agent that made its biggest scratchpad folder (src/files.mjs
|
|
98
110
|
// notes it), else the session's main thread.
|
|
99
|
-
function ownerOf(folder, session, size) {
|
|
111
|
+
export function ownerOf(folder, session, size) {
|
|
100
112
|
let who = null;
|
|
101
113
|
for (const f of [paths.state, path.join(HOME, 'messages.json')]) {
|
|
102
114
|
try {
|
|
@@ -121,7 +133,7 @@ function short(cfg, m, s) {
|
|
|
121
133
|
// The session folders over HOG_MIN, biggest first, with whose they are.
|
|
122
134
|
function bigFolders(folders, size) {
|
|
123
135
|
return Object.entries(size).filter(([p, b]) => folders.includes(p) && b >= HOG_MIN()).sort((a, b) => b[1] - a[1]).slice(0, TOP)
|
|
124
|
-
.map(([folder, b]) => ({ folder, session: path.basename(folder), bytes: b, what:
|
|
136
|
+
.map(([folder, b]) => ({ folder, session: path.basename(folder), bytes: b, what: heavy(folder, size), ...ownerOf(folder, path.basename(folder), size) }));
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
// One pass, from the throttle watcher: measure on a new drop (and every
|
|
@@ -152,7 +164,7 @@ export async function hogsOnce(cfg, m, t = now()) {
|
|
|
152
164
|
const folders = sessionFolders();
|
|
153
165
|
const size = await sizes([...folders, ...Object.values(places())]);
|
|
154
166
|
// The folders big enough to be worth freeing: their sessions are the ones told.
|
|
155
|
-
write(x = { ...x, under: false, folders: bigFolders(folders, size), ...readings(folders, size, m, was, t) });
|
|
167
|
+
write(x = { ...x, under: false, folders: bigFolders(folders, size), ...await withSwap(readings(folders, size, m, was, t), s) });
|
|
156
168
|
}
|
|
157
169
|
const keep = await warnOnce(cfg, m, x, hintOf(x), t);
|
|
158
170
|
if (Object.keys(keep).length) write({ ...x, ...keep });
|
|
@@ -170,7 +182,7 @@ export async function hogsOnce(cfg, m, t = now()) {
|
|
|
170
182
|
const size = await sizes([...folders, ...Object.values(places())]);
|
|
171
183
|
const big = bigFolders(folders, size);
|
|
172
184
|
const waiting = (s.queue || []).filter(q => q.pid).length;
|
|
173
|
-
const x = { ...(was?.cleaned && { cleaned: was.cleaned, cleanedCritical: was.cleanedCritical }), ...(was?.warned && { warned: was.warned }), under: true, drop, at: t, free: m.diskFree, floor, waiting, folders: big, ...readings(folders, size, m, was, t) };
|
|
185
|
+
const x = { ...(was?.cleaned && { cleaned: was.cleaned, cleanedCritical: was.cleanedCritical }), ...(was?.warned && { warned: was.warned }), ...(was?.fall && { fall: was.fall }), under: true, drop, at: t, free: m.diskFree, floor, waiting, folders: big, ...await withSwap(readings(folders, size, m, was, t), s) };
|
|
174
186
|
write(x);
|
|
175
187
|
const keep = await warnOnce(cfg, m, x, hintOf(x), t);
|
|
176
188
|
if (Object.keys(keep).length) write({ ...x, ...keep });
|
|
@@ -205,6 +217,18 @@ function readings(folders, size, m, was, t) {
|
|
|
205
217
|
return { readings: now, readAt: t, writer, grew };
|
|
206
218
|
}
|
|
207
219
|
|
|
220
|
+
// When swap grew on the disk, what holds the memory: swap is memory written out, so deleting files
|
|
221
|
+
// doesn't stop it, and closing what uses the most does. On 2026-11-26 swap stood at 8.3 GB of 9.2
|
|
222
|
+
// with 3.1 GB of disk free, and the waits named only folders.
|
|
223
|
+
async function withSwap(r, s) {
|
|
224
|
+
if (!r.grew.includes('swap')) return r;
|
|
225
|
+
try {
|
|
226
|
+
const { memoryUsers } = await import('./alerts.mjs');
|
|
227
|
+
const { processesNow, memoryUse } = await import('./platform.mjs');
|
|
228
|
+
return { ...r, memory: memoryUsers(s, processesNow(), memoryUse()).slice(0, 3).map(g => ({ name: g.name, bytes: g.bytes })) };
|
|
229
|
+
} catch { return r; }
|
|
230
|
+
}
|
|
231
|
+
|
|
208
232
|
// For a disk wait: what's growing and the biggest folder and whose it is, as words to add, or ''.
|
|
209
233
|
export function hogHint(t = now()) {
|
|
210
234
|
const x = read();
|
|
@@ -213,7 +237,11 @@ export function hogHint(t = now()) {
|
|
|
213
237
|
}
|
|
214
238
|
function hintOf(x) {
|
|
215
239
|
const w = x.writer;
|
|
216
|
-
const
|
|
240
|
+
const fastest = w ? `. Growing fastest: ${named(w.label, x)}, up ${GB(w.by)} in ${Math.max(1, Math.round(w.ms / 6e4))} min` : '';
|
|
241
|
+
// Swap is memory: what to close, not what to delete.
|
|
242
|
+
const grew = fastest + (x.memory?.length && x.grew?.includes('swap')
|
|
243
|
+
? `. Swap grows with memory in use; the most is held by ${x.memory.map(g => `${g.name} (${GB(g.bytes)})`).join(', ')}`
|
|
244
|
+
: '');
|
|
217
245
|
const h = x.folders?.[0];
|
|
218
246
|
if (!h) return grew;
|
|
219
247
|
const name = h.who || `session ${h.session.slice(0, 8)}`;
|