@kaynooo/cli-env 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ev.js CHANGED
@@ -2,16 +2,34 @@
2
2
  // @bun
3
3
 
4
4
  // src/ev.ts
5
- import process15 from "process";
5
+ import process17 from "process";
6
6
  // ../kit/src/args.ts
7
- import process9 from "process";
7
+ import process10 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process6 from "process";
11
+ import process7 from "process";
12
+
13
+ // ../kit/src/mode.ts
14
+ import process2 from "process";
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
29
+ }
12
30
 
13
31
  // ../kit/src/style.ts
14
- import process5 from "process";
32
+ import process6 from "process";
15
33
 
16
34
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
17
35
  function x(s) {
@@ -278,13 +296,13 @@ var t = le();
278
296
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
279
297
  import { homedir as homedir2 } from "os";
280
298
  import { join as join3, resolve as resolve2 } from "path";
281
- import process4 from "process";
299
+ import process5 from "process";
282
300
 
283
301
  // ../kit/src/config.ts
284
302
  import { existsSync } from "fs";
285
303
  import { dirname, join, resolve } from "path";
286
- import process2 from "process";
287
- function findUp(names, from = process2.cwd(), stop = () => false) {
304
+ import process3 from "process";
305
+ function findUp(names, from = process3.cwd(), stop = () => false) {
288
306
  const wanted = typeof names === "string" ? [names] : names;
289
307
  for (let dir = resolve(from);; dir = dirname(dir)) {
290
308
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -298,9 +316,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
298
316
  // ../kit/src/user-config.ts
299
317
  import { homedir } from "os";
300
318
  import { join as join2 } from "path";
301
- import process3 from "process";
319
+ import process4 from "process";
302
320
  function configBase(where = {}) {
303
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
321
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
304
322
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
305
323
  }
306
324
  function userConfigPath(bin, where = {}) {
@@ -333,10 +351,30 @@ function isColorSpec(spec) {
333
351
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
334
352
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
335
353
  }
336
- function tinted(colors, spec) {
354
+ var CUBE = [0, 95, 135, 175, 215, 255];
355
+ function cubeLevel(channel) {
356
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
357
+ }
358
+ function nearest256(hex) {
359
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
360
+ const levels = rgb.map(cubeLevel);
361
+ const cube = levels.map((level) => CUBE[level]);
362
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
363
+ const greyValue = 8 + grey * 10;
364
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
365
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
366
+ }
367
+ function hasTrueColor(env) {
368
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
369
+ }
370
+ function tinted(colors, spec, env = process5.env) {
337
371
  if (typeof spec === "number")
338
372
  return colors.ansi256(spec);
339
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
373
+ return spec.trim().split(SPACES).reduce((chain, token) => {
374
+ if (HEX.test(token))
375
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
376
+ return chain[token] ?? chain;
377
+ }, colors);
340
378
  }
341
379
  function isRecord(value) {
342
380
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -420,7 +458,7 @@ function warnOnce(message) {
420
458
  function isPath(chosen) {
421
459
  return chosen.includes("/") || chosen.endsWith(".json");
422
460
  }
423
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
461
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
424
462
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
425
463
  const sources = [];
426
464
  const chosen = env.KIT_THEME ?? "";
@@ -450,7 +488,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
450
488
  var current;
451
489
  var currentKey = "";
452
490
  function activeTheme() {
453
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
491
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
454
492
  if (current === undefined || key !== currentKey) {
455
493
  current = loadTheme();
456
494
  currentKey = key;
@@ -460,32 +498,32 @@ function activeTheme() {
460
498
 
461
499
  // ../kit/src/style.ts
462
500
  var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
463
- function takesControlCodes(stream, env = process5.env) {
464
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
501
+ function takesControlCodes(stream, env = process6.env) {
502
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
465
503
  }
466
- function paint(stream, env = process5.env) {
504
+ function paint(stream, env = process6.env) {
467
505
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
468
506
  }
469
- function marked(mark, text, stream, detail, env = process5.env) {
507
+ function marked(mark, text, stream, detail, env = process6.env) {
470
508
  const colors = paint(stream, env);
471
509
  let head = MARK_WORDS[mark];
472
510
  if (takesControlCodes(stream, env)) {
473
511
  const { theme } = activeTheme();
474
- head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
512
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
475
513
  }
476
514
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
477
515
  }
478
516
  function ok(text, detail) {
479
- console.log(marked("ok", text, process5.stdout, detail));
517
+ console.log(marked("ok", text, process6.stdout, detail));
480
518
  }
481
- function role(name, stream, env = process5.env) {
519
+ function role(name, stream, env = process6.env) {
482
520
  const colors = paint(stream, env);
483
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
521
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
484
522
  }
485
523
  var STATUS_WORDS = {
486
524
  passed: ["passed", "success", "succeeded", "ok"],
487
525
  failed: ["failed", "failure", "error", "errored"],
488
- running: ["running", "in_progress", "started"],
526
+ running: ["running", "in_progress", "started", "holding"],
489
527
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
490
528
  skipped: ["skipped", "cancelled", "canceled", "manual"]
491
529
  };
@@ -504,8 +542,11 @@ var ESCAPE = String.fromCharCode(27);
504
542
  function textWidth(text) {
505
543
  return Bun.stringWidth(text);
506
544
  }
507
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
545
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
508
546
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
547
+ if (outputMode(stream, env) === "agent")
548
+ return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
549
+ `);
509
550
  const widths = [];
510
551
  for (const row of cells) {
511
552
  for (const [index, cell] of row.entries())
@@ -540,32 +581,35 @@ function narrow(rows, widths, limit) {
540
581
  }
541
582
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
542
583
  }
584
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
585
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
586
+ }
543
587
  function printJson(value) {
544
- console.log(JSON.stringify(value, undefined, 2));
588
+ console.log(jsonText(value));
545
589
  }
546
590
 
547
591
  // ../kit/src/help.ts
548
- import process7 from "process";
592
+ import process8 from "process";
549
593
  var OPTIONAL = /\[[^\]]+\]/g;
550
594
  var USAGE_PREFIX = /^usage:\s*/i;
551
595
  var FULL_STOP = /\.$/;
552
- function usageLine(usage, colors = paint(process7.stdout)) {
596
+ function usageLine(usage, colors = paint(process8.stdout)) {
553
597
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
554
598
  }
555
- function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
599
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
556
600
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
557
601
  `);
558
602
  }
559
- function exitRows(exits, colors = paint(process7.stdout)) {
603
+ function exitRows(exits, colors = paint(process8.stdout)) {
560
604
  if (exits.length === 0)
561
605
  return [];
562
606
  const width = Math.max(...exits.map(([code]) => String(code).length));
563
607
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
564
608
  }
565
- function replacesRows(replaces, colors = paint(process7.stdout)) {
566
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
609
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
610
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
567
611
  }
568
- function wantsHelpJson(env = process7.env) {
612
+ function wantsHelpJson(env = process8.env) {
569
613
  return env.KIT_HELP === "json";
570
614
  }
571
615
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -584,12 +628,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
584
628
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
585
629
  };
586
630
  }
587
- function exampleRows(examples, colors = paint(process7.stdout)) {
588
- if (examples.length === 0)
631
+ function exampleRows(examples, colors = paint(process8.stdout)) {
632
+ if (examples.length === 0 || outputMode() === "agent")
589
633
  return [];
590
634
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
591
635
  }
592
- function optionRows(options, colors = paint(process7.stdout)) {
636
+ function optionRows(options, colors = paint(process8.stdout)) {
593
637
  const rows = Object.entries(options).map(([name, option]) => {
594
638
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
595
639
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -621,10 +665,10 @@ function closest(name, names) {
621
665
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
622
666
  }
623
667
  // ../kit/src/input.ts
624
- import process8 from "process";
668
+ import process9 from "process";
625
669
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
626
670
  if (path === "-") {
627
- if (process8.stdin.isTTY)
671
+ if (process9.stdin.isTTY)
628
672
  fail(noStdin);
629
673
  return Bun.stdin.text();
630
674
  }
@@ -683,7 +727,7 @@ var OUTPUT_OPTIONS = {
683
727
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
684
728
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
685
729
  };
686
- function applyOutput(color, plain, env = process9.env) {
730
+ function applyOutput(color, plain, env = process10.env) {
687
731
  const when = plain === true ? "never" : color ?? "auto";
688
732
  if (when === "auto")
689
733
  return;
@@ -860,13 +904,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
860
904
  // ../kit/src/cli.ts
861
905
  import { readFileSync as readFileSync2, realpathSync } from "fs";
862
906
  import { dirname as dirname3, join as join5 } from "path";
863
- import process11 from "process";
907
+ import process12 from "process";
864
908
 
865
909
  // ../kit/src/usage.ts
866
910
  import { appendFileSync, mkdirSync } from "fs";
867
911
  import { homedir as homedir3 } from "os";
868
912
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
869
- import process10 from "process";
913
+ import process11 from "process";
870
914
 
871
915
  // ../kit/src/logs.ts
872
916
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -880,14 +924,14 @@ var usageError;
880
924
  function noteUsageError(message) {
881
925
  usageError = message;
882
926
  }
883
- function stateHome(env = process10.env) {
927
+ function stateHome(env = process11.env) {
884
928
  const dir = env.XDG_STATE_HOME;
885
929
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
886
930
  }
887
- function usagePath(env = process10.env) {
931
+ function usagePath(env = process11.env) {
888
932
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
889
933
  }
890
- function usageRecorded(env = process10.env) {
934
+ function usageRecorded(env = process11.env) {
891
935
  const off = env.KAYNOOO_CLI_NO_USAGE;
892
936
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
893
937
  }
@@ -901,7 +945,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
901
945
  usageError = undefined;
902
946
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
903
947
  }
904
- function recordUsage(entry, env = process10.env) {
948
+ function recordUsage(entry, env = process11.env) {
905
949
  if (!usageRecorded(env))
906
950
  return;
907
951
  try {
@@ -992,8 +1036,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
992
1036
  `);
993
1037
  }
994
1038
  function printError(prefix, message, hint, cause) {
995
- const colors = paint(process11.stderr);
996
- const styled = takesControlCodes(process11.stderr);
1039
+ const colors = paint(process12.stderr);
1040
+ const styled = takesControlCodes(process12.stderr);
997
1041
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
998
1042
  const under = (label, text, tint) => text === undefined ? "" : `
999
1043
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1036,11 +1080,11 @@ async function dispatch(level, typed, { version, redact }) {
1036
1080
  }
1037
1081
  }
1038
1082
  if (name === undefined && level.path.length > 1) {
1039
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stderr));
1083
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
1040
1084
  return 2;
1041
1085
  }
1042
1086
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1043
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stdout));
1087
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
1044
1088
  return 0;
1045
1089
  }
1046
1090
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1167,7 +1211,7 @@ function packageVersion(entry = Bun.main) {
1167
1211
  return "0.0.0";
1168
1212
  }
1169
1213
  }
1170
- async function runCli(cli, argv = process11.argv.slice(2)) {
1214
+ async function runCli(cli, argv = process12.argv.slice(2)) {
1171
1215
  const version = cli.version ?? packageVersion();
1172
1216
  if (argv[0] === COMPLETE)
1173
1217
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1194,7 +1238,7 @@ function commandPath(scope, argv) {
1194
1238
  }
1195
1239
  return path.length === 0 ? undefined : path.join(" ");
1196
1240
  }
1197
- async function runMain({ name, version, run, redact, usage }, argv = process11.argv.slice(2)) {
1241
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1198
1242
  if (argv[0] === COMPLETE)
1199
1243
  return printCandidates(leafCandidates(run, argv.slice(1)));
1200
1244
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1237,7 +1281,7 @@ var ACCOUNT_DIRS = new Glob("*/sessions");
1237
1281
  // src/commands/audit.ts
1238
1282
  import { stat as stat4 } from "fs/promises";
1239
1283
  import { relative, resolve as resolve3 } from "path";
1240
- import process13 from "process";
1284
+ import process14 from "process";
1241
1285
 
1242
1286
  // ../kit/src/shell.ts
1243
1287
  var SEPARATORS = new Set([`
@@ -2055,11 +2099,12 @@ async function isFolder(path) {
2055
2099
  }
2056
2100
  }
2057
2101
  function shown2(path) {
2058
- return path.startsWith(`${process13.cwd()}/`) ? relative(process13.cwd(), path) : path;
2102
+ return path.startsWith(`${process14.cwd()}/`) ? relative(process14.cwd(), path) : path;
2059
2103
  }
2060
2104
  async function fixAll(exposed, json) {
2061
2105
  const fixed = [];
2062
2106
  let left = false;
2107
+ const tint = role("path", process14.stdout);
2063
2108
  for (const { path, readable, group, tracked, secrets } of exposed) {
2064
2109
  const fix = secrets === undefined ? undefined : await fixCompose(path, group === true);
2065
2110
  const open = fix?.open ?? (readable && !await shutOthersOut(path, group === true) ? [path] : []);
@@ -2076,7 +2121,7 @@ async function fixAll(exposed, json) {
2076
2121
  ...readable && !open.includes(path) ? ["now unreadable by other accounts"] : [],
2077
2122
  ...tracked ? [`tracked by git: git rm --cached ${shellQuote(shown2(path))}, then ignore it`] : []
2078
2123
  ];
2079
- console.log(`${shown2(path)}
2124
+ console.log(`${tint(shown2(path))}
2080
2125
  ${lines.join(`
2081
2126
  `)}`);
2082
2127
  }
@@ -2111,7 +2156,8 @@ async function audit2(args) {
2111
2156
  console.log("no exposed .env file nor compose file writing a secret out");
2112
2157
  return 0;
2113
2158
  }
2114
- const uid = process13.getuid?.();
2159
+ const uid = process14.getuid?.();
2160
+ const tint = role("path", process14.stdout);
2115
2161
  for (const { path, readable, group, tracked, secrets } of exposed) {
2116
2162
  const sudo = uid !== undefined && uid !== 0 && (await stat4(path)).uid !== uid ? "sudo " : "";
2117
2163
  const problems = [
@@ -2119,7 +2165,7 @@ async function audit2(args) {
2119
2165
  ...readable ? [group === true ? `readable by its group or an ACL: ${sudo}chmod go-rwx ${shellQuote(shown2(path))}` : `readable by any account: ${sudo}chmod o-rwx ${shellQuote(shown2(path))}`] : [],
2120
2166
  ...tracked ? [`tracked by git: git rm --cached ${shellQuote(shown2(path))}, then ignore it`] : []
2121
2167
  ];
2122
- console.log(`${shown2(path)}
2168
+ console.log(`${tint(shown2(path))}
2123
2169
  ${problems.join(`
2124
2170
  `)}`);
2125
2171
  }
@@ -2127,6 +2173,7 @@ async function audit2(args) {
2127
2173
  }
2128
2174
 
2129
2175
  // src/commands/compare.ts
2176
+ import process15 from "process";
2130
2177
  var diffUsage = `ev diff <a> <b>
2131
2178
 
2132
2179
  Names the keys set in one file and not the other, never their values.
@@ -2160,7 +2207,9 @@ ${diffUsage}`);
2160
2207
  printJson({ a, b, onlyA, onlyB });
2161
2208
  return onlyA.length + onlyB.length === 0 ? 0 : 1;
2162
2209
  }
2163
- const lines = [...onlyA.map((key) => `only in ${a}: ${key}`), ...onlyB.map((key) => `only in ${b}: ${key}`)];
2210
+ const path = role("path", process15.stdout);
2211
+ const value = role("value", process15.stdout);
2212
+ const lines = [...onlyA.map((key) => `only in ${path(a)}: ${value(key)}`), ...onlyB.map((key) => `only in ${path(b)}: ${value(key)}`)];
2164
2213
  if (lines.length === 0)
2165
2214
  return 0;
2166
2215
  console.log(lines.join(`
@@ -2180,7 +2229,9 @@ async function missing(args) {
2180
2229
  }
2181
2230
  if (absent.length === 0)
2182
2231
  return 0;
2183
- console.log(absent.map((key) => `${key} (set in ${against}, not in ${file})`).join(`
2232
+ const path = role("path", process15.stdout);
2233
+ const value = role("value", process15.stdout);
2234
+ console.log(absent.map((key) => `${value(key)} (set in ${path(against)}, not in ${path(file)})`).join(`
2184
2235
  `));
2185
2236
  return 1;
2186
2237
  }
@@ -2719,7 +2770,7 @@ ${showUsage}`);
2719
2770
  }
2720
2771
 
2721
2772
  // src/commands/redact.ts
2722
- import process14 from "process";
2773
+ import process16 from "process";
2723
2774
 
2724
2775
  // src/redactor.ts
2725
2776
  var DIFF_START = /^(?:diff --git |@@ )/;
@@ -2859,13 +2910,13 @@ async function redact(args) {
2859
2910
  const redactor = new Redactor(known);
2860
2911
  const decoder = new TextDecoder;
2861
2912
  for await (const chunk of Bun.stdin.stream())
2862
- process14.stdout.write(redactor.push(decoder.decode(chunk, { stream: true })));
2863
- process14.stdout.write(redactor.push(decoder.decode()) + redactor.end());
2913
+ process16.stdout.write(redactor.push(decoder.decode(chunk, { stream: true })));
2914
+ process16.stdout.write(redactor.push(decoder.decode()) + redactor.end());
2864
2915
  return 0;
2865
2916
  }
2866
2917
 
2867
2918
  // src/ev.ts
2868
- process15.exitCode = await runCli({
2919
+ process17.exitCode = await runCli({
2869
2920
  name: "ev",
2870
2921
  about: ".env files listed and edited with secrets masked",
2871
2922
  replaces: "cat .env, grep on env files and editing them by hand",
package/dist/redact.js CHANGED
@@ -2,16 +2,34 @@
2
2
  // @bun
3
3
 
4
4
  // src/redact.ts
5
- import process14 from "process";
5
+ import process15 from "process";
6
6
  // ../kit/src/args.ts
7
- import process9 from "process";
7
+ import process10 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process6 from "process";
11
+ import process7 from "process";
12
+
13
+ // ../kit/src/mode.ts
14
+ import process2 from "process";
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
29
+ }
12
30
 
13
31
  // ../kit/src/style.ts
14
- import process5 from "process";
32
+ import process6 from "process";
15
33
 
16
34
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
17
35
  function x(s) {
@@ -278,13 +296,13 @@ var t = le();
278
296
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
279
297
  import { homedir as homedir2 } from "os";
280
298
  import { join as join3, resolve as resolve2 } from "path";
281
- import process4 from "process";
299
+ import process5 from "process";
282
300
 
283
301
  // ../kit/src/config.ts
284
302
  import { existsSync } from "fs";
285
303
  import { dirname, join, resolve } from "path";
286
- import process2 from "process";
287
- function findUp(names, from = process2.cwd(), stop = () => false) {
304
+ import process3 from "process";
305
+ function findUp(names, from = process3.cwd(), stop = () => false) {
288
306
  const wanted = typeof names === "string" ? [names] : names;
289
307
  for (let dir = resolve(from);; dir = dirname(dir)) {
290
308
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -298,9 +316,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
298
316
  // ../kit/src/user-config.ts
299
317
  import { homedir } from "os";
300
318
  import { join as join2 } from "path";
301
- import process3 from "process";
319
+ import process4 from "process";
302
320
  function configBase(where = {}) {
303
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
321
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
304
322
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
305
323
  }
306
324
  function userConfigPath(bin, where = {}) {
@@ -333,10 +351,30 @@ function isColorSpec(spec) {
333
351
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
334
352
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
335
353
  }
336
- function tinted(colors, spec) {
354
+ var CUBE = [0, 95, 135, 175, 215, 255];
355
+ function cubeLevel(channel) {
356
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
357
+ }
358
+ function nearest256(hex) {
359
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
360
+ const levels = rgb.map(cubeLevel);
361
+ const cube = levels.map((level) => CUBE[level]);
362
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
363
+ const greyValue = 8 + grey * 10;
364
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
365
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
366
+ }
367
+ function hasTrueColor(env) {
368
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
369
+ }
370
+ function tinted(colors, spec, env = process5.env) {
337
371
  if (typeof spec === "number")
338
372
  return colors.ansi256(spec);
339
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
373
+ return spec.trim().split(SPACES).reduce((chain, token) => {
374
+ if (HEX.test(token))
375
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
376
+ return chain[token] ?? chain;
377
+ }, colors);
340
378
  }
341
379
  function isRecord(value) {
342
380
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -420,7 +458,7 @@ function warnOnce(message) {
420
458
  function isPath(chosen) {
421
459
  return chosen.includes("/") || chosen.endsWith(".json");
422
460
  }
423
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
461
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
424
462
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
425
463
  const sources = [];
426
464
  const chosen = env.KIT_THEME ?? "";
@@ -450,7 +488,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
450
488
  var current;
451
489
  var currentKey = "";
452
490
  function activeTheme() {
453
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
491
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
454
492
  if (current === undefined || key !== currentKey) {
455
493
  current = loadTheme();
456
494
  currentKey = key;
@@ -460,32 +498,32 @@ function activeTheme() {
460
498
 
461
499
  // ../kit/src/style.ts
462
500
  var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
463
- function takesControlCodes(stream, env = process5.env) {
464
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
501
+ function takesControlCodes(stream, env = process6.env) {
502
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
465
503
  }
466
- function paint(stream, env = process5.env) {
504
+ function paint(stream, env = process6.env) {
467
505
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
468
506
  }
469
- function marked(mark, text, stream, detail, env = process5.env) {
507
+ function marked(mark, text, stream, detail, env = process6.env) {
470
508
  const colors = paint(stream, env);
471
509
  let head = MARK_WORDS[mark];
472
510
  if (takesControlCodes(stream, env)) {
473
511
  const { theme } = activeTheme();
474
- head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
512
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
475
513
  }
476
514
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
477
515
  }
478
516
  function ok(text, detail) {
479
- console.log(marked("ok", text, process5.stdout, detail));
517
+ console.log(marked("ok", text, process6.stdout, detail));
480
518
  }
481
- function role(name, stream, env = process5.env) {
519
+ function role(name, stream, env = process6.env) {
482
520
  const colors = paint(stream, env);
483
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
521
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
484
522
  }
485
523
  var STATUS_WORDS = {
486
524
  passed: ["passed", "success", "succeeded", "ok"],
487
525
  failed: ["failed", "failure", "error", "errored"],
488
- running: ["running", "in_progress", "started"],
526
+ running: ["running", "in_progress", "started", "holding"],
489
527
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
490
528
  skipped: ["skipped", "cancelled", "canceled", "manual"]
491
529
  };
@@ -504,8 +542,11 @@ var ESCAPE = String.fromCharCode(27);
504
542
  function textWidth(text) {
505
543
  return Bun.stringWidth(text);
506
544
  }
507
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
545
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
508
546
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
547
+ if (outputMode(stream, env) === "agent")
548
+ return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
549
+ `);
509
550
  const widths = [];
510
551
  for (const row of cells) {
511
552
  for (const [index, cell] of row.entries())
@@ -540,32 +581,35 @@ function narrow(rows, widths, limit) {
540
581
  }
541
582
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
542
583
  }
584
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
585
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
586
+ }
543
587
  function printJson(value) {
544
- console.log(JSON.stringify(value, undefined, 2));
588
+ console.log(jsonText(value));
545
589
  }
546
590
 
547
591
  // ../kit/src/help.ts
548
- import process7 from "process";
592
+ import process8 from "process";
549
593
  var OPTIONAL = /\[[^\]]+\]/g;
550
594
  var USAGE_PREFIX = /^usage:\s*/i;
551
595
  var FULL_STOP = /\.$/;
552
- function usageLine(usage, colors = paint(process7.stdout)) {
596
+ function usageLine(usage, colors = paint(process8.stdout)) {
553
597
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
554
598
  }
555
- function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
599
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
556
600
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
557
601
  `);
558
602
  }
559
- function exitRows(exits, colors = paint(process7.stdout)) {
603
+ function exitRows(exits, colors = paint(process8.stdout)) {
560
604
  if (exits.length === 0)
561
605
  return [];
562
606
  const width = Math.max(...exits.map(([code]) => String(code).length));
563
607
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
564
608
  }
565
- function replacesRows(replaces, colors = paint(process7.stdout)) {
566
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
609
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
610
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
567
611
  }
568
- function wantsHelpJson(env = process7.env) {
612
+ function wantsHelpJson(env = process8.env) {
569
613
  return env.KIT_HELP === "json";
570
614
  }
571
615
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -584,12 +628,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
584
628
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
585
629
  };
586
630
  }
587
- function exampleRows(examples, colors = paint(process7.stdout)) {
588
- if (examples.length === 0)
631
+ function exampleRows(examples, colors = paint(process8.stdout)) {
632
+ if (examples.length === 0 || outputMode() === "agent")
589
633
  return [];
590
634
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
591
635
  }
592
- function optionRows(options, colors = paint(process7.stdout)) {
636
+ function optionRows(options, colors = paint(process8.stdout)) {
593
637
  const rows = Object.entries(options).map(([name, option]) => {
594
638
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
595
639
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -621,10 +665,10 @@ function closest(name, names) {
621
665
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
622
666
  }
623
667
  // ../kit/src/input.ts
624
- import process8 from "process";
668
+ import process9 from "process";
625
669
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
626
670
  if (path === "-") {
627
- if (process8.stdin.isTTY)
671
+ if (process9.stdin.isTTY)
628
672
  fail(noStdin);
629
673
  return Bun.stdin.text();
630
674
  }
@@ -683,7 +727,7 @@ var OUTPUT_OPTIONS = {
683
727
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
684
728
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
685
729
  };
686
- function applyOutput(color, plain, env = process9.env) {
730
+ function applyOutput(color, plain, env = process10.env) {
687
731
  const when = plain === true ? "never" : color ?? "auto";
688
732
  if (when === "auto")
689
733
  return;
@@ -860,13 +904,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
860
904
  // ../kit/src/cli.ts
861
905
  import { readFileSync as readFileSync2, realpathSync } from "fs";
862
906
  import { dirname as dirname3, join as join5 } from "path";
863
- import process11 from "process";
907
+ import process12 from "process";
864
908
 
865
909
  // ../kit/src/usage.ts
866
910
  import { appendFileSync, mkdirSync } from "fs";
867
911
  import { homedir as homedir3 } from "os";
868
912
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
869
- import process10 from "process";
913
+ import process11 from "process";
870
914
 
871
915
  // ../kit/src/logs.ts
872
916
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -880,14 +924,14 @@ var usageError;
880
924
  function noteUsageError(message) {
881
925
  usageError = message;
882
926
  }
883
- function stateHome(env = process10.env) {
927
+ function stateHome(env = process11.env) {
884
928
  const dir = env.XDG_STATE_HOME;
885
929
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
886
930
  }
887
- function usagePath(env = process10.env) {
931
+ function usagePath(env = process11.env) {
888
932
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
889
933
  }
890
- function usageRecorded(env = process10.env) {
934
+ function usageRecorded(env = process11.env) {
891
935
  const off = env.KAYNOOO_CLI_NO_USAGE;
892
936
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
893
937
  }
@@ -901,7 +945,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
901
945
  usageError = undefined;
902
946
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
903
947
  }
904
- function recordUsage(entry, env = process10.env) {
948
+ function recordUsage(entry, env = process11.env) {
905
949
  if (!usageRecorded(env))
906
950
  return;
907
951
  try {
@@ -992,8 +1036,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
992
1036
  `);
993
1037
  }
994
1038
  function printError(prefix, message, hint, cause) {
995
- const colors = paint(process11.stderr);
996
- const styled = takesControlCodes(process11.stderr);
1039
+ const colors = paint(process12.stderr);
1040
+ const styled = takesControlCodes(process12.stderr);
997
1041
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
998
1042
  const under = (label, text, tint) => text === undefined ? "" : `
999
1043
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1036,11 +1080,11 @@ async function dispatch(level, typed, { version, redact }) {
1036
1080
  }
1037
1081
  }
1038
1082
  if (name === undefined && level.path.length > 1) {
1039
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stderr));
1083
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
1040
1084
  return 2;
1041
1085
  }
1042
1086
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1043
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stdout));
1087
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
1044
1088
  return 0;
1045
1089
  }
1046
1090
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1167,7 +1211,7 @@ function packageVersion(entry = Bun.main) {
1167
1211
  return "0.0.0";
1168
1212
  }
1169
1213
  }
1170
- async function runCli(cli, argv = process11.argv.slice(2)) {
1214
+ async function runCli(cli, argv = process12.argv.slice(2)) {
1171
1215
  const version = cli.version ?? packageVersion();
1172
1216
  if (argv[0] === COMPLETE)
1173
1217
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1194,7 +1238,7 @@ function commandPath(scope, argv) {
1194
1238
  }
1195
1239
  return path.length === 0 ? undefined : path.join(" ");
1196
1240
  }
1197
- async function runMain({ name, version, run, redact, usage }, argv = process11.argv.slice(2)) {
1241
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1198
1242
  if (argv[0] === COMPLETE)
1199
1243
  return printCandidates(leafCandidates(run, argv.slice(1)));
1200
1244
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1235,7 +1279,7 @@ var {Glob } = globalThis.Bun;
1235
1279
  var SESSION_FILES = new Glob("*.json");
1236
1280
  var ACCOUNT_DIRS = new Glob("*/sessions");
1237
1281
  // src/commands/redact.ts
1238
- import process13 from "process";
1282
+ import process14 from "process";
1239
1283
 
1240
1284
  // src/files.ts
1241
1285
  import { chmod, chown, readdir, realpath, rename, rm, stat, writeFile } from "fs/promises";
@@ -1822,10 +1866,10 @@ async function redact(args) {
1822
1866
  const redactor = new Redactor(known);
1823
1867
  const decoder = new TextDecoder;
1824
1868
  for await (const chunk of Bun.stdin.stream())
1825
- process13.stdout.write(redactor.push(decoder.decode(chunk, { stream: true })));
1826
- process13.stdout.write(redactor.push(decoder.decode()) + redactor.end());
1869
+ process14.stdout.write(redactor.push(decoder.decode(chunk, { stream: true })));
1870
+ process14.stdout.write(redactor.push(decoder.decode()) + redactor.end());
1827
1871
  return 0;
1828
1872
  }
1829
1873
 
1830
1874
  // src/redact.ts
1831
- process14.exitCode = await runMain({ name: "redact", run: redact });
1875
+ process15.exitCode = await runMain({ name: "redact", run: redact });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-env",
3
3
  "type": "module",
4
- "version": "0.11.0",
4
+ "version": "0.12.0",
5
5
  "description": "ev lists and edits .env files with secrets masked, redact masks secrets in any piped output.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -37,6 +37,6 @@
37
37
  "redact": "$npm_execpath src/redact.ts"
38
38
  },
39
39
  "devDependencies": {
40
- "@kaynooo/cli-kit": "0.21.1"
40
+ "@kaynooo/cli-kit": "0.22.0"
41
41
  }
42
42
  }
@@ -3,7 +3,7 @@ import type { ComposeFix } from '../fix'
3
3
  import { stat } from 'node:fs/promises'
4
4
  import { relative, resolve } from 'node:path'
5
5
  import process from 'node:process'
6
- import { fail, jsonOption, parse, printJson } from '@kaynooo/cli-kit'
6
+ import { fail, jsonOption, parse, printJson, role } from '@kaynooo/cli-kit'
7
7
  import { shellQuote } from '@kaynooo/cli-kit/shell'
8
8
  import { audit as findExposed } from '../audit'
9
9
  import { fixCompose, shutOthersOut } from '../fix'
@@ -46,6 +46,7 @@ function shown(path: string): string {
46
46
  async function fixAll(exposed: Exposure[], json: boolean): Promise<{ fixed: ComposeFix[], left: boolean }> {
47
47
  const fixed: ComposeFix[] = []
48
48
  let left = false
49
+ const tint = role('path', process.stdout)
49
50
 
50
51
  for (const { path, readable, group, tracked, secrets } of exposed) {
51
52
  const fix = secrets === undefined ? undefined : await fixCompose(path, group === true)
@@ -68,7 +69,7 @@ async function fixAll(exposed: Exposure[], json: boolean): Promise<{ fixed: Comp
68
69
  ...tracked ? [`tracked by git: git rm --cached ${shellQuote(shown(path))}, then ignore it`] : [],
69
70
  ]
70
71
 
71
- console.log(`${shown(path)}\n ${lines.join('\n ')}`)
72
+ console.log(`${tint(shown(path))}\n ${lines.join('\n ')}`)
72
73
  }
73
74
 
74
75
  return { fixed, left }
@@ -118,6 +119,7 @@ export async function audit(args: string[]): Promise<number> {
118
119
  }
119
120
 
120
121
  const uid = process.getuid?.()
122
+ const tint = role('path', process.stdout)
121
123
 
122
124
  for (const { path, readable, group, tracked, secrets } of exposed) {
123
125
  // Only the owner or root can change a file's mode.
@@ -128,7 +130,7 @@ export async function audit(args: string[]): Promise<number> {
128
130
  ...tracked ? [`tracked by git: git rm --cached ${shellQuote(shown(path))}, then ignore it`] : [],
129
131
  ]
130
132
 
131
- console.log(`${shown(path)}\n ${problems.join('\n ')}`)
133
+ console.log(`${tint(shown(path))}\n ${problems.join('\n ')}`)
132
134
  }
133
135
 
134
136
  return 1
@@ -1,4 +1,5 @@
1
- import { fail, jsonOption, parse, printJson } from '@kaynooo/cli-kit'
1
+ import process from 'node:process'
2
+ import { fail, jsonOption, parse, printJson, role } from '@kaynooo/cli-kit'
2
3
  import { entries } from '../dotenv'
3
4
  import { readEnv } from '../files'
4
5
 
@@ -43,7 +44,9 @@ export async function diff(args: string[]): Promise<number> {
43
44
  return onlyA.length + onlyB.length === 0 ? 0 : 1
44
45
  }
45
46
 
46
- const lines = [...onlyA.map(key => `only in ${a}: ${key}`), ...onlyB.map(key => `only in ${b}: ${key}`)]
47
+ const path = role('path', process.stdout)
48
+ const value = role('value', process.stdout)
49
+ const lines = [...onlyA.map(key => `only in ${path(a)}: ${value(key)}`), ...onlyB.map(key => `only in ${path(b)}: ${value(key)}`)]
47
50
 
48
51
  if (lines.length === 0)
49
52
  return 0
@@ -71,7 +74,10 @@ export async function missing(args: string[]): Promise<number> {
71
74
  if (absent.length === 0)
72
75
  return 0
73
76
 
74
- console.log(absent.map(key => `${key} (set in ${against}, not in ${file})`).join('\n'))
77
+ const path = role('path', process.stdout)
78
+ const value = role('value', process.stdout)
79
+
80
+ console.log(absent.map(key => `${value(key)} (set in ${path(against)}, not in ${path(file)})`).join('\n'))
75
81
 
76
82
  return 1
77
83
  }