@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,97 @@
1
+ /**
2
+ * Tree rendering utilities.
3
+ *
4
+ * Renders hierarchical data as ASCII trees with box-drawing characters.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ /**
9
+ * Available tree guide styles.
10
+ *
11
+ * - `single`: Standard Unicode box-drawing (default)
12
+ * - `heavy`: Thick/bold box-drawing characters
13
+ * - `double`: Double-line box-drawing characters
14
+ * - `rounded`: Rounded corners (╰ instead of └)
15
+ */
16
+ type TreeGuideStyle = "single" | "heavy" | "double" | "rounded";
17
+ /**
18
+ * Tree guide character sets for different visual styles.
19
+ */
20
+ declare const TREE_GUIDES: Record<TreeGuideStyle, {
21
+ vertical: string;
22
+ fork: string;
23
+ end: string;
24
+ }>;
25
+ /**
26
+ * Options for customizing tree rendering.
27
+ */
28
+ interface TreeOptions {
29
+ /**
30
+ * Guide style for tree branches.
31
+ * @default "single"
32
+ */
33
+ guide?: TreeGuideStyle;
34
+ /**
35
+ * Maximum depth to render (1 = root children only).
36
+ * @default undefined (unlimited)
37
+ */
38
+ maxDepth?: number;
39
+ /**
40
+ * Custom function to render node labels.
41
+ * Receives the key, value, and current depth.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * renderLabel: (key, value, depth) => {
46
+ * if (value && typeof value === "object") {
47
+ * return `📁 ${key}/`;
48
+ * }
49
+ * return `📄 ${key}`;
50
+ * }
51
+ * ```
52
+ */
53
+ renderLabel?: (key: string, value: unknown, depth: number) => string;
54
+ }
55
+ /**
56
+ * Renders hierarchical data as a tree with unicode box-drawing characters.
57
+ *
58
+ * Uses unicode characters for tree structure.
59
+ * Nested objects are rendered as child nodes; leaf values (null, primitives)
60
+ * are rendered as terminal nodes.
61
+ *
62
+ * @param tree - Hierarchical object to render
63
+ * @param options - Customization options
64
+ * @returns Formatted tree string with box-drawing characters
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const tree = {
69
+ * src: {
70
+ * components: {
71
+ * Button: null,
72
+ * Input: null,
73
+ * },
74
+ * utils: null,
75
+ * },
76
+ * tests: null,
77
+ * };
78
+ *
79
+ * console.log(renderTree(tree));
80
+ * // ├── src
81
+ * // │ ├── components
82
+ * // │ │ ├── Button
83
+ * // │ │ └── Input
84
+ * // │ └── utils
85
+ * // └── tests
86
+ *
87
+ * console.log(renderTree(tree, { guide: "rounded" }));
88
+ * // ├── src
89
+ * // │ ├── components
90
+ * // │ │ ├── Button
91
+ * // │ │ ╰── Input
92
+ * // │ ╰── utils
93
+ * // ╰── tests
94
+ * ```
95
+ */
96
+ declare function renderTree(tree: Record<string, unknown>, options?: TreeOptions): string;
97
+ export { TreeGuideStyle, TREE_GUIDES, TreeOptions, renderTree };
@@ -0,0 +1,20 @@
1
+ import { VisualTheme } from "./cli-s0kkx9m1";
2
+ /**
3
+ * Default visual theme.
4
+ *
5
+ * Features:
6
+ * - Single-line box-drawing borders (┌─┐)
7
+ * - Standard status indicators
8
+ * - Bullet delimiters
9
+ * - Dots spinner
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { defaultTheme } from "@outfitter/cli/theme/presets";
14
+ *
15
+ * // Use default styling
16
+ * const box = renderBox("Hello", { border: defaultTheme.border });
17
+ * ```
18
+ */
19
+ declare const defaultTheme: VisualTheme;
20
+ export { defaultTheme };
@@ -0,0 +1,83 @@
1
+ import { Validator } from "./cli-vstbkzky";
2
+ import { Result } from "better-result";
3
+ /**
4
+ * Error returned when user cancels a prompt.
5
+ */
6
+ interface CancelledError {
7
+ type: "cancelled";
8
+ message: string;
9
+ }
10
+ /**
11
+ * Creates a cancelled error.
12
+ */
13
+ declare function createCancelledError(message?: string): CancelledError;
14
+ /**
15
+ * Options for text prompts.
16
+ */
17
+ interface TextPromptOptions {
18
+ /** Prompt message to display */
19
+ message: string;
20
+ /** Placeholder text */
21
+ placeholder?: string;
22
+ /** Default value */
23
+ defaultValue?: string;
24
+ /** Validation function */
25
+ validate?: Validator;
26
+ }
27
+ /**
28
+ * Options for password prompts.
29
+ */
30
+ interface PasswordPromptOptions {
31
+ /** Prompt message to display */
32
+ message: string;
33
+ /** Validation function */
34
+ validate?: Validator;
35
+ /** Mask character (default: •) */
36
+ mask?: string;
37
+ }
38
+ /**
39
+ * Options for select prompts.
40
+ */
41
+ interface SelectPromptOptions<T> {
42
+ /** Prompt message to display */
43
+ message: string;
44
+ /** Available options */
45
+ options: Array<{
46
+ value: T;
47
+ label: string;
48
+ hint?: string;
49
+ }>;
50
+ /** Initial selected index */
51
+ initialValue?: T;
52
+ }
53
+ /**
54
+ * Options for multi-select prompts.
55
+ */
56
+ interface MultiSelectPromptOptions<T> {
57
+ /** Prompt message to display */
58
+ message: string;
59
+ /** Available options */
60
+ options: Array<{
61
+ value: T;
62
+ label: string;
63
+ hint?: string;
64
+ }>;
65
+ /** Initially selected values */
66
+ initialValues?: T[];
67
+ /** Require at least one selection */
68
+ required?: boolean;
69
+ }
70
+ /**
71
+ * Options for confirm prompts.
72
+ */
73
+ interface ConfirmPromptOptions {
74
+ /** Prompt message to display */
75
+ message: string;
76
+ /** Initial value */
77
+ initialValue?: boolean;
78
+ }
79
+ /**
80
+ * Type alias for prompt results.
81
+ */
82
+ type PromptResult<T> = Promise<Result<T, CancelledError>>;
83
+ export { CancelledError, createCancelledError, TextPromptOptions, PasswordPromptOptions, SelectPromptOptions, MultiSelectPromptOptions, ConfirmPromptOptions, PromptResult };
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ // packages/cli/src/render/json.ts
3
+ function renderJson(data) {
4
+ const json = JSON.stringify(data, null, 2);
5
+ return json;
6
+ }
7
+ function renderText(text) {
8
+ return text;
9
+ }
10
+
11
+ export { renderJson, renderText };
@@ -0,0 +1,59 @@
1
+ import { GlyphPair, SemanticState, VisualTheme } from "./cli-s0kkx9m1";
2
+ /**
3
+ * Resolves a glyph pair to a single character based on terminal capability.
4
+ *
5
+ * Uses terminal detection to choose between unicode and fallback characters.
6
+ * Can be overridden with the `forceUnicode` parameter.
7
+ *
8
+ * @param glyph - The glyph pair to resolve
9
+ * @param forceUnicode - Override terminal detection (true = unicode, false = fallback)
10
+ * @returns The appropriate character for the terminal
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const bullet: GlyphPair = { unicode: "•", fallback: "*" };
15
+ *
16
+ * // Auto-detect terminal capability
17
+ * resolveGlyph(bullet); // "•" or "*" based on terminal
18
+ *
19
+ * // Force unicode
20
+ * resolveGlyph(bullet, true); // "•"
21
+ *
22
+ * // Force fallback
23
+ * resolveGlyph(bullet, false); // "*"
24
+ * ```
25
+ */
26
+ declare function resolveGlyph(glyph: GlyphPair, forceUnicode?: boolean): string;
27
+ /**
28
+ * Resolves a semantic state to its visual marker character.
29
+ *
30
+ * Looks up the marker specification in the theme and returns the
31
+ * appropriate character. Supports both indicator-type markers (from
32
+ * the INDICATORS registry) and custom glyph pairs.
33
+ *
34
+ * @param theme - The visual theme containing marker definitions
35
+ * @param state - The semantic state to resolve
36
+ * @param forceUnicode - Override terminal detection
37
+ * @returns The marker character for the given state
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { defaultTheme, resolveStateMarker } from "@outfitter/cli/theme";
42
+ *
43
+ * // Resolve success marker (indicator-type)
44
+ * resolveStateMarker(defaultTheme, "success", true); // "✔"
45
+ * resolveStateMarker(defaultTheme, "success", false); // "[ok]"
46
+ *
47
+ * // Resolve with custom theme marker
48
+ * const theme = createVisualTheme({
49
+ * overrides: {
50
+ * markers: {
51
+ * current: { type: "custom", glyph: { unicode: "★", fallback: "*" } }
52
+ * }
53
+ * }
54
+ * });
55
+ * resolveStateMarker(theme, "current", true); // "★"
56
+ * ```
57
+ */
58
+ declare function resolveStateMarker(theme: VisualTheme, state: SemanticState, forceUnicode?: boolean): string;
59
+ export { resolveGlyph, resolveStateMarker };
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Regular expression pattern to match ANSI escape codes.
3
+ */
4
+ declare const ANSI_REGEX: RegExp;
5
+ /**
6
+ * Removes ANSI escape codes from text.
7
+ *
8
+ * Useful for calculating visible string length or logging to files
9
+ * where ANSI codes would appear as garbage.
10
+ *
11
+ * @param text - Text that may contain ANSI escape codes
12
+ * @returns Text with all ANSI escape codes removed
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const colored = "\x1b[32mGreen\x1b[0m text";
17
+ * console.log(stripAnsi(colored)); // "Green text"
18
+ * ```
19
+ */
20
+ declare function stripAnsi(text: string): string;
21
+ /**
22
+ * Calculates the visible width of text, ignoring ANSI escape codes.
23
+ *
24
+ * Uses `Bun.stringWidth()` internally, which correctly handles:
25
+ * - ANSI escape codes (ignored)
26
+ * - Wide characters (CJK, emoji) counting as 2 columns
27
+ * - Zero-width characters
28
+ *
29
+ * @param text - Text to measure (may contain ANSI codes)
30
+ * @returns Visible width in terminal columns
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * getStringWidth("Hello"); // 5
35
+ * getStringWidth("\x1b[31mHello\x1b[0m"); // 5 (ANSI ignored)
36
+ * getStringWidth("Hello"); // 5
37
+ * ```
38
+ */
39
+ declare function getStringWidth(text: string): number;
40
+ /**
41
+ * Wraps text at a specified width, preserving ANSI escape codes.
42
+ *
43
+ * Performs word-wrapping at the specified column width while:
44
+ * - Preserving ANSI escape codes across line breaks
45
+ * - Respecting word boundaries (no mid-word breaks)
46
+ * - Trimming trailing whitespace from lines
47
+ *
48
+ * Uses Bun's native `Bun.wrapAnsi()` for high performance.
49
+ *
50
+ * @param text - Text to wrap (may contain ANSI codes)
51
+ * @param width - Maximum visible width per line
52
+ * @returns Wrapped text with newlines
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const long = "This is a long sentence that should be wrapped";
57
+ * console.log(wrapText(long, 20));
58
+ * // This is a long
59
+ * // sentence that
60
+ * // should be wrapped
61
+ *
62
+ * // ANSI codes are preserved across line breaks
63
+ * const colored = "\x1b[32mGreen text that wraps\x1b[0m";
64
+ * console.log(wrapText(colored, 10));
65
+ * ```
66
+ */
67
+ declare function wrapText(text: string, width: number): string;
68
+ /**
69
+ * Truncates text with ellipsis, respecting ANSI escape codes.
70
+ *
71
+ * Preserves ANSI escape sequences while truncating to visible width.
72
+ * Adds "..." when text exceeds maxWidth. The ellipsis is included
73
+ * in the maxWidth calculation.
74
+ *
75
+ * @param text - Text to truncate (may contain ANSI codes)
76
+ * @param maxWidth - Maximum visible width including ellipsis
77
+ * @returns Truncated text with ellipsis if needed
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * truncateText("Hello World", 8); // "Hello..."
82
+ * truncateText("Short", 10); // "Short" (no change)
83
+ *
84
+ * // ANSI codes are preserved
85
+ * truncateText("\x1b[32mGreen text\x1b[0m", 8);
86
+ * // "\x1b[32mGreen\x1b[0m..."
87
+ * ```
88
+ */
89
+ declare function truncateText(text: string, maxWidth: number): string;
90
+ /**
91
+ * Pads text to a specified width with trailing spaces, handling ANSI codes.
92
+ *
93
+ * Uses {@link getStringWidth} to calculate visible width, ignoring ANSI
94
+ * escape codes. If text is already at or exceeds the target width,
95
+ * returns it unchanged.
96
+ *
97
+ * @param text - Text to pad (may contain ANSI codes)
98
+ * @param width - Target visible width
99
+ * @returns Text padded with trailing spaces to reach target width
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * padText("Hi", 10); // "Hi "
104
+ * padText("\x1b[32mHi\x1b[0m", 10); // "\x1b[32mHi\x1b[0m "
105
+ * padText("Already long enough", 5); // "Already long enough"
106
+ * ```
107
+ */
108
+ declare function padText(text: string, width: number): string;
109
+ /**
110
+ * Pluralizes a word based on count.
111
+ *
112
+ * Returns a string with the count and the appropriate singular or plural
113
+ * form of the word. By default, adds 's' for plural. Custom plural forms
114
+ * can be provided for irregular words.
115
+ *
116
+ * @param count - The number of items
117
+ * @param singular - The singular form of the word
118
+ * @param plural - Optional custom plural form (defaults to singular + 's')
119
+ * @returns Formatted string with count and pluralized word
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * pluralize(1, "item"); // "1 item"
124
+ * pluralize(5, "item"); // "5 items"
125
+ * pluralize(0, "child", "children"); // "0 children"
126
+ * ```
127
+ */
128
+ declare function pluralize(count: number, singular: string, plural?: string): string;
129
+ /**
130
+ * Converts text to URL-safe slug.
131
+ *
132
+ * Transforms text into a lowercase, hyphen-separated string suitable
133
+ * for URLs. Replaces ampersands with 'and', removes special characters,
134
+ * and collapses multiple hyphens.
135
+ *
136
+ * @param text - Text to convert to slug
137
+ * @returns URL-safe slug
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * slugify("Hello World!"); // "hello-world"
142
+ * slugify("This & That"); // "this-and-that"
143
+ * slugify(" Multiple Spaces "); // "multiple-spaces"
144
+ * ```
145
+ */
146
+ declare function slugify(text: string): string;
147
+ export { ANSI_REGEX, stripAnsi, getStringWidth, wrapText, truncateText, padText, pluralize, slugify };
@@ -0,0 +1,23 @@
1
+ import { ConfirmPromptOptions, PromptResult } from "./cli-3f12z5kf";
2
+ /**
3
+ * Prompts for yes/no confirmation with Result wrapping.
4
+ *
5
+ * @param options - Confirm prompt options
6
+ * @returns Ok with boolean or Err with CancelledError
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { promptConfirm } from "@outfitter/cli/prompt";
11
+ *
12
+ * const result = await promptConfirm({
13
+ * message: "Are you sure you want to continue?",
14
+ * initialValue: false,
15
+ * });
16
+ *
17
+ * if (result.isOk() && result.value) {
18
+ * console.log("Continuing...");
19
+ * }
20
+ * ```
21
+ */
22
+ declare function promptConfirm(options: ConfirmPromptOptions): PromptResult<boolean>;
23
+ export { promptConfirm };
@@ -0,0 +1,20 @@
1
+ // @bun
2
+ import {
3
+ createCancelledError
4
+ } from "./cli-8bwaw3pz.js";
5
+
6
+ // packages/cli/src/prompt/group.ts
7
+ import { Result as R } from "better-result";
8
+ async function promptGroup(steps) {
9
+ const result = {};
10
+ for (const [key, step] of Object.entries(steps)) {
11
+ const stepResult = await step();
12
+ if (stepResult.isErr()) {
13
+ return R.err(createCancelledError(stepResult.error.message));
14
+ }
15
+ result[key] = stepResult.value;
16
+ }
17
+ return R.ok(result);
18
+ }
19
+
20
+ export { promptGroup };
@@ -0,0 +1,146 @@
1
+ // @bun
2
+ import {
3
+ init_box,
4
+ normalizeBorders,
5
+ normalizePadding
6
+ } from "./cli-vp88gxev.js";
7
+
8
+ // packages/cli/src/render/layout.ts
9
+ init_box();
10
+ function getTerminalWidth() {
11
+ return process.stdout.columns ?? 80;
12
+ }
13
+ function getBoxOverhead(options) {
14
+ const pad = normalizePadding(options.padding, 1);
15
+ const borders = normalizeBorders(options.borders);
16
+ return {
17
+ horizontal: (borders.left ? 1 : 0) + (borders.right ? 1 : 0) + pad.left + pad.right,
18
+ vertical: (borders.top ? 1 : 0) + (borders.bottom ? 1 : 0) + pad.top + pad.bottom
19
+ };
20
+ }
21
+ function getContentWidth(options) {
22
+ const { horizontal } = getBoxOverhead(options);
23
+ if (options.width) {
24
+ const content = options.width - horizontal;
25
+ return Math.max(0, content);
26
+ }
27
+ return Math.max(0, getTerminalWidth() - horizontal);
28
+ }
29
+ function resolveWidth(mode, ctx) {
30
+ if (typeof mode === "number") {
31
+ return mode;
32
+ }
33
+ if (mode === "text") {
34
+ return 0;
35
+ }
36
+ if (mode === "full") {
37
+ return getTerminalWidth();
38
+ }
39
+ if (mode === "container") {
40
+ if (!ctx) {
41
+ throw new Error("container width mode requires LayoutContext");
42
+ }
43
+ return ctx.width;
44
+ }
45
+ const percent = Number.parseInt(mode.slice(0, -1), 10);
46
+ const baseWidth = ctx?.width ?? getTerminalWidth();
47
+ return Math.floor(baseWidth * (percent / 100));
48
+ }
49
+ function createLayoutContext(options, parent) {
50
+ const effectiveOptions = { ...options };
51
+ if (effectiveOptions.width === undefined && parent) {
52
+ effectiveOptions.width = parent.width;
53
+ }
54
+ const width = getContentWidth(effectiveOptions);
55
+ return {
56
+ width,
57
+ ...parent && { parent }
58
+ };
59
+ }
60
+ function getWidth(text) {
61
+ return Bun.stringWidth(text);
62
+ }
63
+ function splitLines(block) {
64
+ return block.split(`
65
+ `);
66
+ }
67
+ function padToWidth(text, width) {
68
+ const currentWidth = getWidth(text);
69
+ if (currentWidth >= width)
70
+ return text;
71
+ return text + " ".repeat(width - currentWidth);
72
+ }
73
+ function createFilledArray(length, value) {
74
+ const result = [];
75
+ for (let i = 0;i < length; i++) {
76
+ result.push(value);
77
+ }
78
+ return result;
79
+ }
80
+ function joinHorizontal(blocks, options) {
81
+ if (blocks.length === 0)
82
+ return "";
83
+ const first = blocks[0];
84
+ if (first === undefined)
85
+ return "";
86
+ if (blocks.length === 1)
87
+ return first;
88
+ const gap = options?.gap ?? 0;
89
+ const align = options?.align ?? "top";
90
+ const gapString = " ".repeat(gap);
91
+ const blockLines = blocks.map(splitLines);
92
+ const maxHeight = Math.max(...blockLines.map((lines) => lines.length));
93
+ const blockWidths = blockLines.map((lines) => Math.max(...lines.map(getWidth)));
94
+ const paddedBlocks = blockLines.map((lines, blockIndex) => {
95
+ const width = blockWidths[blockIndex] ?? 0;
96
+ const height = lines.length;
97
+ const padding = maxHeight - height;
98
+ let topPadding;
99
+ switch (align) {
100
+ case "top":
101
+ topPadding = 0;
102
+ break;
103
+ case "center":
104
+ topPadding = Math.floor(padding / 2);
105
+ break;
106
+ case "bottom":
107
+ topPadding = padding;
108
+ break;
109
+ default: {
110
+ const _exhaustive = align;
111
+ topPadding = _exhaustive;
112
+ }
113
+ }
114
+ const bottomPadding = padding - topPadding;
115
+ const emptyLine = " ".repeat(width);
116
+ const paddedLines = [
117
+ ...createFilledArray(topPadding, emptyLine),
118
+ ...lines.map((line) => padToWidth(line, width)),
119
+ ...createFilledArray(bottomPadding, emptyLine)
120
+ ];
121
+ return paddedLines;
122
+ });
123
+ const resultLines = [];
124
+ for (let i = 0;i < maxHeight; i++) {
125
+ const lineSegments = paddedBlocks.map((block) => block[i] ?? "");
126
+ resultLines.push(lineSegments.join(gapString));
127
+ }
128
+ return resultLines.join(`
129
+ `);
130
+ }
131
+ function joinVertical(blocks, options) {
132
+ if (blocks.length === 0)
133
+ return "";
134
+ const first = blocks[0];
135
+ if (first === undefined)
136
+ return "";
137
+ if (blocks.length === 1)
138
+ return first;
139
+ const gap = options?.gap ?? 0;
140
+ const gapLines = gap > 0 ? `
141
+ `.repeat(gap) : "";
142
+ return blocks.join(`
143
+ ${gapLines}`);
144
+ }
145
+
146
+ export { getTerminalWidth, getBoxOverhead, getContentWidth, resolveWidth, createLayoutContext, joinHorizontal, joinVertical };
@@ -0,0 +1,51 @@
1
+ import { WidthMode } from "./cli-2g8bx1aq";
2
+ /**
3
+ * Separator style for headings.
4
+ */
5
+ type SeparatorStyle = "=" | "-" | "─" | "━" | "═";
6
+ /**
7
+ * Width mode for headings.
8
+ *
9
+ * Note: Headings only support "text", "full", and numeric widths.
10
+ * Use the shared WidthMode type for full container-relative support.
11
+ *
12
+ * @see WidthMode for the complete type definition
13
+ */
14
+ type HeadingWidthMode = Extract<WidthMode, "text" | "full" | number>;
15
+ /**
16
+ * Case transformation for heading text.
17
+ */
18
+ type CaseMode = "upper" | "lower" | "title" | "none";
19
+ /**
20
+ * Options for rendering a heading.
21
+ */
22
+ interface HeadingOptions {
23
+ /** Separator character/style (default: "=") */
24
+ separator?: SeparatorStyle;
25
+ /** Width mode (default: "text") */
26
+ width?: HeadingWidthMode;
27
+ /** Case transformation (default: "upper") */
28
+ case?: CaseMode;
29
+ }
30
+ /**
31
+ * Renders a section heading with a separator line below.
32
+ *
33
+ * @param text - The heading text
34
+ * @param options - Rendering options
35
+ * @returns Formatted heading string
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { renderHeading } from "@outfitter/cli/render";
40
+ *
41
+ * console.log(renderHeading("Theme Colors"));
42
+ * // THEME COLORS
43
+ * // ============
44
+ *
45
+ * console.log(renderHeading("Status", { separator: "─", case: "none" }));
46
+ * // Status
47
+ * // ──────
48
+ * ```
49
+ */
50
+ declare function renderHeading(text: string, options?: HeadingOptions): string;
51
+ export { SeparatorStyle, HeadingWidthMode, CaseMode, HeadingOptions, renderHeading };
@@ -0,0 +1 @@
1
+ // @bun