@kaynooo/cli-docker 0.6.0 → 0.7.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/dc-cli.js CHANGED
@@ -2,13 +2,37 @@
2
2
  // @bun
3
3
 
4
4
  // src/dc-cli.ts
5
- import process12 from "process";
5
+ import process14 from "process";
6
6
  // ../kit/src/args.ts
7
- import process7 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
+ // ../kit/src/format.ts
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
+ }
30
+ function isInteractive(streams = process2) {
31
+ return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
32
+ }
33
+
10
34
  // ../kit/src/style.ts
11
- import process5 from "process";
35
+ import process6 from "process";
12
36
 
13
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
38
  function x(s) {
@@ -275,13 +299,13 @@ var t = le();
275
299
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
276
300
  import { homedir as homedir2 } from "os";
277
301
  import { join as join3, resolve as resolve2 } from "path";
278
- import process4 from "process";
302
+ import process5 from "process";
279
303
 
280
304
  // ../kit/src/config.ts
281
305
  import { existsSync } from "fs";
282
306
  import { dirname, join, resolve } from "path";
283
- import process2 from "process";
284
- function findUp(names, from = process2.cwd(), stop = () => false) {
307
+ import process3 from "process";
308
+ function findUp(names, from = process3.cwd(), stop = () => false) {
285
309
  const wanted = typeof names === "string" ? [names] : names;
286
310
  for (let dir = resolve(from);; dir = dirname(dir)) {
287
311
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -295,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
295
319
  // ../kit/src/user-config.ts
296
320
  import { homedir } from "os";
297
321
  import { join as join2 } from "path";
298
- import process3 from "process";
322
+ import process4 from "process";
299
323
  function configBase(where = {}) {
300
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
324
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
301
325
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
302
326
  }
303
327
  function userConfigPath(bin, where = {}) {
@@ -330,10 +354,30 @@ function isColorSpec(spec) {
330
354
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
331
355
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
332
356
  }
333
- function tinted(colors, spec) {
357
+ var CUBE = [0, 95, 135, 175, 215, 255];
358
+ function cubeLevel(channel) {
359
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
360
+ }
361
+ function nearest256(hex) {
362
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
363
+ const levels = rgb.map(cubeLevel);
364
+ const cube = levels.map((level) => CUBE[level]);
365
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
366
+ const greyValue = 8 + grey * 10;
367
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
368
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
369
+ }
370
+ function hasTrueColor(env) {
371
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
372
+ }
373
+ function tinted(colors, spec, env = process5.env) {
334
374
  if (typeof spec === "number")
335
375
  return colors.ansi256(spec);
336
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
376
+ return spec.trim().split(SPACES).reduce((chain, token) => {
377
+ if (HEX.test(token))
378
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
379
+ return chain[token] ?? chain;
380
+ }, colors);
337
381
  }
338
382
  function isRecord(value) {
339
383
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -417,7 +461,7 @@ function warnOnce(message) {
417
461
  function isPath(chosen) {
418
462
  return chosen.includes("/") || chosen.endsWith(".json");
419
463
  }
420
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
464
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
421
465
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
422
466
  const sources = [];
423
467
  const chosen = env.KIT_THEME ?? "";
@@ -447,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
447
491
  var current;
448
492
  var currentKey = "";
449
493
  function activeTheme() {
450
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
494
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
451
495
  if (current === undefined || key !== currentKey) {
452
496
  current = loadTheme();
453
497
  currentKey = key;
@@ -456,20 +500,20 @@ function activeTheme() {
456
500
  }
457
501
 
458
502
  // ../kit/src/style.ts
459
- function takesControlCodes(stream, env = process5.env) {
460
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
503
+ function takesControlCodes(stream, env = process6.env) {
504
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
461
505
  }
462
- function paint(stream, env = process5.env) {
506
+ function paint(stream, env = process6.env) {
463
507
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
464
508
  }
465
- function role(name, stream, env = process5.env) {
509
+ function role(name, stream, env = process6.env) {
466
510
  const colors = paint(stream, env);
467
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
511
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
468
512
  }
469
513
  var STATUS_WORDS = {
470
514
  passed: ["passed", "success", "succeeded", "ok"],
471
515
  failed: ["failed", "failure", "error", "errored"],
472
- running: ["running", "in_progress", "started"],
516
+ running: ["running", "in_progress", "started", "holding"],
473
517
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
474
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
475
519
  };
@@ -481,32 +525,35 @@ function upTo(text, separator) {
481
525
  return end === -1 ? text : text.slice(0, end);
482
526
  }
483
527
  var ESCAPE = String.fromCharCode(27);
528
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
529
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
530
+ }
484
531
  function printJson(value) {
485
- console.log(JSON.stringify(value, undefined, 2));
532
+ console.log(jsonText(value));
486
533
  }
487
534
 
488
535
  // ../kit/src/help.ts
489
- import process6 from "process";
536
+ import process8 from "process";
490
537
  var OPTIONAL = /\[[^\]]+\]/g;
491
538
  var USAGE_PREFIX = /^usage:\s*/i;
492
539
  var FULL_STOP = /\.$/;
493
- function usageLine(usage, colors = paint(process6.stdout)) {
540
+ function usageLine(usage, colors = paint(process8.stdout)) {
494
541
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
495
542
  }
496
- function helpText(usage, options, colors = paint(process6.stdout), { examples = [], replaces, exits = [] } = {}) {
543
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
497
544
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
498
545
  `);
499
546
  }
500
- function exitRows(exits, colors = paint(process6.stdout)) {
547
+ function exitRows(exits, colors = paint(process8.stdout)) {
501
548
  if (exits.length === 0)
502
549
  return [];
503
550
  const width = Math.max(...exits.map(([code]) => String(code).length));
504
551
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
505
552
  }
506
- function replacesRows(replaces, colors = paint(process6.stdout)) {
507
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
553
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
554
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
508
555
  }
509
- function wantsHelpJson(env = process6.env) {
556
+ function wantsHelpJson(env = process8.env) {
510
557
  return env.KIT_HELP === "json";
511
558
  }
512
559
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -525,12 +572,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
525
572
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
526
573
  };
527
574
  }
528
- function exampleRows(examples, colors = paint(process6.stdout)) {
529
- if (examples.length === 0)
575
+ function exampleRows(examples, colors = paint(process8.stdout)) {
576
+ if (examples.length === 0 || outputMode() === "agent")
530
577
  return [];
531
578
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
532
579
  }
533
- function optionRows(options, colors = paint(process6.stdout)) {
580
+ function optionRows(options, colors = paint(process8.stdout)) {
534
581
  const rows = Object.entries(options).map(([name, option]) => {
535
582
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
536
583
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -624,7 +671,7 @@ var OUTPUT_OPTIONS = {
624
671
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
625
672
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
626
673
  };
627
- function applyOutput(color, plain, env = process7.env) {
674
+ function applyOutput(color, plain, env = process9.env) {
628
675
  const when = plain === true ? "never" : color ?? "auto";
629
676
  if (when === "auto")
630
677
  return;
@@ -801,13 +848,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
801
848
  // ../kit/src/cli.ts
802
849
  import { readFileSync as readFileSync2, realpathSync } from "fs";
803
850
  import { dirname as dirname3, join as join5 } from "path";
804
- import process9 from "process";
851
+ import process11 from "process";
805
852
 
806
853
  // ../kit/src/usage.ts
807
854
  import { appendFileSync, mkdirSync } from "fs";
808
855
  import { homedir as homedir3 } from "os";
809
856
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
810
- import process8 from "process";
857
+ import process10 from "process";
811
858
 
812
859
  // ../kit/src/logs.ts
813
860
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -821,14 +868,14 @@ var usageError;
821
868
  function noteUsageError(message) {
822
869
  usageError = message;
823
870
  }
824
- function stateHome(env = process8.env) {
871
+ function stateHome(env = process10.env) {
825
872
  const dir = env.XDG_STATE_HOME;
826
873
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
827
874
  }
828
- function usagePath(env = process8.env) {
875
+ function usagePath(env = process10.env) {
829
876
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
830
877
  }
831
- function usageRecorded(env = process8.env) {
878
+ function usageRecorded(env = process10.env) {
832
879
  const off = env.KAYNOOO_CLI_NO_USAGE;
833
880
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
834
881
  }
@@ -842,7 +889,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
842
889
  usageError = undefined;
843
890
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
844
891
  }
845
- function recordUsage(entry, env = process8.env) {
892
+ function recordUsage(entry, env = process10.env) {
846
893
  if (!usageRecorded(env))
847
894
  return;
848
895
  try {
@@ -860,8 +907,8 @@ var LEVEL_OPTIONS = {
860
907
  };
861
908
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
862
909
  function printError(prefix, message, hint, cause) {
863
- const colors = paint(process9.stderr);
864
- const styled = takesControlCodes(process9.stderr);
910
+ const colors = paint(process11.stderr);
911
+ const styled = takesControlCodes(process11.stderr);
865
912
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
866
913
  const under = (label, text, tint) => text === undefined ? "" : `
867
914
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -954,7 +1001,7 @@ function packageVersion(entry = Bun.main) {
954
1001
  return "0.0.0";
955
1002
  }
956
1003
  }
957
- async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
1004
+ async function runMain({ name, version, run, redact, usage }, argv = process11.argv.slice(2)) {
958
1005
  if (argv[0] === COMPLETE)
959
1006
  return printCandidates(leafCandidates(run, argv.slice(1)));
960
1007
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -997,7 +1044,7 @@ var {Glob } = globalThis.Bun;
997
1044
  var SESSION_FILES = new Glob("*.json");
998
1045
  var ACCOUNT_DIRS = new Glob("*/sessions");
999
1046
  // src/dc.ts
1000
- import process11 from "process";
1047
+ import process13 from "process";
1001
1048
 
1002
1049
  // src/stack.ts
1003
1050
  import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "fs";
@@ -1535,7 +1582,7 @@ async function target(args) {
1535
1582
  }
1536
1583
  async function choose(recorded) {
1537
1584
  const picker = Bun.which("pick");
1538
- if (picker === null || !process11.stdin.isTTY)
1585
+ if (picker === null || !isInteractive())
1539
1586
  return;
1540
1587
  const proc = Bun.spawn([picker, "--prompt", "dc> "], { stdin: new Blob([recorded.map((stack) => stack.project).join(`
1541
1588
  `)]), stdout: "pipe", stderr: "inherit" });
@@ -1543,8 +1590,8 @@ async function choose(recorded) {
1543
1590
  return recorded.find((stack) => stack.project === picked);
1544
1591
  }
1545
1592
  async function run(stack, args, announce) {
1546
- if (announce && process11.stderr.isTTY)
1547
- console.error(paint(process11.stderr).dim([...stack.run, ...args].join(" ")));
1593
+ if (announce && process13.stderr.isTTY)
1594
+ console.error(paint(process13.stderr).dim([...stack.run, ...args].join(" ")));
1548
1595
  return Bun.spawn([...stack.list.argv, ...args], { cwd: stack.list.cwd, env: stack.list.env, stdio: ["inherit", "inherit", "inherit"] }).exited;
1549
1596
  }
1550
1597
  async function dc(args) {
@@ -1574,4 +1621,4 @@ async function main(args) {
1574
1621
  }
1575
1622
  return dc(args);
1576
1623
  }
1577
- process12.exitCode = await runMain({ name: "dc", run: main });
1624
+ process14.exitCode = await runMain({ name: "dc", run: main });
package/dist/dlog-cli.js CHANGED
@@ -2,13 +2,37 @@
2
2
  // @bun
3
3
 
4
4
  // src/dlog-cli.ts
5
- import process12 from "process";
5
+ import process14 from "process";
6
6
  // ../kit/src/args.ts
7
- import process7 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
+ // ../kit/src/format.ts
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
+ }
30
+ function isInteractive(streams = process2) {
31
+ return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
32
+ }
33
+
10
34
  // ../kit/src/style.ts
11
- import process5 from "process";
35
+ import process6 from "process";
12
36
 
13
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
38
  function x(s) {
@@ -275,13 +299,13 @@ var t = le();
275
299
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
276
300
  import { homedir as homedir2 } from "os";
277
301
  import { join as join3, resolve as resolve2 } from "path";
278
- import process4 from "process";
302
+ import process5 from "process";
279
303
 
280
304
  // ../kit/src/config.ts
281
305
  import { existsSync } from "fs";
282
306
  import { dirname, join, resolve } from "path";
283
- import process2 from "process";
284
- function findUp(names, from = process2.cwd(), stop = () => false) {
307
+ import process3 from "process";
308
+ function findUp(names, from = process3.cwd(), stop = () => false) {
285
309
  const wanted = typeof names === "string" ? [names] : names;
286
310
  for (let dir = resolve(from);; dir = dirname(dir)) {
287
311
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -295,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
295
319
  // ../kit/src/user-config.ts
296
320
  import { homedir } from "os";
297
321
  import { join as join2 } from "path";
298
- import process3 from "process";
322
+ import process4 from "process";
299
323
  function configBase(where = {}) {
300
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
324
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
301
325
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
302
326
  }
303
327
  function userConfigPath(bin, where = {}) {
@@ -330,10 +354,30 @@ function isColorSpec(spec) {
330
354
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
331
355
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
332
356
  }
333
- function tinted(colors, spec) {
357
+ var CUBE = [0, 95, 135, 175, 215, 255];
358
+ function cubeLevel(channel) {
359
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
360
+ }
361
+ function nearest256(hex) {
362
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
363
+ const levels = rgb.map(cubeLevel);
364
+ const cube = levels.map((level) => CUBE[level]);
365
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
366
+ const greyValue = 8 + grey * 10;
367
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
368
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
369
+ }
370
+ function hasTrueColor(env) {
371
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
372
+ }
373
+ function tinted(colors, spec, env = process5.env) {
334
374
  if (typeof spec === "number")
335
375
  return colors.ansi256(spec);
336
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
376
+ return spec.trim().split(SPACES).reduce((chain, token) => {
377
+ if (HEX.test(token))
378
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
379
+ return chain[token] ?? chain;
380
+ }, colors);
337
381
  }
338
382
  function isRecord(value) {
339
383
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -417,7 +461,7 @@ function warnOnce(message) {
417
461
  function isPath(chosen) {
418
462
  return chosen.includes("/") || chosen.endsWith(".json");
419
463
  }
420
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
464
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
421
465
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
422
466
  const sources = [];
423
467
  const chosen = env.KIT_THEME ?? "";
@@ -447,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
447
491
  var current;
448
492
  var currentKey = "";
449
493
  function activeTheme() {
450
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
494
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
451
495
  if (current === undefined || key !== currentKey) {
452
496
  current = loadTheme();
453
497
  currentKey = key;
@@ -456,20 +500,20 @@ function activeTheme() {
456
500
  }
457
501
 
458
502
  // ../kit/src/style.ts
459
- function takesControlCodes(stream, env = process5.env) {
460
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
503
+ function takesControlCodes(stream, env = process6.env) {
504
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
461
505
  }
462
- function paint(stream, env = process5.env) {
506
+ function paint(stream, env = process6.env) {
463
507
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
464
508
  }
465
- function role(name, stream, env = process5.env) {
509
+ function role(name, stream, env = process6.env) {
466
510
  const colors = paint(stream, env);
467
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
511
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
468
512
  }
469
513
  var STATUS_WORDS = {
470
514
  passed: ["passed", "success", "succeeded", "ok"],
471
515
  failed: ["failed", "failure", "error", "errored"],
472
- running: ["running", "in_progress", "started"],
516
+ running: ["running", "in_progress", "started", "holding"],
473
517
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
474
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
475
519
  };
@@ -481,32 +525,35 @@ function upTo(text, separator) {
481
525
  return end === -1 ? text : text.slice(0, end);
482
526
  }
483
527
  var ESCAPE = String.fromCharCode(27);
528
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
529
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
530
+ }
484
531
  function printJson(value) {
485
- console.log(JSON.stringify(value, undefined, 2));
532
+ console.log(jsonText(value));
486
533
  }
487
534
 
488
535
  // ../kit/src/help.ts
489
- import process6 from "process";
536
+ import process8 from "process";
490
537
  var OPTIONAL = /\[[^\]]+\]/g;
491
538
  var USAGE_PREFIX = /^usage:\s*/i;
492
539
  var FULL_STOP = /\.$/;
493
- function usageLine(usage, colors = paint(process6.stdout)) {
540
+ function usageLine(usage, colors = paint(process8.stdout)) {
494
541
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
495
542
  }
496
- function helpText(usage, options, colors = paint(process6.stdout), { examples = [], replaces, exits = [] } = {}) {
543
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
497
544
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
498
545
  `);
499
546
  }
500
- function exitRows(exits, colors = paint(process6.stdout)) {
547
+ function exitRows(exits, colors = paint(process8.stdout)) {
501
548
  if (exits.length === 0)
502
549
  return [];
503
550
  const width = Math.max(...exits.map(([code]) => String(code).length));
504
551
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
505
552
  }
506
- function replacesRows(replaces, colors = paint(process6.stdout)) {
507
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
553
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
554
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
508
555
  }
509
- function wantsHelpJson(env = process6.env) {
556
+ function wantsHelpJson(env = process8.env) {
510
557
  return env.KIT_HELP === "json";
511
558
  }
512
559
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -525,12 +572,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
525
572
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
526
573
  };
527
574
  }
528
- function exampleRows(examples, colors = paint(process6.stdout)) {
529
- if (examples.length === 0)
575
+ function exampleRows(examples, colors = paint(process8.stdout)) {
576
+ if (examples.length === 0 || outputMode() === "agent")
530
577
  return [];
531
578
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
532
579
  }
533
- function optionRows(options, colors = paint(process6.stdout)) {
580
+ function optionRows(options, colors = paint(process8.stdout)) {
534
581
  const rows = Object.entries(options).map(([name, option]) => {
535
582
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
536
583
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -624,7 +671,7 @@ var OUTPUT_OPTIONS = {
624
671
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
625
672
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
626
673
  };
627
- function applyOutput(color, plain, env = process7.env) {
674
+ function applyOutput(color, plain, env = process9.env) {
628
675
  const when = plain === true ? "never" : color ?? "auto";
629
676
  if (when === "auto")
630
677
  return;
@@ -801,13 +848,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
801
848
  // ../kit/src/cli.ts
802
849
  import { readFileSync as readFileSync2, realpathSync } from "fs";
803
850
  import { dirname as dirname3, join as join5 } from "path";
804
- import process9 from "process";
851
+ import process11 from "process";
805
852
 
806
853
  // ../kit/src/usage.ts
807
854
  import { appendFileSync, mkdirSync } from "fs";
808
855
  import { homedir as homedir3 } from "os";
809
856
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
810
- import process8 from "process";
857
+ import process10 from "process";
811
858
 
812
859
  // ../kit/src/logs.ts
813
860
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -821,14 +868,14 @@ var usageError;
821
868
  function noteUsageError(message) {
822
869
  usageError = message;
823
870
  }
824
- function stateHome(env = process8.env) {
871
+ function stateHome(env = process10.env) {
825
872
  const dir = env.XDG_STATE_HOME;
826
873
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
827
874
  }
828
- function usagePath(env = process8.env) {
875
+ function usagePath(env = process10.env) {
829
876
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
830
877
  }
831
- function usageRecorded(env = process8.env) {
878
+ function usageRecorded(env = process10.env) {
832
879
  const off = env.KAYNOOO_CLI_NO_USAGE;
833
880
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
834
881
  }
@@ -842,7 +889,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
842
889
  usageError = undefined;
843
890
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
844
891
  }
845
- function recordUsage(entry, env = process8.env) {
892
+ function recordUsage(entry, env = process10.env) {
846
893
  if (!usageRecorded(env))
847
894
  return;
848
895
  try {
@@ -860,8 +907,8 @@ var LEVEL_OPTIONS = {
860
907
  };
861
908
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
862
909
  function printError(prefix, message, hint, cause) {
863
- const colors = paint(process9.stderr);
864
- const styled = takesControlCodes(process9.stderr);
910
+ const colors = paint(process11.stderr);
911
+ const styled = takesControlCodes(process11.stderr);
865
912
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
866
913
  const under = (label, text, tint) => text === undefined ? "" : `
867
914
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -954,7 +1001,7 @@ function packageVersion(entry = Bun.main) {
954
1001
  return "0.0.0";
955
1002
  }
956
1003
  }
957
- async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
1004
+ async function runMain({ name, version, run, redact, usage }, argv = process11.argv.slice(2)) {
958
1005
  if (argv[0] === COMPLETE)
959
1006
  return printCandidates(leafCandidates(run, argv.slice(1)));
960
1007
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -997,7 +1044,7 @@ var {Glob } = globalThis.Bun;
997
1044
  var SESSION_FILES = new Glob("*.json");
998
1045
  var ACCOUNT_DIRS = new Glob("*/sessions");
999
1046
  // src/dlog.ts
1000
- import process11 from "process";
1047
+ import process13 from "process";
1001
1048
 
1002
1049
  // ../env/src/files.ts
1003
1050
  import { chmod, chown, readdir, realpath, rename, rm, stat, writeFile } from "fs/promises";
@@ -1598,13 +1645,13 @@ function withoutKeys(lines) {
1598
1645
  });
1599
1646
  }
1600
1647
  function line(report) {
1601
- const colors = paint(process11.stdout);
1648
+ const colors = paint(process13.stdout);
1602
1649
  const status = report.status.replace(STATUS_HEALTH, "").trim();
1603
1650
  const detail = [report.health, status].filter(Boolean).join(" \xB7 ");
1604
1651
  return `${report.key.padEnd(24)} ${colors[stateColor(report.state)](report.state.padEnd(9))} ${colors.dim(detail)}`.trimEnd();
1605
1652
  }
1606
1653
  function show(reports) {
1607
- const colors = paint(process11.stdout);
1654
+ const colors = paint(process13.stdout);
1608
1655
  for (const report of reports) {
1609
1656
  console.log(line(report));
1610
1657
  if (report.unreadable !== undefined)
@@ -1645,9 +1692,9 @@ async function dlog(args) {
1645
1692
  show(reports);
1646
1693
  const down = reports.filter((report) => needsLook(report, failOn));
1647
1694
  if (parsed.values.json !== true && down.length > 0)
1648
- console.error(paint(process11.stderr).dim(`${down.length} of ${reports.length} services need a look: ${down.map((report) => report.key).join(", ")}`));
1695
+ console.error(paint(process13.stderr).dim(`${down.length} of ${reports.length} services need a look: ${down.map((report) => report.key).join(", ")}`));
1649
1696
  return down.length > 0 ? 1 : 0;
1650
1697
  }
1651
1698
 
1652
1699
  // src/dlog-cli.ts
1653
- process12.exitCode = await runMain({ name: "dlog", run: dlog });
1700
+ process14.exitCode = await runMain({ name: "dlog", run: dlog });