@outfitter/cli 0.1.0-rc.1 → 0.1.0-rc.3

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 (266) hide show
  1. package/README.md +21 -32
  2. package/dist/actions.js +1 -1
  3. package/dist/borders/index.d.ts +3 -0
  4. package/dist/borders/index.js +13 -0
  5. package/dist/box/index.d.ts +4 -0
  6. package/dist/box/index.js +13 -0
  7. package/dist/cli.d.ts +2 -103
  8. package/dist/cli.js +4 -51
  9. package/dist/colors/index.d.ts +3 -0
  10. package/dist/colors/index.js +18 -0
  11. package/dist/command.d.ts +3 -37
  12. package/dist/command.js +5 -1
  13. package/dist/demo/index.d.ts +78 -0
  14. package/dist/demo/index.js +148 -0
  15. package/dist/demo/registry.d.ts +7 -0
  16. package/dist/demo/registry.js +28 -0
  17. package/dist/demo/renderers/borders.d.ts +7 -0
  18. package/dist/demo/renderers/borders.js +17 -0
  19. package/dist/demo/renderers/box.d.ts +7 -0
  20. package/dist/demo/renderers/box.js +18 -0
  21. package/dist/demo/renderers/colors.d.ts +7 -0
  22. package/dist/demo/renderers/colors.js +18 -0
  23. package/dist/demo/renderers/indicators.d.ts +7 -0
  24. package/dist/demo/renderers/indicators.js +17 -0
  25. package/dist/demo/renderers/list.d.ts +7 -0
  26. package/dist/demo/renderers/list.js +19 -0
  27. package/dist/demo/renderers/markdown.d.ts +7 -0
  28. package/dist/demo/renderers/markdown.js +18 -0
  29. package/dist/demo/renderers/progress.d.ts +7 -0
  30. package/dist/demo/renderers/progress.js +17 -0
  31. package/dist/demo/renderers/spinner.d.ts +7 -0
  32. package/dist/demo/renderers/spinner.js +19 -0
  33. package/dist/demo/renderers/table.d.ts +7 -0
  34. package/dist/demo/renderers/table.js +19 -0
  35. package/dist/demo/renderers/text.d.ts +7 -0
  36. package/dist/demo/renderers/text.js +16 -0
  37. package/dist/demo/renderers/tree.d.ts +7 -0
  38. package/dist/demo/renderers/tree.js +18 -0
  39. package/dist/demo/section.d.ts +5 -0
  40. package/dist/demo/section.js +23 -0
  41. package/dist/demo/templates.d.ts +4 -0
  42. package/dist/demo/templates.js +10 -0
  43. package/dist/demo/types.d.ts +3 -0
  44. package/dist/demo/types.js +8 -0
  45. package/dist/index.d.ts +5 -607
  46. package/dist/index.js +10 -44
  47. package/dist/input.d.ts +9 -123
  48. package/dist/input.js +2 -3
  49. package/dist/list/index.d.ts +3 -0
  50. package/dist/list/index.js +9 -0
  51. package/dist/output.d.ts +2 -68
  52. package/dist/output.js +4 -150
  53. package/dist/pagination.d.ts +1 -34
  54. package/dist/pagination.js +1 -1
  55. package/dist/preset/full.d.ts +14 -0
  56. package/dist/preset/full.js +41 -0
  57. package/dist/preset/standard.d.ts +11 -0
  58. package/dist/preset/standard.js +30 -0
  59. package/dist/prompt/confirm.d.ts +4 -0
  60. package/dist/prompt/confirm.js +9 -0
  61. package/dist/prompt/group.d.ts +4 -0
  62. package/dist/prompt/group.js +9 -0
  63. package/dist/prompt/index.d.ts +7 -0
  64. package/dist/prompt/index.js +32 -0
  65. package/dist/prompt/select.d.ts +4 -0
  66. package/dist/prompt/select.js +11 -0
  67. package/dist/prompt/text.d.ts +4 -0
  68. package/dist/prompt/text.js +11 -0
  69. package/dist/prompt/types.d.ts +3 -0
  70. package/dist/prompt/types.js +8 -0
  71. package/dist/prompt/validators.d.ts +2 -0
  72. package/dist/prompt/validators.js +8 -0
  73. package/dist/render/borders.d.ts +2 -0
  74. package/dist/render/borders.js +15 -0
  75. package/dist/render/box.d.ts +3 -0
  76. package/dist/render/box.js +23 -0
  77. package/dist/render/colors.d.ts +2 -0
  78. package/dist/render/colors.js +20 -0
  79. package/dist/render/date.d.ts +2 -0
  80. package/dist/render/date.js +12 -0
  81. package/dist/render/format-relative.d.ts +2 -0
  82. package/dist/render/format-relative.js +8 -0
  83. package/dist/render/format.d.ts +2 -0
  84. package/dist/render/format.js +10 -0
  85. package/dist/render/heading.d.ts +3 -0
  86. package/dist/render/heading.js +14 -0
  87. package/dist/render/index.d.ts +32 -0
  88. package/dist/render/index.js +235 -0
  89. package/dist/render/indicators.d.ts +2 -0
  90. package/dist/render/indicators.js +14 -0
  91. package/dist/render/json.d.ts +2 -0
  92. package/dist/render/json.js +10 -0
  93. package/dist/render/layout.d.ts +5 -0
  94. package/dist/render/layout.js +25 -0
  95. package/dist/render/list.d.ts +2 -0
  96. package/dist/render/list.js +8 -0
  97. package/dist/render/markdown.d.ts +2 -0
  98. package/dist/render/markdown.js +10 -0
  99. package/dist/render/progress.d.ts +2 -0
  100. package/dist/render/progress.js +8 -0
  101. package/dist/render/separator.d.ts +3 -0
  102. package/dist/render/separator.js +14 -0
  103. package/dist/render/shapes.d.ts +2 -0
  104. package/dist/render/shapes.js +35 -0
  105. package/dist/render/spinner.d.ts +2 -0
  106. package/dist/render/spinner.js +12 -0
  107. package/dist/render/stack.d.ts +3 -0
  108. package/dist/render/stack.js +38 -0
  109. package/dist/render/table.d.ts +3 -0
  110. package/dist/render/table.js +12 -0
  111. package/dist/render/text.d.ts +2 -0
  112. package/dist/render/text.js +27 -0
  113. package/dist/render/tree.d.ts +2 -0
  114. package/dist/render/tree.js +10 -0
  115. package/dist/render/types.d.ts +2 -0
  116. package/dist/render/types.js +1 -0
  117. package/dist/shared/@outfitter/cli-0ggcy7fa.js +20 -0
  118. package/dist/shared/@outfitter/cli-0psys2vm.js +7 -0
  119. package/dist/shared/@outfitter/cli-1bghjef6.js +352 -0
  120. package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +45 -0
  121. package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +50 -0
  122. package/dist/shared/@outfitter/cli-33e97cjs.d.ts +42 -0
  123. package/dist/shared/@outfitter/cli-34fqr7bp.js +37 -0
  124. package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +97 -0
  125. package/dist/shared/@outfitter/cli-3dxmmy4c.d.ts +20 -0
  126. package/dist/shared/@outfitter/cli-3f12z5kf.d.ts +83 -0
  127. package/dist/shared/@outfitter/cli-3hp8qwx3.js +11 -0
  128. package/dist/shared/@outfitter/cli-3t2zaenc.d.ts +59 -0
  129. package/dist/shared/@outfitter/cli-4cb5g831.d.ts +147 -0
  130. package/dist/shared/@outfitter/cli-4w2a1rfy.d.ts +23 -0
  131. package/dist/shared/@outfitter/cli-4x6pqnez.js +20 -0
  132. package/dist/shared/@outfitter/cli-671sxkhj.js +146 -0
  133. package/dist/shared/@outfitter/cli-6bztk73z.d.ts +51 -0
  134. package/dist/shared/@outfitter/cli-6fxffp8k.js +1 -0
  135. package/dist/shared/@outfitter/cli-6j9qynm8.js +118 -0
  136. package/dist/shared/@outfitter/cli-6m988kh0.d.ts +61 -0
  137. package/dist/shared/@outfitter/cli-72kg550t.d.ts +53 -0
  138. package/dist/shared/@outfitter/cli-74ba31gz.js +134 -0
  139. package/dist/shared/@outfitter/cli-7gnrb8cr.js +214 -0
  140. package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +59 -0
  141. package/dist/shared/@outfitter/cli-7nm6edvh.d.ts +17 -0
  142. package/dist/shared/@outfitter/cli-85fg2vr5.js +123 -0
  143. package/dist/shared/@outfitter/cli-8a8xrzhy.js +20 -0
  144. package/dist/shared/@outfitter/cli-8aa1vhdn.d.ts +119 -0
  145. package/dist/shared/@outfitter/cli-8bwaw3pz.js +7 -0
  146. package/dist/shared/@outfitter/cli-8j5k6mr3.js +71 -0
  147. package/dist/shared/@outfitter/cli-8rx4g3s5.d.ts +41 -0
  148. package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +223 -0
  149. package/dist/shared/@outfitter/cli-96b2p4td.d.ts +56 -0
  150. package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +190 -0
  151. package/dist/shared/@outfitter/cli-9mtjjykw.js +67 -0
  152. package/dist/shared/@outfitter/cli-9nbyj2bt.js +128 -0
  153. package/dist/shared/@outfitter/cli-a4q87517.d.ts +64 -0
  154. package/dist/shared/@outfitter/cli-afhjqmg3.js +63 -0
  155. package/dist/shared/@outfitter/cli-an9j0h80.js +117 -0
  156. package/dist/shared/@outfitter/cli-ay411nbr.js +122 -0
  157. package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +132 -0
  158. package/dist/shared/@outfitter/cli-b5c2k0d7.js +39 -0
  159. package/dist/shared/@outfitter/cli-b5epywry.js +1 -0
  160. package/dist/shared/@outfitter/cli-bc17qeh2.js +19 -0
  161. package/dist/shared/@outfitter/cli-bcmcaz1b.js +23 -0
  162. package/dist/shared/@outfitter/cli-bf3vma4q.js +61 -0
  163. package/dist/shared/@outfitter/cli-c8q4f71g.js +144 -0
  164. package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +30 -0
  165. package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +53 -0
  166. package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +42 -0
  167. package/dist/shared/@outfitter/cli-cs45xd6q.js +59 -0
  168. package/dist/shared/@outfitter/cli-d7jpshq5.d.ts +128 -0
  169. package/dist/shared/@outfitter/cli-d9ad0rqj.js +75 -0
  170. package/dist/shared/@outfitter/cli-daw296mv.js +61 -0
  171. package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +91 -0
  172. package/dist/shared/@outfitter/cli-e73v3qqy.d.ts +93 -0
  173. package/dist/shared/@outfitter/cli-efy6jfcj.js +52 -0
  174. package/dist/shared/@outfitter/cli-en6zn6sj.js +1 -0
  175. package/dist/shared/@outfitter/cli-ep2cvtk8.js +48 -0
  176. package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +300 -0
  177. package/dist/shared/@outfitter/cli-f75h8e94.js +7 -0
  178. package/dist/shared/@outfitter/cli-fakncnjp.d.ts +106 -0
  179. package/dist/shared/@outfitter/cli-feb5j90n.js +94 -0
  180. package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +66 -0
  181. package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +328 -0
  182. package/dist/shared/@outfitter/cli-j19a91ck.js +30 -0
  183. package/dist/shared/@outfitter/cli-j4n8gaf3.js +95 -0
  184. package/dist/shared/@outfitter/cli-jejfypgf.js +85 -0
  185. package/dist/shared/@outfitter/cli-jhcdwvpn.js +135 -0
  186. package/dist/shared/@outfitter/cli-jjemfdta.js +85 -0
  187. package/dist/shared/@outfitter/cli-kc84wmch.js +267 -0
  188. package/dist/shared/@outfitter/cli-ktqme80d.js +7 -0
  189. package/dist/shared/@outfitter/cli-mhamvbty.d.ts +34 -0
  190. package/dist/shared/@outfitter/cli-mq0jp15z.js +1 -0
  191. package/dist/shared/@outfitter/cli-mymyavvj.d.ts +26 -0
  192. package/dist/shared/@outfitter/cli-n17gt1dz.js +19 -0
  193. package/dist/shared/@outfitter/cli-n9dbh0hp.js +51 -0
  194. package/dist/shared/@outfitter/cli-nvvc92c8.js +128 -0
  195. package/dist/shared/@outfitter/cli-p1m5dhrs.js +169 -0
  196. package/dist/shared/@outfitter/cli-p38sfxyk.js +25 -0
  197. package/dist/shared/@outfitter/cli-p3dqm1vd.js +22 -0
  198. package/dist/shared/@outfitter/cli-p9j1phge.js +20 -0
  199. package/dist/shared/@outfitter/cli-pkxmzavm.js +62 -0
  200. package/dist/shared/@outfitter/cli-q8r6jarq.d.ts +24 -0
  201. package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +71 -0
  202. package/dist/shared/@outfitter/cli-qjfc3j11.d.ts +112 -0
  203. package/dist/shared/@outfitter/cli-qp4cbhqr.js +70 -0
  204. package/dist/shared/@outfitter/cli-s0kkx9m1.d.ts +164 -0
  205. package/dist/shared/@outfitter/cli-snxj55n6.js +43 -0
  206. package/dist/shared/@outfitter/cli-swwxvjvm.d.ts +24 -0
  207. package/dist/shared/@outfitter/cli-sx67mmfx.d.ts +98 -0
  208. package/dist/shared/@outfitter/cli-tarpsa8a.js +30 -0
  209. package/dist/shared/@outfitter/cli-thvzhjd1.js +126 -0
  210. package/dist/shared/@outfitter/cli-tqewy503.d.ts +36 -0
  211. package/dist/shared/@outfitter/cli-ttt7r0j7.d.ts +253 -0
  212. package/dist/shared/@outfitter/cli-tvw1xrdj.js +20 -0
  213. package/dist/shared/@outfitter/cli-v1tzwxkt.js +32 -0
  214. package/dist/shared/@outfitter/cli-vd60dj65.js +1 -0
  215. package/dist/shared/@outfitter/cli-vp88gxev.js +279 -0
  216. package/dist/shared/@outfitter/cli-vstbkzky.d.ts +74 -0
  217. package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +54 -0
  218. package/dist/shared/@outfitter/cli-w5y3xepp.js +20 -0
  219. package/dist/shared/@outfitter/cli-x4cavvc0.js +1 -0
  220. package/dist/shared/@outfitter/cli-xep6v2c0.js +52 -0
  221. package/dist/shared/@outfitter/cli-xg5y5fhk.js +86 -0
  222. package/dist/shared/@outfitter/cli-xsaheemc.d.ts +248 -0
  223. package/dist/shared/@outfitter/cli-xvqtqjxk.js +82 -0
  224. package/dist/shared/@outfitter/cli-y25tt8nc.d.ts +48 -0
  225. package/dist/shared/@outfitter/cli-zact3325.js +152 -0
  226. package/dist/shared/@outfitter/cli-zx598p8q.d.ts +26 -0
  227. package/dist/streaming/ansi.d.ts +2 -0
  228. package/dist/streaming/ansi.js +8 -0
  229. package/dist/streaming/index.d.ts +4 -0
  230. package/dist/streaming/index.js +17 -0
  231. package/dist/streaming/spinner.d.ts +3 -0
  232. package/dist/streaming/spinner.js +10 -0
  233. package/dist/streaming/writer.d.ts +2 -0
  234. package/dist/streaming/writer.js +9 -0
  235. package/dist/table/index.d.ts +4 -0
  236. package/dist/table/index.js +13 -0
  237. package/dist/terminal/detection.d.ts +2 -0
  238. package/dist/terminal/detection.js +23 -0
  239. package/dist/terminal/index.d.ts +2 -0
  240. package/dist/terminal/index.js +24 -0
  241. package/dist/theme/context.d.ts +9 -0
  242. package/dist/theme/context.js +14 -0
  243. package/dist/theme/create.d.ts +8 -0
  244. package/dist/theme/create.js +12 -0
  245. package/dist/theme/index.d.ts +17 -0
  246. package/dist/theme/index.js +42 -0
  247. package/dist/theme/presets/bold.d.ts +8 -0
  248. package/dist/theme/presets/bold.js +12 -0
  249. package/dist/theme/presets/default.d.ts +8 -0
  250. package/dist/theme/presets/default.js +11 -0
  251. package/dist/theme/presets/index.d.ts +12 -0
  252. package/dist/theme/presets/index.js +24 -0
  253. package/dist/theme/presets/minimal.d.ts +8 -0
  254. package/dist/theme/presets/minimal.js +12 -0
  255. package/dist/theme/presets/rounded.d.ts +8 -0
  256. package/dist/theme/presets/rounded.js +12 -0
  257. package/dist/theme/resolve.d.ts +8 -0
  258. package/dist/theme/resolve.js +11 -0
  259. package/dist/theme/types.d.ts +7 -0
  260. package/dist/theme/types.js +1 -0
  261. package/dist/tree/index.d.ts +3 -0
  262. package/dist/tree/index.js +11 -0
  263. package/dist/types.d.ts +1 -252
  264. package/dist/types.js +1 -1
  265. package/package.json +228 -20
  266. package/dist/shared/@outfitter/cli-4yy82cmp.js +0 -20
@@ -0,0 +1,123 @@
1
+ // @bun
2
+ import {
3
+ __esm
4
+ } from "./cli-v1tzwxkt.js";
5
+
6
+ // packages/cli/src/render/borders.ts
7
+ function getBorderCharacters(style) {
8
+ return BORDERS[style];
9
+ }
10
+ function drawHorizontalLine(width, chars, position, columnWidths) {
11
+ if (!chars.horizontal) {
12
+ return "";
13
+ }
14
+ const positionChars = {
15
+ top: { left: chars.topLeft, right: chars.topRight, cross: chars.topT },
16
+ middle: { left: chars.leftT, right: chars.rightT, cross: chars.cross },
17
+ bottom: {
18
+ left: chars.bottomLeft,
19
+ right: chars.bottomRight,
20
+ cross: chars.bottomT
21
+ }
22
+ };
23
+ const { left, right, cross: intersection } = positionChars[position];
24
+ if (!columnWidths || columnWidths.length <= 1) {
25
+ return `${left}${chars.horizontal.repeat(width)}${right}`;
26
+ }
27
+ const columnsWidth = columnWidths.reduce((sum, w) => sum + w, 0);
28
+ const intersectionsWidth = columnWidths.length - 1;
29
+ const actualWidth = columnsWidth + intersectionsWidth;
30
+ const adjustedWidths = [...columnWidths];
31
+ if (actualWidth !== width && adjustedWidths.length > 0) {
32
+ const lastIndex = adjustedWidths.length - 1;
33
+ const lastWidth = adjustedWidths[lastIndex] ?? 0;
34
+ adjustedWidths[lastIndex] = Math.max(0, lastWidth + (width - actualWidth));
35
+ }
36
+ const segments = adjustedWidths.map((colWidth) => chars.horizontal.repeat(colWidth));
37
+ return `${left}${segments.join(intersection)}${right}`;
38
+ }
39
+ var BORDERS;
40
+ var init_borders = __esm(() => {
41
+ BORDERS = {
42
+ single: {
43
+ topLeft: "\u250C",
44
+ topRight: "\u2510",
45
+ bottomLeft: "\u2514",
46
+ bottomRight: "\u2518",
47
+ horizontal: "\u2500",
48
+ vertical: "\u2502",
49
+ topT: "\u252C",
50
+ bottomT: "\u2534",
51
+ leftT: "\u251C",
52
+ rightT: "\u2524",
53
+ cross: "\u253C"
54
+ },
55
+ double: {
56
+ topLeft: "\u2554",
57
+ topRight: "\u2557",
58
+ bottomLeft: "\u255A",
59
+ bottomRight: "\u255D",
60
+ horizontal: "\u2550",
61
+ vertical: "\u2551",
62
+ topT: "\u2566",
63
+ bottomT: "\u2569",
64
+ leftT: "\u2560",
65
+ rightT: "\u2563",
66
+ cross: "\u256C"
67
+ },
68
+ rounded: {
69
+ topLeft: "\u256D",
70
+ topRight: "\u256E",
71
+ bottomLeft: "\u2570",
72
+ bottomRight: "\u256F",
73
+ horizontal: "\u2500",
74
+ vertical: "\u2502",
75
+ topT: "\u252C",
76
+ bottomT: "\u2534",
77
+ leftT: "\u251C",
78
+ rightT: "\u2524",
79
+ cross: "\u253C"
80
+ },
81
+ heavy: {
82
+ topLeft: "\u250F",
83
+ topRight: "\u2513",
84
+ bottomLeft: "\u2517",
85
+ bottomRight: "\u251B",
86
+ horizontal: "\u2501",
87
+ vertical: "\u2503",
88
+ topT: "\u2533",
89
+ bottomT: "\u253B",
90
+ leftT: "\u2523",
91
+ rightT: "\u252B",
92
+ cross: "\u254B"
93
+ },
94
+ ascii: {
95
+ topLeft: "+",
96
+ topRight: "+",
97
+ bottomLeft: "+",
98
+ bottomRight: "+",
99
+ horizontal: "-",
100
+ vertical: "|",
101
+ topT: "+",
102
+ bottomT: "+",
103
+ leftT: "+",
104
+ rightT: "+",
105
+ cross: "+"
106
+ },
107
+ none: {
108
+ topLeft: "",
109
+ topRight: "",
110
+ bottomLeft: "",
111
+ bottomRight: "",
112
+ horizontal: "",
113
+ vertical: "",
114
+ topT: "",
115
+ bottomT: "",
116
+ leftT: "",
117
+ rightT: "",
118
+ cross: ""
119
+ }
120
+ };
121
+ });
122
+
123
+ export { BORDERS, getBorderCharacters, drawHorizontalLine, init_borders };
@@ -0,0 +1,20 @@
1
+ // @bun
2
+ import {
3
+ defaultTheme
4
+ } from "./cli-cs45xd6q.js";
5
+ import {
6
+ BORDERS,
7
+ init_borders
8
+ } from "./cli-85fg2vr5.js";
9
+
10
+ // packages/cli/src/theme/presets/bold.ts
11
+ init_borders();
12
+ var boldTheme = {
13
+ ...defaultTheme,
14
+ name: "bold",
15
+ border: "heavy",
16
+ borderChars: BORDERS.heavy,
17
+ treeGuide: "heavy"
18
+ };
19
+
20
+ export { boldTheme };
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Options for terminal detection functions.
3
+ *
4
+ * These options allow overriding automatic detection for testing
5
+ * or specific environments.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Force TTY mode for testing
10
+ * supportsColor({ isTTY: true });
11
+ *
12
+ * // Simulate CI environment
13
+ * isInteractive({ isTTY: true, isCI: true }); // returns false
14
+ * ```
15
+ */
16
+ interface TerminalOptions {
17
+ /** Override TTY detection (uses process.stdout.isTTY if not specified) */
18
+ isTTY?: boolean;
19
+ /** Override CI detection (uses CI env variable if not specified) */
20
+ isCI?: boolean;
21
+ }
22
+ /**
23
+ * Gets the value of an environment variable.
24
+ *
25
+ * @param key - Environment variable name
26
+ * @returns The value if set, undefined otherwise
27
+ */
28
+ declare function getEnvValue(key: "NO_COLOR" | "FORCE_COLOR"): string | undefined;
29
+ /**
30
+ * Checks if NO_COLOR environment variable is set.
31
+ *
32
+ * @returns `true` if NO_COLOR is set (even if empty)
33
+ */
34
+ declare function hasNoColorEnv(): boolean;
35
+ /**
36
+ * Resolves the FORCE_COLOR environment variable.
37
+ *
38
+ * @returns `true` if colors should be forced, `false` if explicitly disabled, `undefined` if not set
39
+ */
40
+ declare function resolveForceColorEnv(): boolean | undefined;
41
+ /**
42
+ * Resolves color environment variables with configurable priority.
43
+ *
44
+ * @param options - Options for resolution priority
45
+ * @returns `true` if colors enabled, `false` if disabled, `undefined` if not determined by env
46
+ */
47
+ declare function resolveColorEnv(options?: {
48
+ forceColorFirst?: boolean;
49
+ }): boolean | undefined;
50
+ /**
51
+ * Checks if the current environment supports ANSI colors.
52
+ *
53
+ * Detection priority:
54
+ * 1. `NO_COLOR` env variable - if set (even empty), returns false (per no-color.org)
55
+ * 2. `FORCE_COLOR` env variable - if set, returns true (numeric levels > 0)
56
+ * 3. Falls back to TTY detection via `process.stdout.isTTY`
57
+ *
58
+ * @param options - Optional overrides for TTY detection
59
+ * @returns `true` if colors are supported, `false` otherwise
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * if (supportsColor()) {
64
+ * console.log("\x1b[32mGreen text\x1b[0m");
65
+ * } else {
66
+ * console.log("Plain text");
67
+ * }
68
+ *
69
+ * // With explicit TTY override for testing
70
+ * supportsColor({ isTTY: true }); // true (unless NO_COLOR is set)
71
+ * supportsColor({ isTTY: false }); // false (unless FORCE_COLOR is set)
72
+ * ```
73
+ */
74
+ declare function supportsColor(options?: TerminalOptions): boolean;
75
+ /**
76
+ * Gets the terminal width in columns.
77
+ *
78
+ * Returns `process.stdout.columns` when in a TTY, or 80 as a fallback
79
+ * for non-TTY environments (pipes, CI, etc.).
80
+ *
81
+ * @param options - Optional overrides for TTY detection
82
+ * @returns Terminal width in columns (default: 80 if not TTY)
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const width = getTerminalWidth();
87
+ * console.log(`Terminal is ${width} columns wide`);
88
+ *
89
+ * // Force non-TTY mode (always returns 80)
90
+ * getTerminalWidth({ isTTY: false }); // 80
91
+ * ```
92
+ */
93
+ declare function getTerminalWidth(options?: TerminalOptions): number;
94
+ /**
95
+ * Checks if the terminal is interactive.
96
+ *
97
+ * A terminal is considered interactive when:
98
+ * - It is a TTY (process.stdout.isTTY is true)
99
+ * - It is NOT running in a CI environment (CI env variable is not set)
100
+ *
101
+ * Use this to decide whether to show interactive prompts or use
102
+ * non-interactive fallbacks.
103
+ *
104
+ * @param options - Optional overrides for TTY and CI detection
105
+ * @returns `true` if interactive prompts are safe to use
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * if (isInteractive()) {
110
+ * // Safe to use interactive prompts
111
+ * const answer = await prompt("Continue?");
112
+ * } else {
113
+ * // Use non-interactive defaults
114
+ * console.log("Running in non-interactive mode");
115
+ * }
116
+ * ```
117
+ */
118
+ declare function isInteractive(options?: TerminalOptions): boolean;
119
+ export { TerminalOptions, getEnvValue, hasNoColorEnv, resolveForceColorEnv, resolveColorEnv, supportsColor, getTerminalWidth, isInteractive };
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ // packages/cli/src/prompt/types.ts
3
+ function createCancelledError(message = "User cancelled") {
4
+ return { type: "cancelled", message };
5
+ }
6
+
7
+ export { createCancelledError };
@@ -0,0 +1,71 @@
1
+ // @bun
2
+ // packages/cli/src/render/format-relative.ts
3
+ function formatRelative(date) {
4
+ let timestamp;
5
+ if (date instanceof Date) {
6
+ timestamp = date.getTime();
7
+ } else if (typeof date === "number") {
8
+ timestamp = date;
9
+ } else {
10
+ const parsed = Date.parse(date);
11
+ if (Number.isNaN(parsed)) {
12
+ return "invalid date";
13
+ }
14
+ timestamp = parsed;
15
+ }
16
+ if (!Number.isFinite(timestamp)) {
17
+ return "invalid date";
18
+ }
19
+ const now = Date.now();
20
+ const diffMs = now - timestamp;
21
+ const absDiffMs = Math.abs(diffMs);
22
+ const isFuture = diffMs < 0;
23
+ const SECOND = 1000;
24
+ const MINUTE = 60 * SECOND;
25
+ const HOUR = 60 * MINUTE;
26
+ const DAY = 24 * HOUR;
27
+ const MONTH = 30 * DAY;
28
+ const YEAR = 365 * DAY;
29
+ if (absDiffMs < 10 * SECOND) {
30
+ return "just now";
31
+ }
32
+ if (absDiffMs < MINUTE) {
33
+ const seconds = Math.floor(absDiffMs / SECOND);
34
+ return isFuture ? `in ${seconds} seconds` : `${seconds} seconds ago`;
35
+ }
36
+ if (absDiffMs < HOUR) {
37
+ const minutes = Math.floor(absDiffMs / MINUTE);
38
+ if (minutes === 1) {
39
+ return isFuture ? "in 1 minute" : "1 minute ago";
40
+ }
41
+ return isFuture ? `in ${minutes} minutes` : `${minutes} minutes ago`;
42
+ }
43
+ if (absDiffMs < DAY) {
44
+ const hours = Math.floor(absDiffMs / HOUR);
45
+ if (hours === 1) {
46
+ return isFuture ? "in 1 hour" : "1 hour ago";
47
+ }
48
+ return isFuture ? `in ${hours} hours` : `${hours} hours ago`;
49
+ }
50
+ if (absDiffMs < 2 * DAY) {
51
+ return isFuture ? "tomorrow" : "yesterday";
52
+ }
53
+ if (absDiffMs < MONTH) {
54
+ const days = Math.floor(absDiffMs / DAY);
55
+ return isFuture ? `in ${days} days` : `${days} days ago`;
56
+ }
57
+ if (absDiffMs < YEAR) {
58
+ const months = Math.floor(absDiffMs / MONTH);
59
+ if (months === 1) {
60
+ return isFuture ? "in 1 month" : "1 month ago";
61
+ }
62
+ return isFuture ? `in ${months} months` : `${months} months ago`;
63
+ }
64
+ const years = Math.floor(absDiffMs / YEAR);
65
+ if (years === 1) {
66
+ return isFuture ? "in 1 year" : "1 year ago";
67
+ }
68
+ return isFuture ? `in ${years} years` : `${years} years ago`;
69
+ }
70
+
71
+ export { formatRelative };
@@ -0,0 +1,41 @@
1
+ import { PasswordPromptOptions, PromptResult, TextPromptOptions } from "./cli-3f12z5kf";
2
+ /**
3
+ * Prompts for text input with Result wrapping.
4
+ *
5
+ * @param options - Text prompt options
6
+ * @returns Ok with value or Err with CancelledError
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { promptText } from "@outfitter/cli/prompt";
11
+ *
12
+ * const result = await promptText({
13
+ * message: "What is your name?",
14
+ * placeholder: "Enter your name",
15
+ * validate: (v) => v.length > 0 || "Name is required",
16
+ * });
17
+ *
18
+ * if (result.isOk()) {
19
+ * console.log(`Hello, ${result.value}!`);
20
+ * }
21
+ * ```
22
+ */
23
+ declare function promptText(options: TextPromptOptions): PromptResult<string>;
24
+ /**
25
+ * Prompts for password input with Result wrapping.
26
+ *
27
+ * @param options - Password prompt options
28
+ * @returns Ok with value or Err with CancelledError
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { promptPassword } from "@outfitter/cli/prompt";
33
+ *
34
+ * const result = await promptPassword({
35
+ * message: "Enter your password:",
36
+ * validate: (v) => v.length >= 8 || "Password too short",
37
+ * });
38
+ * ```
39
+ */
40
+ declare function promptPassword(options: PasswordPromptOptions): PromptResult<string>;
41
+ export { promptText, promptPassword };
@@ -0,0 +1,223 @@
1
+ import { BorderStyle } from "./cli-fakncnjp";
2
+ /**
3
+ * Text alignment options for box content.
4
+ */
5
+ type BoxAlign = "left" | "center" | "right";
6
+ /**
7
+ * Options for customizing box rendering.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Box with title and rounded corners
12
+ * renderBox("Content", {
13
+ * title: "Status",
14
+ * border: "rounded",
15
+ * padding: 1,
16
+ * });
17
+ *
18
+ * // Fixed-width centered box
19
+ * renderBox("Centered", {
20
+ * width: 40,
21
+ * align: "center",
22
+ * });
23
+ * ```
24
+ */
25
+ /**
26
+ * Spacing configuration for individual sides.
27
+ */
28
+ interface BoxSpacing {
29
+ top?: number;
30
+ right?: number;
31
+ bottom?: number;
32
+ left?: number;
33
+ }
34
+ /**
35
+ * Border visibility configuration for individual sides.
36
+ */
37
+ interface BoxBorders {
38
+ top?: boolean;
39
+ right?: boolean;
40
+ bottom?: boolean;
41
+ left?: boolean;
42
+ }
43
+ interface BoxOptions {
44
+ /**
45
+ * Border style to use.
46
+ * @default "single"
47
+ */
48
+ border?: BorderStyle;
49
+ /**
50
+ * Control which borders to render.
51
+ * @default { top: true, right: true, bottom: true, left: true }
52
+ */
53
+ borders?: BoxBorders;
54
+ /**
55
+ * Internal padding (spaces between border and content).
56
+ * Can be a single number for all sides or an object for individual sides.
57
+ * @default 1
58
+ */
59
+ padding?: number | BoxSpacing;
60
+ /**
61
+ * External margin (spacing outside the box).
62
+ * Can be a single number for all sides or an object for individual sides.
63
+ */
64
+ margin?: number | BoxSpacing;
65
+ /**
66
+ * Fixed width for the box. If not specified, auto-fits to content.
67
+ */
68
+ width?: number;
69
+ /**
70
+ * Optional title to display in the top border.
71
+ */
72
+ title?: string;
73
+ /**
74
+ * Content alignment within the box.
75
+ * @default "left"
76
+ */
77
+ align?: BoxAlign;
78
+ /**
79
+ * Content sections separated by internal dividers.
80
+ * Each section can be a string or string[].
81
+ * When provided, takes precedence over the content parameter.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * renderBox("", {
86
+ * sections: [
87
+ * "Header",
88
+ * ["Line 1", "Line 2"],
89
+ * "Footer"
90
+ * ],
91
+ * border: "single"
92
+ * });
93
+ * // ┌─────────────────┐
94
+ * // │ Header │
95
+ * // ├─────────────────┤
96
+ * // │ Line 1 │
97
+ * // │ Line 2 │
98
+ * // ├─────────────────┤
99
+ * // │ Footer │
100
+ * // └─────────────────┘
101
+ * ```
102
+ */
103
+ sections?: Array<string | string[]>;
104
+ }
105
+ /**
106
+ * A rendered box with metadata for composition.
107
+ */
108
+ interface Box {
109
+ /** Rendered string representation */
110
+ readonly output: string;
111
+ /** Width in characters */
112
+ readonly width: number;
113
+ /** Height in lines */
114
+ readonly height: number;
115
+ }
116
+ /**
117
+ * Content that can be rendered inside a box.
118
+ * - string: Plain text content
119
+ * - string[]: Multi-line content
120
+ * - Box: Nested box (rendered string with metadata)
121
+ */
122
+ type BoxContent = string | string[] | Box;
123
+ /**
124
+ * Normalized spacing with all four sides defined.
125
+ */
126
+ interface NormalizedSpacing {
127
+ top: number;
128
+ right: number;
129
+ bottom: number;
130
+ left: number;
131
+ }
132
+ /**
133
+ * Normalized borders with all four sides defined.
134
+ */
135
+ interface NormalizedBorders {
136
+ top: boolean;
137
+ right: boolean;
138
+ bottom: boolean;
139
+ left: boolean;
140
+ }
141
+ /**
142
+ * Normalizes padding input to have all four sides.
143
+ * For backward compatibility, when padding is a number it only applies to horizontal (left/right).
144
+ * When padding is an object, all sides can be specified.
145
+ */
146
+ declare function normalizePadding(padding: number | BoxSpacing | undefined, defaultValue: number): NormalizedSpacing;
147
+ /**
148
+ * Normalizes margin input to have all four sides.
149
+ * When margin is a number, it applies to all sides.
150
+ */
151
+ declare function normalizeMargin(margin: number | BoxSpacing | undefined, defaultValue: number): NormalizedSpacing;
152
+ /**
153
+ * Normalizes borders input to have all four sides.
154
+ */
155
+ declare function normalizeBorders(borders: BoxBorders | undefined): NormalizedBorders;
156
+ /**
157
+ * Renders content within a bordered panel.
158
+ *
159
+ * Creates a box with Unicode borders around the content. Supports multiple
160
+ * border styles, titles, padding, and alignment options.
161
+ *
162
+ * @param content - The content to render (string or array of strings)
163
+ * @param options - Optional configuration for border style, padding, etc.
164
+ * @returns Formatted box string
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // Simple box
169
+ * console.log(renderBox("Hello, world!"));
170
+ * // ┌───────────────┐
171
+ * // │ Hello, world! │
172
+ * // └───────────────┘
173
+ *
174
+ * // Box with title
175
+ * console.log(renderBox("All systems go", { title: "Status" }));
176
+ * // ┌─ Status ──────┐
177
+ * // │ All systems go │
178
+ * // └────────────────┘
179
+ *
180
+ * // Rounded box with padding
181
+ * console.log(renderBox(["Line 1", "Line 2"], {
182
+ * border: "rounded",
183
+ * padding: 2,
184
+ * }));
185
+ * // ╭──────────────╮
186
+ * // │ │
187
+ * // │ Line 1 │
188
+ * // │ Line 2 │
189
+ * // │ │
190
+ * // ╰──────────────╯
191
+ * ```
192
+ */
193
+ declare function renderBox(content: string | string[], options?: BoxOptions): string;
194
+ /**
195
+ * Creates a Box object that can be composed with other boxes.
196
+ *
197
+ * Unlike `renderBox` which returns a string, `createBox` returns a Box object
198
+ * with metadata (width, height) that enables nested composition.
199
+ *
200
+ * @param content - The content to render (string, string[], Box, or array of mixed)
201
+ * @param options - Optional configuration for border style, padding, etc.
202
+ * @returns Box object with output, width, and height
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * // Simple box
207
+ * const box = createBox("Hello");
208
+ * console.log(box.output);
209
+ * console.log(`Width: ${box.width}, Height: ${box.height}`);
210
+ *
211
+ * // Nested boxes
212
+ * const inner = createBox("Inner", { border: "rounded" });
213
+ * const outer = createBox(inner, { border: "double", title: "Container" });
214
+ * console.log(outer.output);
215
+ * // ╔═ Container ═══════════════╗
216
+ * // ║ ╭───────────────────────╮ ║
217
+ * // ║ │ Inner │ ║
218
+ * // ║ ╰───────────────────────╯ ║
219
+ * // ╚═══════════════════════════╝
220
+ * ```
221
+ */
222
+ declare function createBox(content: BoxContent | BoxContent[], options?: BoxOptions): Box;
223
+ export { BoxAlign, BoxSpacing, BoxBorders, BoxOptions, Box, BoxContent, NormalizedSpacing, NormalizedBorders, normalizePadding, normalizeMargin, normalizeBorders, renderBox, createBox };
@@ -0,0 +1,56 @@
1
+ import { SpinnerStyle } from "./cli-e5ms1y0x";
2
+ import { ListStyle } from "./cli-b0tzqgnf";
3
+ import { BorderStyle } from "./cli-fakncnjp";
4
+ import { PrimitiveId, PrimitiveMeta, ThemeMethodMeta, VariantMeta } from "./cli-qjfc3j11";
5
+ import { Theme } from "./cli-xsaheemc";
6
+ /**
7
+ * Type-safe metadata for all theme methods.
8
+ *
9
+ * Uses `keyof Theme` to ensure every theme method has metadata.
10
+ * Adding a new method to Theme without updating this causes a compile error.
11
+ */
12
+ declare const THEME_METHOD_META: Record<keyof Theme, ThemeMethodMeta>;
13
+ /**
14
+ * Gets theme methods grouped by category.
15
+ */
16
+ declare function getThemeMethodsByCategory(): {
17
+ semantic: Array<keyof Theme>;
18
+ utility: Array<keyof Theme>;
19
+ };
20
+ /**
21
+ * Type-safe metadata for all border styles.
22
+ */
23
+ declare const BORDER_STYLE_META: Record<BorderStyle, VariantMeta<BorderStyle>>;
24
+ /**
25
+ * Gets all border styles as an array.
26
+ */
27
+ declare function getBorderStyles(): BorderStyle[];
28
+ /**
29
+ * Type-safe metadata for all spinner styles.
30
+ */
31
+ declare const SPINNER_STYLE_META: Record<SpinnerStyle, VariantMeta<SpinnerStyle>>;
32
+ /**
33
+ * Gets all spinner styles as an array.
34
+ */
35
+ declare function getSpinnerStyles(): SpinnerStyle[];
36
+ /**
37
+ * Type-safe metadata for all list styles.
38
+ */
39
+ declare const LIST_STYLE_META: Record<ListStyle, VariantMeta<ListStyle>>;
40
+ /**
41
+ * Gets all list styles as an array.
42
+ */
43
+ declare function getListStyles(): ListStyle[];
44
+ /**
45
+ * Type-safe metadata for all primitives.
46
+ */
47
+ declare const PRIMITIVE_META: Record<PrimitiveId, PrimitiveMeta>;
48
+ /**
49
+ * Gets all primitive IDs as an array.
50
+ */
51
+ declare function getPrimitiveIds(): PrimitiveId[];
52
+ /**
53
+ * Gets metadata for a specific primitive.
54
+ */
55
+ declare function getPrimitiveMeta(id: PrimitiveId): PrimitiveMeta;
56
+ export { THEME_METHOD_META, getThemeMethodsByCategory, BORDER_STYLE_META, getBorderStyles, SPINNER_STYLE_META, getSpinnerStyles, LIST_STYLE_META, getListStyles, PRIMITIVE_META, getPrimitiveIds, getPrimitiveMeta };