@towles/tool 0.0.120 → 0.0.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/node_modules/@towles/shared/package.json +15 -0
  2. package/node_modules/@towles/shared/src/date-utils.test.ts +97 -0
  3. package/node_modules/@towles/shared/src/date-utils.ts +54 -0
  4. package/node_modules/@towles/shared/src/fs.ts +19 -0
  5. package/node_modules/@towles/shared/src/git/branch-name.test.ts +83 -0
  6. package/node_modules/@towles/shared/src/git/branch-name.ts +10 -0
  7. package/node_modules/@towles/shared/src/git/exec.ts +41 -0
  8. package/node_modules/@towles/shared/src/git/gh-cli-wrapper.test.ts +55 -0
  9. package/node_modules/@towles/shared/src/git/gh-cli-wrapper.ts +74 -0
  10. package/node_modules/@towles/shared/src/index.ts +8 -0
  11. package/node_modules/@towles/shared/src/render.test.ts +71 -0
  12. package/node_modules/@towles/shared/src/render.ts +36 -0
  13. package/package.json +4 -1
  14. package/packages/agentboard/apps/tui/src/components/DetailPanel.tsx +62 -1
  15. package/packages/agentboard/packages/runtime/package.json +1 -0
  16. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-code.test.ts +38 -1
  17. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-code.ts +106 -31
  18. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-pid.test.ts +74 -0
  19. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-pid.ts +57 -0
  20. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-usage.test.ts +148 -0
  21. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-usage.ts +78 -0
  22. package/packages/agentboard/packages/runtime/src/contracts/agent.ts +17 -0
  23. package/packages/agentboard/packages/runtime/src/server/pane-scanner.ts +10 -4
  24. package/packages/shared/node_modules/consola/LICENSE +47 -0
  25. package/packages/shared/node_modules/consola/README.md +352 -0
  26. package/packages/shared/node_modules/consola/basic.d.ts +1 -0
  27. package/packages/shared/node_modules/consola/browser.d.ts +1 -0
  28. package/packages/shared/node_modules/consola/core.d.ts +1 -0
  29. package/packages/shared/node_modules/consola/dist/basic.cjs +32 -0
  30. package/packages/shared/node_modules/consola/dist/basic.d.cts +23 -0
  31. package/packages/shared/node_modules/consola/dist/basic.d.mts +21 -0
  32. package/packages/shared/node_modules/consola/dist/basic.d.ts +23 -0
  33. package/packages/shared/node_modules/consola/dist/basic.mjs +24 -0
  34. package/packages/shared/node_modules/consola/dist/browser.cjs +84 -0
  35. package/packages/shared/node_modules/consola/dist/browser.d.cts +23 -0
  36. package/packages/shared/node_modules/consola/dist/browser.d.mts +21 -0
  37. package/packages/shared/node_modules/consola/dist/browser.d.ts +23 -0
  38. package/packages/shared/node_modules/consola/dist/browser.mjs +76 -0
  39. package/packages/shared/node_modules/consola/dist/chunks/prompt.cjs +288 -0
  40. package/packages/shared/node_modules/consola/dist/chunks/prompt.mjs +280 -0
  41. package/packages/shared/node_modules/consola/dist/core.cjs +517 -0
  42. package/packages/shared/node_modules/consola/dist/core.d.cts +459 -0
  43. package/packages/shared/node_modules/consola/dist/core.d.mts +459 -0
  44. package/packages/shared/node_modules/consola/dist/core.d.ts +459 -0
  45. package/packages/shared/node_modules/consola/dist/core.mjs +512 -0
  46. package/packages/shared/node_modules/consola/dist/index.cjs +663 -0
  47. package/packages/shared/node_modules/consola/dist/index.d.cts +24 -0
  48. package/packages/shared/node_modules/consola/dist/index.d.mts +22 -0
  49. package/packages/shared/node_modules/consola/dist/index.d.ts +24 -0
  50. package/packages/shared/node_modules/consola/dist/index.mjs +651 -0
  51. package/packages/shared/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +75 -0
  52. package/packages/shared/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
  53. package/packages/shared/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
  54. package/packages/shared/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +312 -0
  55. package/packages/shared/node_modules/consola/dist/utils.cjs +64 -0
  56. package/packages/shared/node_modules/consola/dist/utils.d.cts +286 -0
  57. package/packages/shared/node_modules/consola/dist/utils.d.mts +286 -0
  58. package/packages/shared/node_modules/consola/dist/utils.d.ts +286 -0
  59. package/packages/shared/node_modules/consola/dist/utils.mjs +54 -0
  60. package/packages/shared/node_modules/consola/lib/index.cjs +10 -0
  61. package/packages/shared/node_modules/consola/package.json +136 -0
  62. package/packages/shared/node_modules/consola/utils.d.ts +1 -0
  63. package/packages/shared/tsconfig.json +0 -16
@@ -0,0 +1,312 @@
1
+ 'use strict';
2
+
3
+ const tty = require('node:tty');
4
+
5
+ function _interopNamespaceCompat(e) {
6
+ if (e && typeof e === 'object' && 'default' in e) return e;
7
+ const n = Object.create(null);
8
+ if (e) {
9
+ for (const k in e) {
10
+ n[k] = e[k];
11
+ }
12
+ }
13
+ n.default = e;
14
+ return n;
15
+ }
16
+
17
+ const tty__namespace = /*#__PURE__*/_interopNamespaceCompat(tty);
18
+
19
+ const {
20
+ env = {},
21
+ argv = [],
22
+ platform = ""
23
+ } = typeof process === "undefined" ? {} : process;
24
+ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
25
+ const isForced = "FORCE_COLOR" in env || argv.includes("--color");
26
+ const isWindows = platform === "win32";
27
+ const isDumbTerminal = env.TERM === "dumb";
28
+ const isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal;
29
+ const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
30
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
31
+ function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
32
+ return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
33
+ }
34
+ function clearBleed(index, string, open, close, replace) {
35
+ return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
36
+ }
37
+ function filterEmpty(open, close, replace = open, at = open.length + 1) {
38
+ return (string) => string || !(string === "" || string === void 0) ? clearBleed(
39
+ ("" + string).indexOf(close, at),
40
+ string,
41
+ open,
42
+ close,
43
+ replace
44
+ ) : "";
45
+ }
46
+ function init(open, close, replace) {
47
+ return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
48
+ }
49
+ const colorDefs = {
50
+ reset: init(0, 0),
51
+ bold: init(1, 22, "\x1B[22m\x1B[1m"),
52
+ dim: init(2, 22, "\x1B[22m\x1B[2m"),
53
+ italic: init(3, 23),
54
+ underline: init(4, 24),
55
+ inverse: init(7, 27),
56
+ hidden: init(8, 28),
57
+ strikethrough: init(9, 29),
58
+ black: init(30, 39),
59
+ red: init(31, 39),
60
+ green: init(32, 39),
61
+ yellow: init(33, 39),
62
+ blue: init(34, 39),
63
+ magenta: init(35, 39),
64
+ cyan: init(36, 39),
65
+ white: init(37, 39),
66
+ gray: init(90, 39),
67
+ bgBlack: init(40, 49),
68
+ bgRed: init(41, 49),
69
+ bgGreen: init(42, 49),
70
+ bgYellow: init(43, 49),
71
+ bgBlue: init(44, 49),
72
+ bgMagenta: init(45, 49),
73
+ bgCyan: init(46, 49),
74
+ bgWhite: init(47, 49),
75
+ blackBright: init(90, 39),
76
+ redBright: init(91, 39),
77
+ greenBright: init(92, 39),
78
+ yellowBright: init(93, 39),
79
+ blueBright: init(94, 39),
80
+ magentaBright: init(95, 39),
81
+ cyanBright: init(96, 39),
82
+ whiteBright: init(97, 39),
83
+ bgBlackBright: init(100, 49),
84
+ bgRedBright: init(101, 49),
85
+ bgGreenBright: init(102, 49),
86
+ bgYellowBright: init(103, 49),
87
+ bgBlueBright: init(104, 49),
88
+ bgMagentaBright: init(105, 49),
89
+ bgCyanBright: init(106, 49),
90
+ bgWhiteBright: init(107, 49)
91
+ };
92
+ function createColors(useColor = isColorSupported) {
93
+ return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
94
+ }
95
+ const colors = createColors();
96
+ function getColor(color, fallback = "reset") {
97
+ return colors[color] || colors[fallback];
98
+ }
99
+ function colorize(color, text) {
100
+ return getColor(color)(text);
101
+ }
102
+
103
+ const ansiRegex = [
104
+ String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
105
+ String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
106
+ ].join("|");
107
+ function stripAnsi(text) {
108
+ return text.replace(new RegExp(ansiRegex, "g"), "");
109
+ }
110
+ function centerAlign(str, len, space = " ") {
111
+ const free = len - str.length;
112
+ if (free <= 0) {
113
+ return str;
114
+ }
115
+ const freeLeft = Math.floor(free / 2);
116
+ let _str = "";
117
+ for (let i = 0; i < len; i++) {
118
+ _str += i < freeLeft || i >= freeLeft + str.length ? space : str[i - freeLeft];
119
+ }
120
+ return _str;
121
+ }
122
+ function rightAlign(str, len, space = " ") {
123
+ const free = len - str.length;
124
+ if (free <= 0) {
125
+ return str;
126
+ }
127
+ let _str = "";
128
+ for (let i = 0; i < len; i++) {
129
+ _str += i < free ? space : str[i - free];
130
+ }
131
+ return _str;
132
+ }
133
+ function leftAlign(str, len, space = " ") {
134
+ let _str = "";
135
+ for (let i = 0; i < len; i++) {
136
+ _str += i < str.length ? str[i] : space;
137
+ }
138
+ return _str;
139
+ }
140
+ function align(alignment, str, len, space = " ") {
141
+ switch (alignment) {
142
+ case "left": {
143
+ return leftAlign(str, len, space);
144
+ }
145
+ case "right": {
146
+ return rightAlign(str, len, space);
147
+ }
148
+ case "center": {
149
+ return centerAlign(str, len, space);
150
+ }
151
+ default: {
152
+ return str;
153
+ }
154
+ }
155
+ }
156
+
157
+ const boxStylePresets = {
158
+ solid: {
159
+ tl: "\u250C",
160
+ tr: "\u2510",
161
+ bl: "\u2514",
162
+ br: "\u2518",
163
+ h: "\u2500",
164
+ v: "\u2502"
165
+ },
166
+ double: {
167
+ tl: "\u2554",
168
+ tr: "\u2557",
169
+ bl: "\u255A",
170
+ br: "\u255D",
171
+ h: "\u2550",
172
+ v: "\u2551"
173
+ },
174
+ doubleSingle: {
175
+ tl: "\u2553",
176
+ tr: "\u2556",
177
+ bl: "\u2559",
178
+ br: "\u255C",
179
+ h: "\u2500",
180
+ v: "\u2551"
181
+ },
182
+ doubleSingleRounded: {
183
+ tl: "\u256D",
184
+ tr: "\u256E",
185
+ bl: "\u2570",
186
+ br: "\u256F",
187
+ h: "\u2500",
188
+ v: "\u2551"
189
+ },
190
+ singleThick: {
191
+ tl: "\u250F",
192
+ tr: "\u2513",
193
+ bl: "\u2517",
194
+ br: "\u251B",
195
+ h: "\u2501",
196
+ v: "\u2503"
197
+ },
198
+ singleDouble: {
199
+ tl: "\u2552",
200
+ tr: "\u2555",
201
+ bl: "\u2558",
202
+ br: "\u255B",
203
+ h: "\u2550",
204
+ v: "\u2502"
205
+ },
206
+ singleDoubleRounded: {
207
+ tl: "\u256D",
208
+ tr: "\u256E",
209
+ bl: "\u2570",
210
+ br: "\u256F",
211
+ h: "\u2550",
212
+ v: "\u2502"
213
+ },
214
+ rounded: {
215
+ tl: "\u256D",
216
+ tr: "\u256E",
217
+ bl: "\u2570",
218
+ br: "\u256F",
219
+ h: "\u2500",
220
+ v: "\u2502"
221
+ }
222
+ };
223
+ const defaultStyle = {
224
+ borderColor: "white",
225
+ borderStyle: "rounded",
226
+ valign: "center",
227
+ padding: 2,
228
+ marginLeft: 1,
229
+ marginTop: 1,
230
+ marginBottom: 1
231
+ };
232
+ function box(text, _opts = {}) {
233
+ const opts = {
234
+ ..._opts,
235
+ style: {
236
+ ...defaultStyle,
237
+ ..._opts.style
238
+ }
239
+ };
240
+ const textLines = text.split("\n");
241
+ const boxLines = [];
242
+ const _color = getColor(opts.style.borderColor);
243
+ const borderStyle = {
244
+ ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
245
+ };
246
+ if (_color) {
247
+ for (const key in borderStyle) {
248
+ borderStyle[key] = _color(
249
+ borderStyle[key]
250
+ );
251
+ }
252
+ }
253
+ const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
254
+ const height = textLines.length + paddingOffset;
255
+ const width = Math.max(
256
+ ...textLines.map((line) => stripAnsi(line).length),
257
+ opts.title ? stripAnsi(opts.title).length : 0
258
+ ) + paddingOffset;
259
+ const widthOffset = width + paddingOffset;
260
+ const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
261
+ if (opts.style.marginTop > 0) {
262
+ boxLines.push("".repeat(opts.style.marginTop));
263
+ }
264
+ if (opts.title) {
265
+ const title = _color ? _color(opts.title) : opts.title;
266
+ const left = borderStyle.h.repeat(
267
+ Math.floor((width - stripAnsi(opts.title).length) / 2)
268
+ );
269
+ const right = borderStyle.h.repeat(
270
+ width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
271
+ );
272
+ boxLines.push(
273
+ `${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`
274
+ );
275
+ } else {
276
+ boxLines.push(
277
+ `${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
278
+ );
279
+ }
280
+ const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
281
+ for (let i = 0; i < height; i++) {
282
+ if (i < valignOffset || i >= valignOffset + textLines.length) {
283
+ boxLines.push(
284
+ `${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
285
+ );
286
+ } else {
287
+ const line = textLines[i - valignOffset];
288
+ const left = " ".repeat(paddingOffset);
289
+ const right = " ".repeat(width - stripAnsi(line).length);
290
+ boxLines.push(
291
+ `${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
292
+ );
293
+ }
294
+ }
295
+ boxLines.push(
296
+ `${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
297
+ );
298
+ if (opts.style.marginBottom > 0) {
299
+ boxLines.push("".repeat(opts.style.marginBottom));
300
+ }
301
+ return boxLines.join("\n");
302
+ }
303
+
304
+ exports.align = align;
305
+ exports.box = box;
306
+ exports.centerAlign = centerAlign;
307
+ exports.colorize = colorize;
308
+ exports.colors = colors;
309
+ exports.getColor = getColor;
310
+ exports.leftAlign = leftAlign;
311
+ exports.rightAlign = rightAlign;
312
+ exports.stripAnsi = stripAnsi;
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ const box = require('./shared/consola.DwRq1yyg.cjs');
4
+ require('node:tty');
5
+
6
+ function formatTree(items, options) {
7
+ options = {
8
+ prefix: " ",
9
+ ellipsis: "...",
10
+ ...options
11
+ };
12
+ const tree = _buildTree(items, options).join("");
13
+ if (options && options.color) {
14
+ return box.colorize(options.color, tree);
15
+ }
16
+ return tree;
17
+ }
18
+ function _buildTree(items, options) {
19
+ const chunks = [];
20
+ const total = items.length - 1;
21
+ for (let i = 0; i <= total; i++) {
22
+ const item = items[i];
23
+ const isItemString = typeof item === "string";
24
+ const isLimit = options?.maxDepth != null && options.maxDepth <= 0;
25
+ if (isLimit) {
26
+ const ellipsis = `${options.prefix}${options.ellipsis}
27
+ `;
28
+ return [
29
+ isItemString ? ellipsis : item.color ? box.colorize(item.color, ellipsis) : ellipsis
30
+ // prettier-ignore
31
+ ];
32
+ }
33
+ const isLast = i === total;
34
+ const prefix = isLast ? `${options?.prefix}\u2514\u2500` : `${options?.prefix}\u251C\u2500`;
35
+ if (isItemString) {
36
+ chunks.push(`${prefix}${item}
37
+ `);
38
+ } else {
39
+ const log = `${prefix}${item.text}
40
+ `;
41
+ chunks.push(item.color ? box.colorize(item.color, log) : log);
42
+ if (item.children) {
43
+ const _tree = _buildTree(item.children, {
44
+ ...options,
45
+ maxDepth: options?.maxDepth == null ? void 0 : options.maxDepth - 1,
46
+ prefix: `${options?.prefix}${isLast ? " " : "\u2502 "}`
47
+ });
48
+ chunks.push(..._tree);
49
+ }
50
+ }
51
+ }
52
+ return chunks;
53
+ }
54
+
55
+ exports.align = box.align;
56
+ exports.box = box.box;
57
+ exports.centerAlign = box.centerAlign;
58
+ exports.colorize = box.colorize;
59
+ exports.colors = box.colors;
60
+ exports.getColor = box.getColor;
61
+ exports.leftAlign = box.leftAlign;
62
+ exports.rightAlign = box.rightAlign;
63
+ exports.stripAnsi = box.stripAnsi;
64
+ exports.formatTree = formatTree;
@@ -0,0 +1,286 @@
1
+ type BoxBorderStyle = {
2
+ /**
3
+ * Top left corner
4
+ * @example `┌`
5
+ * @example `╔`
6
+ * @example `╓`
7
+ */
8
+ tl: string;
9
+ /**
10
+ * Top right corner
11
+ * @example `┐`
12
+ * @example `╗`
13
+ * @example `╖`
14
+ */
15
+ tr: string;
16
+ /**
17
+ * Bottom left corner
18
+ * @example `└`
19
+ * @example `╚`
20
+ * @example `╙`
21
+ */
22
+ bl: string;
23
+ /**
24
+ * Bottom right corner
25
+ * @example `┘`
26
+ * @example `╝`
27
+ * @example `╜`
28
+ */
29
+ br: string;
30
+ /**
31
+ * Horizontal line
32
+ * @example `─`
33
+ * @example `═`
34
+ * @example `─`
35
+ */
36
+ h: string;
37
+ /**
38
+ * Vertical line
39
+ * @example `│`
40
+ * @example `║`
41
+ * @example `║`
42
+ */
43
+ v: string;
44
+ };
45
+ declare const boxStylePresets: Record<string, BoxBorderStyle>;
46
+ type BoxStyle = {
47
+ /**
48
+ * The border color
49
+ * @default 'white'
50
+ */
51
+ borderColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
52
+ /**
53
+ * The border style
54
+ * @default 'solid'
55
+ * @example 'single-double-rounded'
56
+ * @example
57
+ * ```ts
58
+ * {
59
+ * tl: '┌',
60
+ * tr: '┐',
61
+ * bl: '└',
62
+ * br: '┘',
63
+ * h: '─',
64
+ * v: '│',
65
+ * }
66
+ * ```
67
+ */
68
+ borderStyle: BoxBorderStyle | keyof typeof boxStylePresets;
69
+ /**
70
+ * The vertical alignment of the text
71
+ * @default 'center'
72
+ */
73
+ valign: "top" | "center" | "bottom";
74
+ /**
75
+ * The padding of the box
76
+ * @default 2
77
+ */
78
+ padding: number;
79
+ /**
80
+ * The left margin of the box
81
+ * @default 1
82
+ */
83
+ marginLeft: number;
84
+ /**
85
+ * The top margin of the box
86
+ * @default 1
87
+ */
88
+ marginTop: number;
89
+ /**
90
+ * The top margin of the box
91
+ * @default 1
92
+ */
93
+ marginBottom: number;
94
+ };
95
+ /**
96
+ * The border options of the box
97
+ */
98
+ type BoxOpts = {
99
+ /**
100
+ * Title that will be displayed on top of the box
101
+ * @example 'Hello World'
102
+ * @example 'Hello {name}'
103
+ */
104
+ title?: string;
105
+ style?: Partial<BoxStyle>;
106
+ };
107
+ /**
108
+ * Creates a styled box with text content, customisable via options.
109
+ * @param {string} text - The text to display in the box.
110
+ * @param {BoxOpts} [_opts={}] - Optional settings for the appearance and behaviour of the box. See {@link BoxOpts}.
111
+ * @returns {string} The formatted box as a string, ready for printing or logging.
112
+ */
113
+ declare function box(text: string, _opts?: BoxOpts): string;
114
+
115
+ /**
116
+ * Based on https://github.com/jorgebucaran/colorette
117
+ * Read LICENSE file for more information
118
+ * https://github.com/jorgebucaran/colorette/blob/20fc196d07d0f87c61e0256eadd7831c79b24108/index.js
119
+ */
120
+ declare const colorDefs: {
121
+ reset: (string: string) => string;
122
+ bold: (string: string) => string;
123
+ dim: (string: string) => string;
124
+ italic: (string: string) => string;
125
+ underline: (string: string) => string;
126
+ inverse: (string: string) => string;
127
+ hidden: (string: string) => string;
128
+ strikethrough: (string: string) => string;
129
+ black: (string: string) => string;
130
+ red: (string: string) => string;
131
+ green: (string: string) => string;
132
+ yellow: (string: string) => string;
133
+ blue: (string: string) => string;
134
+ magenta: (string: string) => string;
135
+ cyan: (string: string) => string;
136
+ white: (string: string) => string;
137
+ gray: (string: string) => string;
138
+ bgBlack: (string: string) => string;
139
+ bgRed: (string: string) => string;
140
+ bgGreen: (string: string) => string;
141
+ bgYellow: (string: string) => string;
142
+ bgBlue: (string: string) => string;
143
+ bgMagenta: (string: string) => string;
144
+ bgCyan: (string: string) => string;
145
+ bgWhite: (string: string) => string;
146
+ blackBright: (string: string) => string;
147
+ redBright: (string: string) => string;
148
+ greenBright: (string: string) => string;
149
+ yellowBright: (string: string) => string;
150
+ blueBright: (string: string) => string;
151
+ magentaBright: (string: string) => string;
152
+ cyanBright: (string: string) => string;
153
+ whiteBright: (string: string) => string;
154
+ bgBlackBright: (string: string) => string;
155
+ bgRedBright: (string: string) => string;
156
+ bgGreenBright: (string: string) => string;
157
+ bgYellowBright: (string: string) => string;
158
+ bgBlueBright: (string: string) => string;
159
+ bgMagentaBright: (string: string) => string;
160
+ bgCyanBright: (string: string) => string;
161
+ bgWhiteBright: (string: string) => string;
162
+ };
163
+ type ColorName = keyof typeof colorDefs;
164
+ type ColorFunction = (text: string | number) => string;
165
+ /**
166
+ * An object containing functions for colouring text. Each function corresponds to a terminal colour. See {@link ColorName} for available colours.
167
+ */
168
+ declare const colors: Record<ColorName, ColorFunction>;
169
+ /**
170
+ * Gets a colour function by name, with an option for a fallback colour if the requested colour is not found.
171
+ * @param {ColorName} color - The name of the colour function to get. See {@link ColorName}.
172
+ * @param {ColorName} [fallback="reset"] - The name of the fallback colour function if the requested colour is not found. See {@link ColorName}.
173
+ * @returns {ColorFunction} The colour function that corresponds to the requested colour, or the fallback colour function. See {@link ColorFunction}.
174
+ */
175
+ declare function getColor(color: ColorName, fallback?: ColorName): ColorFunction;
176
+ /**
177
+ * Applies a specified colour to a given text string or number.
178
+ * @param {ColorName} color - The colour to apply. See {@link ColorName}.
179
+ * @param {string | number} text - The text to colour.
180
+ * @returns {string} The coloured text.
181
+ */
182
+ declare function colorize(color: ColorName, text: string | number): string;
183
+
184
+ /**
185
+ * Removes ANSI escape codes from a given string. This is particularly useful for
186
+ * processing text that contains formatting codes, such as colours or styles, so that the
187
+ * the raw text without any visual formatting.
188
+ *
189
+ * @param {string} text - The text string from which to strip the ANSI escape codes.
190
+ * @returns {string} The text without ANSI escape codes.
191
+ */
192
+ declare function stripAnsi(text: string): string;
193
+ /**
194
+ * Centers a string within a specified total width, padding it with spaces or another specified character.
195
+ * If the string is longer than the total width, it is returned as is.
196
+ *
197
+ * @param {string} str - The string to centre.
198
+ * @param {number} len - The total width in which to centre the string.
199
+ * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
200
+ * @returns {string} The centred string.
201
+ */
202
+ declare function centerAlign(str: string, len: number, space?: string): string;
203
+ /**
204
+ * Right-justifies a string within a given total width, padding it with whitespace or another specified character.
205
+ * If the string is longer than the total width, it is returned as is.
206
+ *
207
+ * @param {string} str - The string to right-justify.
208
+ * @param {number} len - The total width to align the string.
209
+ * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
210
+ * @returns {string} The right-justified string.
211
+ */
212
+ declare function rightAlign(str: string, len: number, space?: string): string;
213
+ /**
214
+ * Left-aligns a string within a given total width, padding it with whitespace or another specified character on the right.
215
+ * If the string is longer than the total width, it is returned as is.
216
+ *
217
+ * @param {string} str - The string to align left.
218
+ * @param {number} len - The total width to align the string.
219
+ * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
220
+ * @returns {string} The left-justified string.
221
+ */
222
+ declare function leftAlign(str: string, len: number, space?: string): string;
223
+ /**
224
+ * Aligns a string (left, right, or centre) within a given total width, padding it with spaces or another specified character.
225
+ * If the string is longer than the total width, it is returned as is. This function acts as a wrapper for individual alignment functions.
226
+ *
227
+ * @param {"left" | "right" | "centre"} alignment - The desired alignment of the string.
228
+ * @param {string} str - The string to align.
229
+ * @param {number} len - The total width in which to align the string.
230
+ * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
231
+ * @returns {string} The aligned string, according to the given alignment.
232
+ */
233
+ declare function align(alignment: "left" | "right" | "center", str: string, len: number, space?: string): string;
234
+
235
+ type TreeItemObject = {
236
+ /**
237
+ * Text of the item
238
+ */
239
+ text: string;
240
+ /**
241
+ * Children of the item
242
+ */
243
+ children?: TreeItem[];
244
+ /**
245
+ * Color of the item
246
+ */
247
+ color?: ColorName;
248
+ };
249
+ type TreeItem = string | TreeItemObject;
250
+ type TreeOptions = {
251
+ /**
252
+ * Color of the tree
253
+ */
254
+ color?: ColorName;
255
+ /**
256
+ * Prefix of the tree
257
+ *
258
+ * @default " "
259
+ */
260
+ prefix?: string;
261
+ /**
262
+ * The max depth of tree
263
+ */
264
+ maxDepth?: number;
265
+ /**
266
+ * Ellipsis of the tree
267
+ *
268
+ * @default "..."
269
+ */
270
+ ellipsis?: string;
271
+ };
272
+ /**
273
+ * Formats a hierarchical list of items into a string representing a tree structure.
274
+ * Each item in the tree can be a simple string or an object defining the text of the item,
275
+ * optional children, and colour. The tree structure can be customised with options
276
+ * Specify the overall colour and the prefix used for indentation and tree lines.
277
+ *
278
+ * @param {TreeItem[]} items - An array of items to include in the tree. Each item can be
279
+ * either a string or an object with `text', `children' and `colour' properties.
280
+ * @param {TreeOptions} [options] - Optional settings to customise the appearance of the tree, including
281
+ * the colour of the tree text and the prefix for branches. See {@link TreeOptions}.
282
+ * @returns {string} The formatted tree as a string, ready for printing to the console or elsewhere.
283
+ */
284
+ declare function formatTree(items: TreeItem[], options?: TreeOptions): string;
285
+
286
+ export { type BoxBorderStyle, type BoxOpts, type BoxStyle, type ColorFunction, type ColorName, type TreeItem, type TreeItemObject, type TreeOptions, align, box, centerAlign, colorize, colors, formatTree, getColor, leftAlign, rightAlign, stripAnsi };