@kaynooo/cli-proc 0.7.0 → 0.7.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.
package/dist/proc-cli.js CHANGED
@@ -2,13 +2,13 @@
2
2
  // @bun
3
3
 
4
4
  // src/proc-cli.ts
5
- import process16 from "process";
5
+ import process19 from "process";
6
6
  // ../kit/src/args.ts
7
- import process6 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process4 from "process";
11
+ import process7 from "process";
12
12
 
13
13
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-n6z2kk96.js
14
14
  var r = new Map;
@@ -23,6 +23,7 @@ function y(e, t) {
23
23
  n = new Intl.NumberFormat(e, t), i.set(o, n);
24
24
  return n;
25
25
  }
26
+
26
27
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
27
28
  var N = new Map;
28
29
  var Nt = /\s+\S*$/;
@@ -40,6 +41,7 @@ function ko(t, e, r = "...") {
40
41
  }
41
42
  var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
42
43
  var z = new Map;
44
+
43
45
  // ../kit/src/mode.ts
44
46
  import process2 from "process";
45
47
  var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
@@ -62,7 +64,7 @@ function isInteractive(streams = process2) {
62
64
  }
63
65
 
64
66
  // ../kit/src/style.ts
65
- import process3 from "process";
67
+ import process6 from "process";
66
68
 
67
69
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
68
70
  var G2 = /^[a-f0-9]+$/i;
@@ -88,7 +90,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
88
90
  return false;
89
91
  return r?.isTTY === true;
90
92
  }
91
- function f2(r, e = []) {
93
+ function f(r, e = []) {
92
94
  let l = "", n = "";
93
95
  for (let t = 0, i = e.length;t < i; t++)
94
96
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
@@ -98,7 +100,7 @@ function f2(r, e = []) {
98
100
  if (Array.isArray(a)) {
99
101
  let s = g.get(i);
100
102
  if (s === undefined)
101
- s = f2(r, [...e, a]), g.set(i, s);
103
+ s = f(r, [...e, a]), g.set(i, s);
102
104
  return s;
103
105
  }
104
106
  if (typeof a === "function")
@@ -107,30 +109,251 @@ function f2(r, e = []) {
107
109
  if (u === undefined) {
108
110
  if (g.size >= 64)
109
111
  g.clear();
110
- u = f2(r, [...e, a(...s)]), g.set(y, u);
112
+ u = f(r, [...e, a(...s)]), g.set(y, u);
111
113
  }
112
114
  return u;
113
115
  };
114
116
  throw Error(`Unknown style: ${String(i)}`);
115
117
  } });
116
118
  }
117
- function Fe2(r = {}) {
118
- return f2(r);
119
+ function Fe(r = {}) {
120
+ return f(r);
121
+ }
122
+ var o = Fe();
123
+
124
+ // ../kit/src/theme.ts
125
+ import { existsSync as existsSync2, readFileSync, statSync } from "fs";
126
+ import { homedir as homedir2 } from "os";
127
+ import { join as join3, resolve as resolve2 } from "path";
128
+ import process5 from "process";
129
+
130
+ // ../kit/src/config.ts
131
+ import { existsSync } from "fs";
132
+ import { dirname, join, resolve } from "path";
133
+ import process3 from "process";
134
+ function findUp(names, from = process3.cwd(), stop = () => false) {
135
+ const wanted = typeof names === "string" ? [names] : names;
136
+ for (let dir = resolve(from);; dir = dirname(dir)) {
137
+ const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
138
+ if (found !== undefined)
139
+ return found;
140
+ if (stop(dir) || dirname(dir) === dir)
141
+ return;
142
+ }
143
+ }
144
+
145
+ // ../kit/src/user-config.ts
146
+ import { homedir } from "os";
147
+ import { join as join2 } from "path";
148
+ import process4 from "process";
149
+ function configBase(where = {}) {
150
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
151
+ return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
152
+ }
153
+ function userConfigPath(bin, where = {}) {
154
+ return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
119
155
  }
120
- var o2 = Fe2();
121
156
 
122
157
  // ../kit/src/theme.ts
123
158
  var ENDS = new Map;
159
+ var DEFAULT = {
160
+ colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", plan: "magenta", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
161
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", plan: "\u25C7", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
162
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
163
+ bins: {},
164
+ gradient: ["#c084fc", "#67e8f9"]
165
+ };
166
+ var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", plan: "magentaBright", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
167
+ var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", plan: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
168
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
169
+ var PRESETS = {
170
+ default: {},
171
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
172
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
173
+ ascii: { glyphs: ASCII }
174
+ };
124
175
  var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
176
+ var HEX = /^#[0-9a-f]{6}$/i;
177
+ var CONTROL = /\p{Cc}/u;
125
178
  var MAX_FILE_BYTES = 64 * 1024;
179
+ var SPACES = /\s+/;
180
+ function isColorSpec(spec) {
181
+ if (typeof spec === "number")
182
+ return Number.isInteger(spec) && spec >= 0 && spec <= 255;
183
+ return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
184
+ }
185
+ var CUBE = [0, 95, 135, 175, 215, 255];
186
+ function cubeLevel(channel) {
187
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
188
+ }
189
+ function nearest256(hex) {
190
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
191
+ const levels = rgb.map(cubeLevel);
192
+ const cube = levels.map((level) => CUBE[level]);
193
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
194
+ const greyValue = 8 + grey * 10;
195
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
196
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
197
+ }
198
+ function hasTrueColor(env) {
199
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
200
+ }
201
+ function tinted(colors, spec, env = process5.env) {
202
+ if (typeof spec === "number")
203
+ return colors.ansi256(spec);
204
+ return spec.trim().split(SPACES).reduce((chain, token) => {
205
+ if (HEX.test(token))
206
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
207
+ return chain[token] ?? chain;
208
+ }, colors);
209
+ }
210
+ function isRecord(value) {
211
+ return typeof value === "object" && value !== null && !Array.isArray(value);
212
+ }
213
+ function readThemeFile(path, warn) {
214
+ try {
215
+ const stat = statSync(path, { throwIfNoEntry: false });
216
+ if (stat === undefined)
217
+ return;
218
+ if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
219
+ warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
220
+ return;
221
+ }
222
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
223
+ if (isRecord(parsed))
224
+ return parsed;
225
+ warn(`${path} is not a JSON object, theme ignored`);
226
+ } catch (error) {
227
+ warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
228
+ }
229
+ return;
230
+ }
231
+ function applyPreset(theme, name, warn, where) {
232
+ if (name === undefined)
233
+ return;
234
+ if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
235
+ warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
236
+ return;
237
+ }
238
+ const preset = PRESETS[name];
239
+ Object.assign(theme.colors, preset.colors);
240
+ Object.assign(theme.glyphs, preset.glyphs);
241
+ if (preset.accents !== undefined)
242
+ theme.accents = [...preset.accents];
243
+ if (Object.hasOwn(preset, "gradient"))
244
+ theme.gradient = preset.gradient;
245
+ return name;
246
+ }
247
+ function applyFile(theme, file, where, warn) {
248
+ if (isRecord(file.colors)) {
249
+ for (const [key, value] of Object.entries(file.colors)) {
250
+ if (!Object.hasOwn(DEFAULT.colors, key))
251
+ warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
252
+ else if (!isColorSpec(value))
253
+ warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
254
+ else
255
+ theme.colors[key] = value;
256
+ }
257
+ }
258
+ if (isRecord(file.glyphs)) {
259
+ for (const [key, value] of Object.entries(file.glyphs)) {
260
+ if (!Object.hasOwn(DEFAULT.glyphs, key))
261
+ warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
262
+ else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
263
+ warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
264
+ else
265
+ theme.glyphs[key] = value;
266
+ }
267
+ }
268
+ if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
269
+ theme.accents = [...file.accents];
270
+ else if (file.accents !== undefined)
271
+ warn(`${where}: accents must be a non-empty list of colours`);
272
+ if (file.gradient === null)
273
+ theme.gradient = undefined;
274
+ else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
275
+ theme.gradient = [file.gradient[0], file.gradient[1]];
276
+ else if (file.gradient !== undefined)
277
+ warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
278
+ if (isRecord(file.bins)) {
279
+ for (const [bin, value] of Object.entries(file.bins)) {
280
+ if (isColorSpec(value))
281
+ theme.bins[bin] = value;
282
+ else
283
+ warn(`${where}: bin ${bin} has no valid colour`);
284
+ }
285
+ }
286
+ }
287
+ function endsWalk(home) {
288
+ return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
289
+ }
126
290
  var warned = new Set;
291
+ function warnOnce(message) {
292
+ if (warned.has(message))
293
+ return;
294
+ warned.add(message);
295
+ console.error(`warning: theme ${message}`);
296
+ }
297
+ function isPath(chosen) {
298
+ return chosen.includes("/") || chosen.endsWith(".json");
299
+ }
300
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
301
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
302
+ const sources = [];
303
+ const chosen = env.KIT_THEME ?? "";
304
+ const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
305
+ if (isPath(chosen))
306
+ wanted.push(resolve2(from, chosen));
307
+ const files = [];
308
+ for (const path of wanted) {
309
+ const file = path === undefined ? undefined : readThemeFile(path, warn);
310
+ if (path !== undefined && file !== undefined)
311
+ files.push({ path, file });
312
+ }
313
+ let preset = "default";
314
+ if (chosen !== "" && !isPath(chosen)) {
315
+ preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
316
+ } else {
317
+ const named = files.findLast(({ file }) => file.preset !== undefined);
318
+ if (named !== undefined)
319
+ preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
320
+ }
321
+ for (const { path, file } of files) {
322
+ applyFile(theme, file, path, warn);
323
+ sources.push(path);
324
+ }
325
+ return { theme, sources, preset };
326
+ }
327
+ var current;
328
+ var currentKey = "";
329
+ function activeTheme() {
330
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
331
+ if (current === undefined || key !== currentKey) {
332
+ current = loadTheme();
333
+ currentKey = key;
334
+ }
335
+ return current;
336
+ }
127
337
 
128
338
  // ../kit/src/style.ts
129
- function takesControlCodes(stream, env = process3.env) {
339
+ var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
340
+ function takesControlCodes(stream, env = process6.env) {
130
341
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
131
342
  }
132
- function paint(stream, env = process3.env) {
133
- return Fe2({ stream: { isTTY: takesControlCodes(stream, env) }, env });
343
+ function paint(stream, env = process6.env) {
344
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
345
+ }
346
+ function marked(mark, text, stream, detail, env = process6.env) {
347
+ const colors = paint(stream, env);
348
+ let head = MARK_WORDS[mark];
349
+ if (takesControlCodes(stream, env)) {
350
+ const { theme } = activeTheme();
351
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
352
+ }
353
+ return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
354
+ }
355
+ function problem(text, detail) {
356
+ console.error(marked("problem", text, process6.stderr, detail));
134
357
  }
135
358
  var STATUS_WORDS = {
136
359
  passed: ["passed", "success", "succeeded", "ok"],
@@ -141,7 +364,7 @@ var STATUS_WORDS = {
141
364
  };
142
365
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
143
366
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-knqbxp56.js
144
- function tt2(i, { units: r = "iec", dp: t = 1, locale: n } = {}) {
367
+ function tt(i, { units: r = "iec", dp: t = 1, locale: n } = {}) {
145
368
  let e = r === "si" ? 1000 : 1024;
146
369
  if (Math.abs(i) < e)
147
370
  return `${i} B`;
@@ -179,7 +402,7 @@ var ESCAPE = String.fromCharCode(27);
179
402
  function textWidth(text) {
180
403
  return Bun.stringWidth(text);
181
404
  }
182
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process4.stdout, env = process4.env } = {}) {
405
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
183
406
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
184
407
  if (outputMode(stream, env) === "agent")
185
408
  return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
@@ -218,7 +441,7 @@ function narrow(rows, widths, limit) {
218
441
  }
219
442
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
220
443
  }
221
- function jsonText(value, replacer, { stream = process4.stdout, env = process4.env } = {}) {
444
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
222
445
  return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
223
446
  }
224
447
  function printJson(value) {
@@ -226,27 +449,27 @@ function printJson(value) {
226
449
  }
227
450
 
228
451
  // ../kit/src/help.ts
229
- import process5 from "process";
452
+ import process8 from "process";
230
453
  var OPTIONAL = /\[[^\]]+\]/g;
231
454
  var USAGE_PREFIX = /^usage:\s*/i;
232
455
  var FULL_STOP = /\.$/;
233
- function usageLine(usage, colors = paint(process5.stdout)) {
456
+ function usageLine(usage, colors = paint(process8.stdout)) {
234
457
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
235
458
  }
236
- function helpText(usage, options, colors = paint(process5.stdout), { examples = [], replaces, exits = [] } = {}) {
459
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
237
460
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
238
461
  `);
239
462
  }
240
- function exitRows(exits, colors = paint(process5.stdout)) {
463
+ function exitRows(exits, colors = paint(process8.stdout)) {
241
464
  if (exits.length === 0)
242
465
  return [];
243
466
  const width = Math.max(...exits.map(([code]) => String(code).length));
244
467
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
245
468
  }
246
- function replacesRows(replaces, colors = paint(process5.stdout)) {
469
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
247
470
  return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
248
471
  }
249
- function wantsHelpJson(env = process5.env) {
472
+ function wantsHelpJson(env = process8.env) {
250
473
  return env.KIT_HELP === "json";
251
474
  }
252
475
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -265,12 +488,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
265
488
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
266
489
  };
267
490
  }
268
- function exampleRows(examples, colors = paint(process5.stdout)) {
491
+ function exampleRows(examples, colors = paint(process8.stdout)) {
269
492
  if (examples.length === 0 || outputMode() === "agent")
270
493
  return [];
271
494
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
272
495
  }
273
- function optionRows(options, colors = paint(process5.stdout)) {
496
+ function optionRows(options, colors = paint(process8.stdout)) {
274
497
  const rows = Object.entries(options).map(([name, option]) => {
275
498
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
276
499
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -371,7 +594,7 @@ var OUTPUT_OPTIONS = {
371
594
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
372
595
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
373
596
  };
374
- function applyOutput(color, plain, env = process6.env) {
597
+ function applyOutput(color, plain, env = process9.env) {
375
598
  const when = plain === true ? "never" : color ?? "auto";
376
599
  if (when === "auto")
377
600
  return;
@@ -542,7 +765,7 @@ function nearestOption(message, options, allowNegative) {
542
765
  }
543
766
  // ../kit/src/process.ts
544
767
  import { constants } from "os";
545
- import process7 from "process";
768
+ import process10 from "process";
546
769
  var KILL_GRACE_MS = 2000;
547
770
  function exitCodeOf(code, signal) {
548
771
  if (code !== null)
@@ -562,7 +785,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
562
785
  return;
563
786
  try {
564
787
  if (grouped)
565
- process7.kill(-proc.pid, killing);
788
+ process10.kill(-proc.pid, killing);
566
789
  else
567
790
  proc.kill(killing);
568
791
  } catch {}
@@ -636,15 +859,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
636
859
  var RESET_STYLE = `${ESC}[0m`;
637
860
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
638
861
  // ../kit/src/cli.ts
639
- import { readFileSync, realpathSync } from "fs";
640
- import { dirname as dirname2, join as join2 } from "path";
641
- import process9 from "process";
862
+ import { readFileSync as readFileSync2, realpathSync } from "fs";
863
+ import { dirname as dirname3, join as join5 } from "path";
864
+ import process12 from "process";
642
865
 
643
866
  // ../kit/src/usage.ts
644
867
  import { appendFileSync, mkdirSync } from "fs";
645
- import { homedir } from "os";
646
- import { dirname, isAbsolute, join } from "path";
647
- import process8 from "process";
868
+ import { homedir as homedir3 } from "os";
869
+ import { dirname as dirname2, isAbsolute, join as join4 } from "path";
870
+ import process11 from "process";
648
871
 
649
872
  // ../kit/src/logs.ts
650
873
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -658,14 +881,14 @@ var usageError;
658
881
  function noteUsageError(message) {
659
882
  usageError = message;
660
883
  }
661
- function stateHome(env = process8.env) {
884
+ function stateHome(env = process11.env) {
662
885
  const dir = env.XDG_STATE_HOME;
663
- return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
886
+ return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
664
887
  }
665
- function usagePath(env = process8.env) {
666
- return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
888
+ function usagePath(env = process11.env) {
889
+ return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
667
890
  }
668
- function usageRecorded(env = process8.env) {
891
+ function usageRecorded(env = process11.env) {
669
892
  const off = env.KAYNOOO_CLI_NO_USAGE;
670
893
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
671
894
  }
@@ -679,12 +902,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
679
902
  usageError = undefined;
680
903
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
681
904
  }
682
- function recordUsage(entry, env = process8.env) {
905
+ function recordUsage(entry, env = process11.env) {
683
906
  if (!usageRecorded(env))
684
907
  return;
685
908
  try {
686
909
  const path = usagePath(env);
687
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
910
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
688
911
  appendFileSync(path, `${JSON.stringify(entry)}
689
912
  `, { mode: 384 });
690
913
  } catch {}
@@ -770,8 +993,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
770
993
  `);
771
994
  }
772
995
  function printError(prefix, message, hint, cause) {
773
- const colors = paint(process9.stderr);
774
- const styled = takesControlCodes(process9.stderr);
996
+ const colors = paint(process12.stderr);
997
+ const styled = takesControlCodes(process12.stderr);
775
998
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
776
999
  const under = (label, text, tint) => text === undefined ? "" : `
777
1000
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -814,11 +1037,11 @@ async function dispatch(level, typed, { version, redact }) {
814
1037
  }
815
1038
  }
816
1039
  if (name === undefined && level.path.length > 1) {
817
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stderr));
1040
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
818
1041
  return 2;
819
1042
  }
820
1043
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
821
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stdout));
1044
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
822
1045
  return 0;
823
1046
  }
824
1047
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -935,17 +1158,17 @@ async function printCandidates(found) {
935
1158
  return 0;
936
1159
  }
937
1160
  function packageVersion(entry = Bun.main) {
938
- for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1161
+ for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
939
1162
  try {
940
- const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
1163
+ const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
941
1164
  if (typeof version === "string")
942
1165
  return version;
943
1166
  } catch {}
944
- if (dirname2(dir) === dir)
1167
+ if (dirname3(dir) === dir)
945
1168
  return "0.0.0";
946
1169
  }
947
1170
  }
948
- async function runCli(cli, argv = process9.argv.slice(2)) {
1171
+ async function runCli(cli, argv = process12.argv.slice(2)) {
949
1172
  const version = cli.version ?? packageVersion();
950
1173
  if (argv[0] === COMPLETE)
951
1174
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -972,7 +1195,7 @@ function commandPath(scope, argv) {
972
1195
  }
973
1196
  return path.length === 0 ? undefined : path.join(" ");
974
1197
  }
975
- async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
1198
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
976
1199
  if (argv[0] === COMPLETE)
977
1200
  return printCandidates(leafCandidates(run, argv.slice(1)));
978
1201
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1016,7 +1239,7 @@ function parseSize(text, bareUnit = 1) {
1016
1239
  return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
1017
1240
  }
1018
1241
  // ../kit/src/watch.ts
1019
- import process10 from "process";
1242
+ import process13 from "process";
1020
1243
  import { format } from "util";
1021
1244
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1022
1245
  var DEFAULT_SECONDS = 2;
@@ -1038,7 +1261,7 @@ function withoutWatch(args) {
1038
1261
  }
1039
1262
  return rest;
1040
1263
  }
1041
- async function watching(value, step, stream = process10.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1264
+ async function watching(value, step, stream = process13.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1042
1265
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1043
1266
  if (!takesControlCodes(stream))
1044
1267
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1046,12 +1269,12 @@ async function watching(value, step, stream = process10.stdout, sleep = Bun.slee
1046
1269
  for (let round = 0;round < rounds; round++) {
1047
1270
  const held = [];
1048
1271
  const { log, info } = console;
1049
- const write = process10.stdout.write.bind(process10.stdout);
1272
+ const write = process13.stdout.write.bind(process13.stdout);
1050
1273
  const hold = (...parts) => void held.push(`${format(...parts)}
1051
1274
  `);
1052
1275
  console.log = hold;
1053
1276
  console.info = hold;
1054
- process10.stdout.write = (text) => {
1277
+ process13.stdout.write = (text) => {
1055
1278
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1056
1279
  return true;
1057
1280
  };
@@ -1060,7 +1283,7 @@ async function watching(value, step, stream = process10.stdout, sleep = Bun.slee
1060
1283
  } finally {
1061
1284
  console.log = log;
1062
1285
  console.info = info;
1063
- process10.stdout.write = write;
1286
+ process13.stdout.write = write;
1064
1287
  }
1065
1288
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1066
1289
  await sleep(interval);
@@ -1068,7 +1291,7 @@ async function watching(value, step, stream = process10.stdout, sleep = Bun.slee
1068
1291
  return code;
1069
1292
  }
1070
1293
  // src/pid.ts
1071
- import process12 from "process";
1294
+ import process15 from "process";
1072
1295
 
1073
1296
  // src/mask.ts
1074
1297
  import { basename } from "path";
@@ -1459,9 +1682,9 @@ function limitLine(limits, name) {
1459
1682
  return limit === undefined ? "-" : `soft ${limit.soft}, hard ${limit.hard}`;
1460
1683
  }
1461
1684
  function render(info, showEnv) {
1462
- const colors = paint(process12.stdout);
1685
+ const colors = paint(process15.stdout);
1463
1686
  const memory = info.memory;
1464
- const size = (bytes) => bytes === undefined ? "-" : tt2(bytes);
1687
+ const size = (bytes) => bytes === undefined ? "-" : tt(bytes);
1465
1688
  const rows = [
1466
1689
  ["Executable", info.exe ?? "-"],
1467
1690
  ["Directory", info.cwd ?? "-"],
@@ -1512,10 +1735,10 @@ async function pid(args) {
1512
1735
 
1513
1736
  // src/ports.ts
1514
1737
  import { basename as basename2 } from "path";
1515
- import process14 from "process";
1738
+ import process17 from "process";
1516
1739
 
1517
1740
  // ../kit/src/prompt.ts
1518
- import process13 from "process";
1741
+ import process16 from "process";
1519
1742
 
1520
1743
  // ../kit/src/picker/score.ts
1521
1744
  var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
@@ -1525,7 +1748,9 @@ var NONE = Number.NEGATIVE_INFINITY;
1525
1748
  var IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
1526
1749
  var PASTE_START = "\x1B[200~";
1527
1750
  var PASTE_END = "\x1B[201~";
1528
- var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
1751
+ var KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
1752
+ var MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
1753
+ var WHEEL_LINES = 3;
1529
1754
  var KEYS = {
1530
1755
  "\x1B[A": "up",
1531
1756
  "\x1BOA": "up",
@@ -1554,9 +1779,15 @@ var KEYS = {
1554
1779
  "\x1BOP": "help",
1555
1780
  "\x1B[11~": "help"
1556
1781
  };
1782
+ function repeat(value, count) {
1783
+ return Array.from({ length: count }).fill(value);
1784
+ }
1557
1785
  function parseKeys(input, paste = { active: false }, ctrls = []) {
1558
1786
  const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
1559
1787
  return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
1788
+ const wheel = MOUSE.exec(sequence)?.[1];
1789
+ if (wheel !== undefined)
1790
+ return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
1560
1791
  const named = codes.get(sequence);
1561
1792
  const key = named === undefined ? KEYS[sequence] : { ctrl: named };
1562
1793
  if (sequence === PASTE_START || sequence === PASTE_END) {
@@ -1599,21 +1830,18 @@ function asking(colors, question, typed, keys) {
1599
1830
  function answer(colors, question, state, picked) {
1600
1831
  return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1601
1832
  }
1602
- async function ask(question, { hint, terminal = process13 }, render, press) {
1833
+ async function ask(question, { hint, terminal = process16 }, render, press) {
1603
1834
  const { stdin, stderr } = terminal;
1604
1835
  if (!isInteractive(terminal))
1605
1836
  fail(`cannot ask "${question}" off a terminal`, 2, hint);
1606
1837
  const colors = paint(stderr);
1607
- let drawn = [];
1608
1838
  let current = "asking";
1609
1839
  let outcome;
1610
1840
  const columns = () => stderr.columns || 80;
1611
- const draw = (state) => {
1841
+ const draw = (state, last = false) => {
1612
1842
  const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
1613
- const rows = drawn.reduce((sum, line) => sum + Math.max(1, Math.ceil(Bun.stringWidth(line) / columns())), 0);
1614
- stderr.write(`${rows > 1 ? `\x1B[${rows - 1}A` : ""}\r\x1B[0J${frame.join(`
1615
- `)}`);
1616
- drawn = frame;
1843
+ stderr.write(`\r\x1B[0J${frame.join(`
1844
+ `)}${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}`);
1617
1845
  current = state;
1618
1846
  };
1619
1847
  const redraw = () => draw(current);
@@ -1649,7 +1877,7 @@ async function ask(question, { hint, terminal = process13 }, render, press) {
1649
1877
  });
1650
1878
  } finally {
1651
1879
  stderr.off?.("resize", redraw);
1652
- draw(outcome ?? "cancel");
1880
+ draw(outcome ?? "cancel", true);
1653
1881
  stderr.write(`
1654
1882
  \x1B[?25h\x1B[?2004l`);
1655
1883
  stdin.setRawMode(false);
@@ -1746,6 +1974,7 @@ var options2 = {
1746
1974
  watch: watchOption("the ports"),
1747
1975
  force: { type: "boolean", description: "with --kill, SIGKILL what SIGTERM did not stop within --grace" },
1748
1976
  yes: { type: "boolean", short: "y", description: "with --kill, do not ask first" },
1977
+ quiet: { type: "boolean", short: "q", description: "with --kill, print nothing about what was stopped" },
1749
1978
  grace: { type: "string", description: "with --force, how long SIGTERM gets before SIGKILL (5s)" }
1750
1979
  };
1751
1980
  function buildRows(sockets, owners, procs, containers) {
@@ -1787,7 +2016,7 @@ function refusal(row, proc, guard) {
1787
2016
  return reason === undefined ? undefined : `pid ${row.pid} is ${reason}`;
1788
2017
  }
1789
2018
  function render2(rows) {
1790
- const colors = paint(process14.stdout);
2019
+ const colors = paint(process17.stdout);
1791
2020
  const cells = rows.map((row) => [
1792
2021
  colors.cyan(String(row.port)),
1793
2022
  row.protocol,
@@ -1799,12 +2028,12 @@ function render2(rows) {
1799
2028
  return table([["PORT", "PROTO", "ADDRESS", "PID", "COMMAND", "CWD"], ...cells], { header: true });
1800
2029
  }
1801
2030
  async function stop(port, rows, procs, values) {
1802
- const guard = { uid: process14.getuid?.() ?? -1, mine: new Set(ancestry(process14.pid, procs)) };
2031
+ const guard = { uid: process17.getuid?.() ?? -1, mine: new Set(ancestry(process17.pid, procs)) };
1803
2032
  const targets = new Map;
1804
2033
  for (const row of rows) {
1805
2034
  const reason = refusal(row, row.pid === undefined ? undefined : procs.get(row.pid), guard);
1806
2035
  if (reason !== undefined)
1807
- console.error(`port ${port}: ${reason}`);
2036
+ problem(`port ${port}: ${reason}`);
1808
2037
  else if (row.pid !== undefined)
1809
2038
  targets.set(row.pid, row);
1810
2039
  }
@@ -1812,16 +2041,16 @@ async function stop(port, rows, procs, values) {
1812
2041
  return 1;
1813
2042
  const names = [...targets].map(([pid, row]) => `${pid} (${truncate(row.command ?? "", 40)})`).join(", ");
1814
2043
  if (values.yes !== true) {
1815
- if (!process14.stdin.isTTY)
2044
+ if (!process17.stdin.isTTY)
1816
2045
  fail(`stopping ${names} needs a terminal to ask on: pass --yes`, 2);
1817
2046
  if (await confirm(`Stop ${names}?`, { default: false }) !== true)
1818
2047
  return 1;
1819
2048
  }
1820
2049
  const outcome = await terminate([...targets.keys()], { escalate: values.force === true, graceMs: duration(values.grace, "grace", 5000) });
1821
- for (const pid of [...outcome.terminated, ...outcome.killed])
2050
+ for (const pid of values.quiet === true ? [] : [...outcome.terminated, ...outcome.killed])
1822
2051
  console.log(`stopped ${pid}${outcome.killed.includes(pid) ? " (SIGKILL)" : ""}`);
1823
2052
  for (const pid of outcome.survived)
1824
- console.error(`${pid} is still running${values.force === true ? "" : ", pass --force to SIGKILL it"}`);
2053
+ problem(`${pid} is still running${values.force === true ? "" : ", pass --force to SIGKILL it"}`);
1825
2054
  return outcome.survived.length === 0 ? 0 : 1;
1826
2055
  }
1827
2056
  async function ports(args) {
@@ -1843,7 +2072,7 @@ async function ports(args) {
1843
2072
  badUsage(`<port> takes a whole number from 1 to 65535, not ${given}`);
1844
2073
  if (values.kill === true && port === undefined)
1845
2074
  badUsage("--kill takes the port to free: ports <port> --kill");
1846
- const [sockets, owners, procs] = await Promise.all([readSockets(), socketOwners(), snapshot("/proc", (uid) => uid === process14.getuid?.())]);
2075
+ const [sockets, owners, procs] = await Promise.all([readSockets(), socketOwners(), snapshot("/proc", (uid) => uid === process17.getuid?.())]);
1847
2076
  const byPid = new Map(procs.map((proc) => [proc.pid, proc]));
1848
2077
  const wanted = sockets.filter((socket) => port === undefined || socket.port === port);
1849
2078
  const needsDocker = wanted.some((socket) => {
@@ -1852,7 +2081,7 @@ async function ports(args) {
1852
2081
  });
1853
2082
  const rows = buildRows(wanted, owners, byPid, needsDocker ? await dockerContainers() : []);
1854
2083
  if (port !== undefined && rows.length === 0) {
1855
- console.error(`nothing listens on port ${port}`);
2084
+ problem(`nothing listens on port ${port}`);
1856
2085
  return 1;
1857
2086
  }
1858
2087
  if (values.kill === true && port !== undefined)
@@ -1864,17 +2093,17 @@ async function ports(args) {
1864
2093
  console.log(render2(rows));
1865
2094
  const unknown = rows.filter((row) => row.pid === undefined && row.container === undefined).length;
1866
2095
  if (unknown > 0)
1867
- console.error(paint(process14.stderr).dim(`${unknown} ${unknown === 1 ? "port has" : "ports have"} an owner this user cannot read, shown as -`));
2096
+ console.error(paint(process17.stderr).dim(`${unknown} ${unknown === 1 ? "port has" : "ports have"} an owner this user cannot read, shown as -`));
1868
2097
  return 0;
1869
2098
  }
1870
2099
 
1871
2100
  // src/procs.ts
1872
- import { existsSync } from "fs";
1873
- import { homedir as homedir2 } from "os";
1874
- import process15 from "process";
2101
+ import { existsSync as existsSync3 } from "fs";
2102
+ import { homedir as homedir4 } from "os";
2103
+ import process18 from "process";
1875
2104
 
1876
2105
  // src/select.ts
1877
- import { basename as basename3, join as join3, relative } from "path";
2106
+ import { basename as basename3, join as join6, relative } from "path";
1878
2107
  var BROWSERS = /^(?:chrom(?:e|ium)(?:-browser)?|google-chrome(?:-stable|-beta|-unstable)?|chrome_crashpad_handler|chrome-headless-shell|headless_shell|chromium-headless-shell|brave|brave-browser|msedge|microsoft-edge|webkitwebprocess|webkitnetworkprocess|webkitgpuprocess|minibrowser|webkitwebdriver|wpewebprocess|wpenetworkprocess|bun-webview.*)$/i;
1879
2108
  var NATIVE = new Set(["rust-analyzer", "gopls", "clangd", "lua-language-server", "pyright-langserver", "pylsp", "intelephense", "phpactor", "tsgo", "esbuild", "biome", "ruff", "phpunit", "pytest", "vitest", "jest"]);
1880
2109
  var RUNTIMES = new Set(["node", "bun", "bunx", "deno", "nodejs"]);
@@ -1911,9 +2140,9 @@ function projectOf(cwd, exists, home) {
1911
2140
  if (cwd === undefined || !cwd.startsWith(`${home}/`))
1912
2141
  return;
1913
2142
  const folders = [];
1914
- for (let dir = cwd;dir.startsWith(`${home}/`); dir = join3(dir, ".."))
2143
+ for (let dir = cwd;dir.startsWith(`${home}/`); dir = join6(dir, ".."))
1915
2144
  folders.push(dir);
1916
- return folders.find((dir) => exists(join3(dir, ".git"))) ?? folders.find((dir) => MARKERS.some((marker) => exists(join3(dir, marker))));
2145
+ return folders.find((dir) => exists(join6(dir, ".git"))) ?? folders.find((dir) => MARKERS.some((marker) => exists(join6(dir, marker))));
1917
2146
  }
1918
2147
  function isOrphan(proc, byPid) {
1919
2148
  if (proc.unit?.endsWith(".service") === true)
@@ -1999,6 +2228,7 @@ var options3 = {
1999
2228
  kill: { type: "boolean", conflicts: ["watch"], description: "stop the listed processes: a dry run without --yes" },
2000
2229
  watch: watchOption("the processes"),
2001
2230
  yes: { type: "boolean", short: "y", description: "with --kill, really stop them, without asking" },
2231
+ quiet: { type: "boolean", short: "q", description: "with --kill --yes, print nothing about what was stopped" },
2002
2232
  "min-mem": { type: "string", description: "heavy from this resident size (500M), and the least a left over process must use to be listed; a bare number counts megabytes" },
2003
2233
  older: { type: "string", description: "only processes at least this old: 30m, 2h, 1d" },
2004
2234
  grace: { type: "string", description: "how long SIGTERM gets before SIGKILL (5s)" }
@@ -2020,11 +2250,11 @@ function summary(group) {
2020
2250
  };
2021
2251
  }
2022
2252
  function render3(groups) {
2023
- const colors = paint(process15.stdout);
2253
+ const colors = paint(process18.stdout);
2024
2254
  const rows = groups.map((group) => [
2025
2255
  group.origin,
2026
2256
  String(group.members.length),
2027
- tt2(group.rss),
2257
+ tt(group.rss),
2028
2258
  formatSeconds(group.oldestMs / 1000),
2029
2259
  colors.dim(truncate(Object.entries(Object.groupBy(group.members, ({ tool }) => tool)).map(([tool, list]) => `${tool}${list.length > 1 ? ` x${list.length}` : ""}`).join(", "), 50)),
2030
2260
  group.orphans === 0 ? "" : colors.yellow(`${group.orphans} orphaned`)
@@ -2047,10 +2277,10 @@ async function procs(args) {
2047
2277
  if (values.watch !== undefined)
2048
2278
  return watching(values.watch, async () => procs(withoutWatch(args)));
2049
2279
  const olderMs = values.older === undefined ? undefined : duration(values.older, "older", 0, "m");
2050
- const uid = process15.getuid?.() ?? -1;
2280
+ const uid = process18.getuid?.() ?? -1;
2051
2281
  const all = await snapshot("/proc", (owner) => owner === uid);
2052
- const mine = new Set(ancestry(process15.pid, new Map(all.map((proc) => [proc.pid, proc]))));
2053
- const { groups, protectedCount } = selectGroups(all, { guard: { uid, mine }, now: Date.now(), home: homedir2(), exists: existsSync, minMem, olderMs });
2282
+ const mine = new Set(ancestry(process18.pid, new Map(all.map((proc) => [proc.pid, proc]))));
2283
+ const { groups, protectedCount } = selectGroups(all, { guard: { uid, mine }, now: Date.now(), home: homedir4(), exists: existsSync3, minMem, olderMs });
2054
2284
  const pids = groups.flatMap((group) => group.members.map(({ proc }) => proc.pid));
2055
2285
  const show = (extra = {}) => {
2056
2286
  if (values.json === true) {
@@ -2062,22 +2292,23 @@ async function procs(args) {
2062
2292
  if (values.kill !== true || pids.length === 0 || values.yes !== true) {
2063
2293
  show();
2064
2294
  if (values.json !== true && protectedCount > 0)
2065
- console.error(paint(process15.stderr).dim(`${protectedCount} more left out: shells, terminals and this command's ancestors are never touched`));
2295
+ console.error(paint(process18.stderr).dim(`${protectedCount} more left out: shells, terminals and this command's ancestors are never touched`));
2066
2296
  if (values.kill === true && pids.length > 0)
2067
2297
  console.error(`dry run: would stop ${pids.length} ${pids.length === 1 ? "process" : "processes"} (${pids.join(" ")}), pass --yes to do it`);
2068
2298
  return 0;
2069
2299
  }
2070
2300
  const outcome = await terminate(pids, { escalate: true, graceMs: duration(values.grace, "grace", 5000) });
2071
- show({ stopped: [...outcome.terminated, ...outcome.killed], killed: outcome.killed, survived: outcome.survived });
2072
- if (values.json !== true)
2301
+ if (values.quiet !== true || values.json === true)
2302
+ show({ stopped: [...outcome.terminated, ...outcome.killed], killed: outcome.killed, survived: outcome.survived });
2303
+ if (values.json !== true && values.quiet !== true)
2073
2304
  console.log(`stopped ${outcome.terminated.length + outcome.killed.length} of ${pids.length}${outcome.killed.length === 0 ? "" : `, ${outcome.killed.length} needed SIGKILL`}`);
2074
2305
  if (outcome.survived.length > 0)
2075
- console.error(`still running: ${outcome.survived.join(" ")}`);
2306
+ problem(`still running: ${outcome.survived.join(" ")}`);
2076
2307
  return outcome.survived.length === 0 ? 0 : 1;
2077
2308
  }
2078
2309
 
2079
2310
  // src/proc-cli.ts
2080
- process16.exitCode = await runCli({
2311
+ process19.exitCode = await runCli({
2081
2312
  name: "proc",
2082
2313
  about: "what a process is, who listens on a port and which dev processes are worth cleaning, read from /proc",
2083
2314
  replaces: "cat /proc/<pid>/..., ss -ltnp, lsof -i and pgrep -f one-liners",