@outfitter/cli 0.1.0-rc.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/README.md +21 -32
  2. package/dist/actions.d.ts +12 -1
  3. package/dist/actions.js +170 -3
  4. package/dist/borders/index.d.ts +3 -0
  5. package/dist/borders/index.js +13 -0
  6. package/dist/box/index.d.ts +4 -0
  7. package/dist/box/index.js +13 -0
  8. package/dist/cli.js +1 -1
  9. package/dist/colors/index.d.ts +3 -0
  10. package/dist/colors/index.js +18 -0
  11. package/dist/command.d.ts +40 -3
  12. package/dist/command.js +45 -3
  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 -8
  46. package/dist/index.js +9 -43
  47. package/dist/input.d.ts +163 -2
  48. package/dist/input.js +425 -11
  49. package/dist/list/index.d.ts +3 -0
  50. package/dist/list/index.js +9 -0
  51. package/dist/output.js +1 -1
  52. package/dist/pagination.d.ts +62 -2
  53. package/dist/pagination.js +84 -6
  54. package/dist/preset/full.d.ts +14 -0
  55. package/dist/preset/full.js +41 -0
  56. package/dist/preset/standard.d.ts +11 -0
  57. package/dist/preset/standard.js +30 -0
  58. package/dist/prompt/confirm.d.ts +4 -0
  59. package/dist/prompt/confirm.js +9 -0
  60. package/dist/prompt/group.d.ts +4 -0
  61. package/dist/prompt/group.js +9 -0
  62. package/dist/prompt/index.d.ts +7 -0
  63. package/dist/prompt/index.js +32 -0
  64. package/dist/prompt/select.d.ts +4 -0
  65. package/dist/prompt/select.js +11 -0
  66. package/dist/prompt/text.d.ts +4 -0
  67. package/dist/prompt/text.js +11 -0
  68. package/dist/prompt/types.d.ts +3 -0
  69. package/dist/prompt/types.js +8 -0
  70. package/dist/prompt/validators.d.ts +2 -0
  71. package/dist/prompt/validators.js +8 -0
  72. package/dist/render/borders.d.ts +2 -0
  73. package/dist/render/borders.js +15 -0
  74. package/dist/render/box.d.ts +3 -0
  75. package/dist/render/box.js +23 -0
  76. package/dist/render/colors.d.ts +1 -1
  77. package/dist/render/colors.js +6 -3
  78. package/dist/render/date.js +1 -1
  79. package/dist/render/format-relative.js +1 -1
  80. package/dist/render/format.js +1 -1
  81. package/dist/render/heading.d.ts +3 -0
  82. package/dist/render/heading.js +14 -0
  83. package/dist/render/index.d.ts +26 -7
  84. package/dist/render/index.js +160 -26
  85. package/dist/render/indicators.d.ts +2 -0
  86. package/dist/render/indicators.js +14 -0
  87. package/dist/render/json.js +1 -1
  88. package/dist/render/layout.d.ts +5 -0
  89. package/dist/render/layout.js +25 -0
  90. package/dist/render/list.d.ts +2 -2
  91. package/dist/render/list.js +2 -2
  92. package/dist/render/markdown.js +4 -4
  93. package/dist/render/progress.js +1 -1
  94. package/dist/render/separator.d.ts +3 -0
  95. package/dist/render/separator.js +14 -0
  96. package/dist/render/shapes.js +10 -9
  97. package/dist/render/spinner.d.ts +2 -0
  98. package/dist/render/spinner.js +12 -0
  99. package/dist/render/stack.d.ts +3 -0
  100. package/dist/render/stack.js +38 -0
  101. package/dist/render/table.d.ts +2 -1
  102. package/dist/render/table.js +6 -5
  103. package/dist/render/text.d.ts +1 -1
  104. package/dist/render/text.js +7 -4
  105. package/dist/render/tree.d.ts +2 -2
  106. package/dist/render/tree.js +5 -3
  107. package/dist/render/types.d.ts +2 -0
  108. package/dist/render/types.js +1 -0
  109. package/dist/shared/@outfitter/cli-0ggcy7fa.js +20 -0
  110. package/dist/shared/@outfitter/cli-0psys2vm.js +7 -0
  111. package/dist/shared/@outfitter/cli-1bghjef6.js +352 -0
  112. package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +45 -0
  113. package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +50 -0
  114. package/dist/shared/@outfitter/cli-34fqr7bp.js +37 -0
  115. package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +97 -0
  116. package/dist/shared/@outfitter/cli-3dxmmy4c.d.ts +20 -0
  117. package/dist/shared/@outfitter/cli-3f12z5kf.d.ts +83 -0
  118. package/dist/shared/@outfitter/cli-3t2zaenc.d.ts +59 -0
  119. package/dist/shared/@outfitter/{cli-dds0qqvm.d.ts → cli-4cb5g831.d.ts} +2 -0
  120. package/dist/shared/@outfitter/cli-4w2a1rfy.d.ts +23 -0
  121. package/dist/shared/@outfitter/cli-4x6pqnez.js +20 -0
  122. package/dist/shared/@outfitter/cli-671sxkhj.js +146 -0
  123. package/dist/shared/@outfitter/cli-6bztk73z.d.ts +51 -0
  124. package/dist/shared/@outfitter/cli-6fxffp8k.js +1 -0
  125. package/dist/shared/@outfitter/cli-6j9qynm8.js +118 -0
  126. package/dist/shared/@outfitter/cli-6m988kh0.d.ts +61 -0
  127. package/dist/shared/@outfitter/cli-74ba31gz.js +134 -0
  128. package/dist/shared/@outfitter/cli-7gnrb8cr.js +214 -0
  129. package/dist/shared/@outfitter/cli-7nm6edvh.d.ts +17 -0
  130. package/dist/shared/@outfitter/cli-85fg2vr5.js +123 -0
  131. package/dist/shared/@outfitter/cli-8a8xrzhy.js +20 -0
  132. package/dist/shared/@outfitter/cli-8bwaw3pz.js +7 -0
  133. package/dist/shared/@outfitter/cli-8rx4g3s5.d.ts +41 -0
  134. package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +223 -0
  135. package/dist/shared/@outfitter/cli-96b2p4td.d.ts +56 -0
  136. package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +190 -0
  137. package/dist/shared/@outfitter/cli-9mtjjykw.js +67 -0
  138. package/dist/shared/@outfitter/{cli-ag0w4pk0.js → cli-9nbyj2bt.js} +60 -21
  139. package/dist/shared/@outfitter/{cli-azzk8a1d.js → cli-afhjqmg3.js} +7 -3
  140. package/dist/shared/@outfitter/cli-an9j0h80.js +117 -0
  141. package/dist/shared/@outfitter/cli-ay411nbr.js +122 -0
  142. package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +132 -0
  143. package/dist/shared/@outfitter/cli-b5c2k0d7.js +39 -0
  144. package/dist/shared/@outfitter/cli-b5epywry.js +1 -0
  145. package/dist/shared/@outfitter/cli-bcmcaz1b.js +23 -0
  146. package/dist/shared/@outfitter/cli-bf3vma4q.js +61 -0
  147. package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +53 -0
  148. package/dist/shared/@outfitter/cli-cs45xd6q.js +59 -0
  149. package/dist/shared/@outfitter/cli-d7jpshq5.d.ts +128 -0
  150. package/dist/shared/@outfitter/{cli-jbj78ac5.js → cli-d9ad0rqj.js} +6 -1
  151. package/dist/shared/@outfitter/cli-daw296mv.js +61 -0
  152. package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +91 -0
  153. package/dist/shared/@outfitter/cli-e73v3qqy.d.ts +93 -0
  154. package/dist/shared/@outfitter/cli-en6zn6sj.js +1 -0
  155. package/dist/shared/@outfitter/cli-ep2cvtk8.js +48 -0
  156. package/dist/shared/@outfitter/cli-f75h8e94.js +7 -0
  157. package/dist/shared/@outfitter/cli-fakncnjp.d.ts +106 -0
  158. package/dist/shared/@outfitter/cli-feb5j90n.js +94 -0
  159. package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +66 -0
  160. package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +328 -0
  161. package/dist/shared/@outfitter/cli-j4n8gaf3.js +95 -0
  162. package/dist/shared/@outfitter/cli-jejfypgf.js +85 -0
  163. package/dist/shared/@outfitter/{cli-wqc652mx.js → cli-jhcdwvpn.js} +8 -8
  164. package/dist/shared/@outfitter/{cli-v9mjsvjh.js → cli-jjemfdta.js} +13 -46
  165. package/dist/shared/@outfitter/cli-kc84wmch.js +267 -0
  166. package/dist/shared/@outfitter/cli-ktqme80d.js +7 -0
  167. package/dist/shared/@outfitter/cli-mq0jp15z.js +1 -0
  168. package/dist/shared/@outfitter/cli-mymyavvj.d.ts +26 -0
  169. package/dist/shared/@outfitter/cli-n17gt1dz.js +19 -0
  170. package/dist/shared/@outfitter/cli-n9dbh0hp.js +51 -0
  171. package/dist/shared/@outfitter/cli-nvvc92c8.js +128 -0
  172. package/dist/shared/@outfitter/cli-p1m5dhrs.js +169 -0
  173. package/dist/shared/@outfitter/cli-p38sfxyk.js +25 -0
  174. package/dist/shared/@outfitter/cli-p3dqm1vd.js +22 -0
  175. package/dist/shared/@outfitter/cli-p9j1phge.js +20 -0
  176. package/dist/shared/@outfitter/cli-pkxmzavm.js +62 -0
  177. package/dist/shared/@outfitter/cli-q8r6jarq.d.ts +24 -0
  178. package/dist/shared/@outfitter/{cli-2y3kxew8.d.ts → cli-qj83y5wj.d.ts} +22 -9
  179. package/dist/shared/@outfitter/cli-qjfc3j11.d.ts +112 -0
  180. package/dist/shared/@outfitter/cli-qp4cbhqr.js +70 -0
  181. package/dist/shared/@outfitter/cli-s0kkx9m1.d.ts +164 -0
  182. package/dist/shared/@outfitter/cli-snxj55n6.js +43 -0
  183. package/dist/shared/@outfitter/cli-swwxvjvm.d.ts +24 -0
  184. package/dist/shared/@outfitter/cli-sx67mmfx.d.ts +98 -0
  185. package/dist/shared/@outfitter/cli-tarpsa8a.js +30 -0
  186. package/dist/shared/@outfitter/cli-thvzhjd1.js +126 -0
  187. package/dist/shared/@outfitter/cli-tqewy503.d.ts +36 -0
  188. package/dist/shared/@outfitter/cli-tvw1xrdj.js +20 -0
  189. package/dist/shared/@outfitter/cli-v1tzwxkt.js +32 -0
  190. package/dist/shared/@outfitter/cli-vd60dj65.js +1 -0
  191. package/dist/shared/@outfitter/cli-vp88gxev.js +279 -0
  192. package/dist/shared/@outfitter/cli-vstbkzky.d.ts +74 -0
  193. package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +54 -0
  194. package/dist/shared/@outfitter/cli-w5y3xepp.js +20 -0
  195. package/dist/shared/@outfitter/cli-x4cavvc0.js +1 -0
  196. package/dist/shared/@outfitter/cli-xep6v2c0.js +52 -0
  197. package/dist/shared/@outfitter/cli-xg5y5fhk.js +86 -0
  198. package/dist/shared/@outfitter/{cli-n51t773m.d.ts → cli-xsaheemc.d.ts} +44 -4
  199. package/dist/shared/@outfitter/cli-xvqtqjxk.js +82 -0
  200. package/dist/shared/@outfitter/cli-y25tt8nc.d.ts +48 -0
  201. package/dist/streaming/ansi.d.ts +2 -0
  202. package/dist/streaming/ansi.js +8 -0
  203. package/dist/streaming/index.d.ts +4 -0
  204. package/dist/streaming/index.js +17 -0
  205. package/dist/streaming/spinner.d.ts +3 -0
  206. package/dist/streaming/spinner.js +10 -0
  207. package/dist/streaming/writer.d.ts +2 -0
  208. package/dist/streaming/writer.js +9 -0
  209. package/dist/table/index.d.ts +4 -0
  210. package/dist/table/index.js +13 -0
  211. package/dist/terminal/detection.js +5 -2
  212. package/dist/terminal/index.js +6 -2
  213. package/dist/theme/context.d.ts +9 -0
  214. package/dist/theme/context.js +14 -0
  215. package/dist/theme/create.d.ts +8 -0
  216. package/dist/theme/create.js +12 -0
  217. package/dist/theme/index.d.ts +17 -0
  218. package/dist/theme/index.js +42 -0
  219. package/dist/theme/presets/bold.d.ts +8 -0
  220. package/dist/theme/presets/bold.js +12 -0
  221. package/dist/theme/presets/default.d.ts +8 -0
  222. package/dist/theme/presets/default.js +11 -0
  223. package/dist/theme/presets/index.d.ts +12 -0
  224. package/dist/theme/presets/index.js +24 -0
  225. package/dist/theme/presets/minimal.d.ts +8 -0
  226. package/dist/theme/presets/minimal.js +12 -0
  227. package/dist/theme/presets/rounded.d.ts +8 -0
  228. package/dist/theme/presets/rounded.js +12 -0
  229. package/dist/theme/resolve.d.ts +8 -0
  230. package/dist/theme/resolve.js +11 -0
  231. package/dist/theme/types.d.ts +7 -0
  232. package/dist/theme/types.js +1 -0
  233. package/dist/tree/index.d.ts +3 -0
  234. package/dist/tree/index.js +11 -0
  235. package/dist/types.js +1 -1
  236. package/package.json +168 -54
  237. package/dist/shared/@outfitter/cli-2vs2gxa8.js +0 -429
  238. package/dist/shared/@outfitter/cli-2yq94zst.d.ts +0 -39
  239. package/dist/shared/@outfitter/cli-6xc869x1.js +0 -26
  240. package/dist/shared/@outfitter/cli-7km1e58p.js +0 -85
  241. package/dist/shared/@outfitter/cli-8r0bnyyx.js +0 -43
  242. package/dist/shared/@outfitter/cli-afecwfrn.d.ts +0 -13
  243. package/dist/shared/@outfitter/cli-bt423m6y.js +0 -4
  244. package/dist/shared/@outfitter/cli-d4fegbad.d.ts +0 -66
  245. package/dist/shared/@outfitter/cli-e0ecw3x1.js +0 -64
  246. package/dist/shared/@outfitter/cli-fheaaa6b.js +0 -25
  247. package/dist/shared/@outfitter/cli-j361wp3g.d.ts +0 -41
  248. package/dist/shared/@outfitter/cli-p0m2fc51.js +0 -172
  249. package/dist/shared/@outfitter/cli-tyajr8qa.d.ts +0 -63
  250. package/dist/shared/@outfitter/cli-zs6jy1am.d.ts +0 -164
package/README.md CHANGED
@@ -11,7 +11,9 @@ bun add @outfitter/cli
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import { output, collectIds, loadCursor, saveCursor } from "@outfitter/cli";
14
+ import { output } from "@outfitter/cli/output";
15
+ import { collectIds } from "@outfitter/cli/input";
16
+ import { loadCursor, saveCursor } from "@outfitter/cli/pagination";
15
17
 
16
18
  // Output data with automatic mode detection
17
19
  output({ id: "123", name: "Example" });
@@ -37,7 +39,7 @@ Output data to the console with automatic mode selection.
37
39
  Defaults to human-friendly output for TTY, JSON for non-TTY. Override via `mode` option or `OUTFITTER_JSON`/`OUTFITTER_JSONL` environment variables.
38
40
 
39
41
  ```typescript
40
- import { output } from "@outfitter/cli";
42
+ import { output } from "@outfitter/cli/output";
41
43
 
42
44
  // Basic usage - mode auto-detected
43
45
  output(results);
@@ -73,7 +75,7 @@ output(errors, { stream: process.stderr });
73
75
  Exit the process with an error message and appropriate exit code.
74
76
 
75
77
  ```typescript
76
- import { exitWithError } from "@outfitter/cli";
78
+ import { exitWithError } from "@outfitter/cli/output";
77
79
 
78
80
  try {
79
81
  await riskyOperation();
@@ -89,7 +91,7 @@ try {
89
91
  Collect IDs from various input formats: space-separated, comma-separated, repeated flags, `@file`, and stdin.
90
92
 
91
93
  ```typescript
92
- import { collectIds } from "@outfitter/cli";
94
+ import { collectIds } from "@outfitter/cli/input";
93
95
 
94
96
  // All these produce the same result:
95
97
  // myapp show id1 id2 id3
@@ -116,7 +118,7 @@ const ids = await collectIds(args.ids, {
116
118
  Expand `@file` references to file contents. Returns input unchanged if not a file reference.
117
119
 
118
120
  ```typescript
119
- import { expandFileArg } from "@outfitter/cli";
121
+ import { expandFileArg } from "@outfitter/cli/input";
120
122
 
121
123
  // myapp create @template.md
122
124
  const content = await expandFileArg(args.content);
@@ -141,7 +143,7 @@ const content = await expandFileArg(args.content, {
141
143
  Parse and expand glob patterns using `Bun.Glob`.
142
144
 
143
145
  ```typescript
144
- import { parseGlob } from "@outfitter/cli";
146
+ import { parseGlob } from "@outfitter/cli/input";
145
147
 
146
148
  const files = await parseGlob("src/**/*.ts", {
147
149
  cwd: workspaceRoot,
@@ -165,7 +167,7 @@ const files = await parseGlob("src/**/*.ts", {
165
167
  Parse `key=value` pairs from CLI input.
166
168
 
167
169
  ```typescript
168
- import { parseKeyValue } from "@outfitter/cli";
170
+ import { parseKeyValue } from "@outfitter/cli/input";
169
171
 
170
172
  // --set key=value --set key2=value2
171
173
  // --set key=value,key2=value2
@@ -182,7 +184,7 @@ if (result.isOk()) {
182
184
  Parse numeric or date range inputs.
183
185
 
184
186
  ```typescript
185
- import { parseRange } from "@outfitter/cli";
187
+ import { parseRange } from "@outfitter/cli/input";
186
188
 
187
189
  // Numeric range
188
190
  const numResult = parseRange("1-10", "number");
@@ -202,7 +204,7 @@ const single = parseRange("5", "number");
202
204
  Parse filter expressions from CLI input.
203
205
 
204
206
  ```typescript
205
- import { parseFilter } from "@outfitter/cli";
207
+ import { parseFilter } from "@outfitter/cli/input";
206
208
 
207
209
  const result = parseFilter("status:active,priority:>=high,!archived:true");
208
210
 
@@ -232,7 +234,7 @@ if (result.isOk()) {
232
234
  Parse sort specification from CLI input.
233
235
 
234
236
  ```typescript
235
- import { parseSortSpec } from "@outfitter/cli";
237
+ import { parseSortSpec } from "@outfitter/cli/input";
236
238
 
237
239
  const result = parseSortSpec("modified:desc,title:asc");
238
240
 
@@ -249,7 +251,7 @@ if (result.isOk()) {
249
251
  Normalize an identifier with validation.
250
252
 
251
253
  ```typescript
252
- import { normalizeId } from "@outfitter/cli";
254
+ import { normalizeId } from "@outfitter/cli/input";
253
255
 
254
256
  const result = normalizeId(" MY-ID ", {
255
257
  trim: true,
@@ -279,7 +281,7 @@ if (result.isOk()) {
279
281
  Prompt for confirmation before destructive operations. Respects `--yes` flag for non-interactive mode.
280
282
 
281
283
  ```typescript
282
- import { confirmDestructive } from "@outfitter/cli";
284
+ import { confirmDestructive } from "@outfitter/cli/input";
283
285
 
284
286
  const result = await confirmDestructive({
285
287
  message: "Delete 5 notes?",
@@ -311,7 +313,7 @@ $XDG_STATE_HOME/{toolName}/cursors/{command}[/{context}]/cursor.json
311
313
  Load persisted pagination state for a command.
312
314
 
313
315
  ```typescript
314
- import { loadCursor } from "@outfitter/cli";
316
+ import { loadCursor } from "@outfitter/cli/pagination";
315
317
 
316
318
  const state = loadCursor({
317
319
  command: "list",
@@ -331,7 +333,7 @@ if (state) {
331
333
  Save pagination state for a command.
332
334
 
333
335
  ```typescript
334
- import { saveCursor } from "@outfitter/cli";
336
+ import { saveCursor } from "@outfitter/cli/pagination";
335
337
 
336
338
  const results = await listNotes({ limit: 20 });
337
339
 
@@ -348,7 +350,7 @@ if (results.hasMore) {
348
350
  Clear persisted pagination state for a command.
349
351
 
350
352
  ```typescript
351
- import { clearCursor } from "@outfitter/cli";
353
+ import { clearCursor } from "@outfitter/cli/pagination";
352
354
 
353
355
  // User passed --reset flag
354
356
  if (flags.reset) {
@@ -412,23 +414,10 @@ exitWithError(error); // Exits with code 2
412
414
  All types are exported for TypeScript consumers:
413
415
 
414
416
  ```typescript
415
- import type {
416
- // Core types
417
- CLIConfig,
418
- CommandConfig,
419
- CommandAction,
420
- CommandFlags,
421
- // Output types
422
- OutputMode,
423
- OutputOptions,
424
- // Input types
425
- CollectIdsOptions,
426
- ExpandFileOptions,
427
- ParseGlobOptions,
428
- // Pagination types
429
- PaginationState,
430
- CursorOptions,
431
- } from "@outfitter/cli";
417
+ import type { CLIConfig, CommandConfig, CommandAction, CommandFlags } from "@outfitter/cli/command";
418
+ import type { OutputMode, OutputOptions } from "@outfitter/cli/output";
419
+ import type { CollectIdsOptions, ExpandFileOptions, ParseGlobOptions } from "@outfitter/cli/input";
420
+ import type { PaginationState, CursorOptions } from "@outfitter/cli/pagination";
432
421
  ```
433
422
 
434
423
  ## License
package/dist/actions.d.ts CHANGED
@@ -1,2 +1,13 @@
1
- import { BuildCliCommandsOptions, buildCliCommands } from "./shared/@outfitter/cli-afecwfrn";
1
+ import { ActionRegistry, ActionSurface, AnyActionSpec, HandlerContext } from "@outfitter/contracts";
2
+ import { Command } from "commander";
3
+ interface BuildCliCommandsOptions {
4
+ readonly createContext?: (input: {
5
+ action: AnyActionSpec;
6
+ args: readonly string[];
7
+ flags: Record<string, unknown>;
8
+ }) => HandlerContext;
9
+ readonly includeSurfaces?: readonly ActionSurface[];
10
+ }
11
+ type ActionSource = ActionRegistry | readonly AnyActionSpec[];
12
+ declare function buildCliCommands(source: ActionSource, options?: BuildCliCommandsOptions): Command[];
2
13
  export { buildCliCommands, BuildCliCommandsOptions };
package/dist/actions.js CHANGED
@@ -1,8 +1,175 @@
1
1
  // @bun
2
+ import"./shared/@outfitter/cli-v1tzwxkt.js";
3
+
4
+ // packages/cli/src/actions.ts
2
5
  import {
3
- buildCliCommands
4
- } from "./shared/@outfitter/cli-p0m2fc51.js";
5
- import"./shared/@outfitter/cli-bt423m6y.js";
6
+ createContext as createHandlerContext,
7
+ DEFAULT_REGISTRY_SURFACES,
8
+ validateInput
9
+ } from "@outfitter/contracts";
10
+ import { Command } from "commander";
11
+ var ARGUMENT_PREFIXES = ["<", "["];
12
+ function isArgumentToken(token) {
13
+ if (!token) {
14
+ return false;
15
+ }
16
+ return ARGUMENT_PREFIXES.some((prefix) => token.startsWith(prefix));
17
+ }
18
+ function splitCommandSpec(spec) {
19
+ const parts = spec.trim().split(/\s+/).filter(Boolean);
20
+ if (parts.length === 0) {
21
+ return { name: undefined, args: [] };
22
+ }
23
+ return { name: parts[0], args: parts.slice(1) };
24
+ }
25
+ function applyArguments(command, args) {
26
+ for (const arg of args) {
27
+ command.argument(arg);
28
+ }
29
+ }
30
+ function applyCliOptions(command, action) {
31
+ const options = action.cli?.options ?? [];
32
+ for (const option of options) {
33
+ if (option.required) {
34
+ command.requiredOption(option.flags, option.description, option.defaultValue);
35
+ } else {
36
+ command.option(option.flags, option.description, option.defaultValue);
37
+ }
38
+ }
39
+ }
40
+ function resolveDescription(action) {
41
+ return action.cli?.description ?? action.description ?? action.id;
42
+ }
43
+ function resolveAliases(action) {
44
+ return action.cli?.aliases ?? [];
45
+ }
46
+ function resolveCommandSpec(action) {
47
+ return action.cli?.command ?? action.id;
48
+ }
49
+ function resolveFlags(command) {
50
+ return command.optsWithGlobals?.() ?? command.opts();
51
+ }
52
+ function resolveInput(action, context) {
53
+ if (action.cli?.mapInput) {
54
+ return action.cli.mapInput(context);
55
+ }
56
+ const hasFlags = Object.keys(context.flags).length > 0;
57
+ if (!hasFlags && context.args.length === 0) {
58
+ return {};
59
+ }
60
+ return {
61
+ ...context.flags,
62
+ ...context.args.length > 0 ? { args: context.args } : {}
63
+ };
64
+ }
65
+ async function runAction(action, command, createContext) {
66
+ const flags = resolveFlags(command);
67
+ const args = command.args;
68
+ const inputContext = { args, flags };
69
+ const input = resolveInput(action, inputContext);
70
+ const validation = validateInput(action.input, input);
71
+ if (validation.isErr()) {
72
+ throw validation.error;
73
+ }
74
+ const ctx = createContext({ action, args, flags });
75
+ const result = await action.handler(validation.value, ctx);
76
+ if (result.isErr()) {
77
+ throw result.error;
78
+ }
79
+ }
80
+ function createCommand(action, createContext, spec) {
81
+ const commandSpec = spec ?? resolveCommandSpec(action);
82
+ const { name, args } = splitCommandSpec(commandSpec);
83
+ if (!name) {
84
+ throw new Error(`Missing CLI command name for action ${action.id}`);
85
+ }
86
+ const command = new Command(name);
87
+ command.description(resolveDescription(action));
88
+ applyCliOptions(command, action);
89
+ applyArguments(command, args);
90
+ for (const alias of resolveAliases(action)) {
91
+ command.alias(alias);
92
+ }
93
+ command.action(async (...argsList) => {
94
+ const commandInstance = argsList.at(-1);
95
+ await runAction(action, commandInstance, createContext);
96
+ });
97
+ return command;
98
+ }
99
+ function buildCliCommands(source, options = {}) {
100
+ const actions = isActionRegistry(source) ? source.list() : source;
101
+ const includeSurfaces = options.includeSurfaces ?? [
102
+ "cli"
103
+ ];
104
+ const commands = [];
105
+ const createContext = options.createContext ?? ((_input) => createHandlerContext({
106
+ cwd: process.cwd(),
107
+ env: process.env
108
+ }));
109
+ const grouped = new Map;
110
+ const ungrouped = [];
111
+ for (const action of actions) {
112
+ const surfaces = action.surfaces ?? DEFAULT_REGISTRY_SURFACES;
113
+ if (!surfaces.some((surface) => includeSurfaces.includes(surface))) {
114
+ continue;
115
+ }
116
+ const group = action.cli?.group;
117
+ if (group) {
118
+ const groupActions = grouped.get(group) ?? [];
119
+ groupActions.push(action);
120
+ grouped.set(group, groupActions);
121
+ } else {
122
+ ungrouped.push(action);
123
+ }
124
+ }
125
+ for (const action of ungrouped) {
126
+ commands.push(createCommand(action, createContext));
127
+ }
128
+ for (const [groupName, groupActions] of grouped.entries()) {
129
+ const groupCommand = new Command(groupName);
130
+ let baseAction;
131
+ const subcommands = [];
132
+ for (const action of groupActions) {
133
+ const spec = action.cli?.command?.trim() ?? "";
134
+ const { name, args } = splitCommandSpec(spec);
135
+ if (!name || isArgumentToken(name)) {
136
+ if (baseAction) {
137
+ throw new Error(`Group '${groupName}' defines multiple base actions: '${baseAction.id}' and '${action.id}'.`);
138
+ }
139
+ baseAction = action;
140
+ groupCommand.description(resolveDescription(action));
141
+ applyCliOptions(groupCommand, action);
142
+ applyArguments(groupCommand, name ? [name, ...args] : args);
143
+ for (const alias of resolveAliases(action)) {
144
+ groupCommand.alias(alias);
145
+ }
146
+ groupCommand.action(async (...argsList) => {
147
+ const commandInstance = argsList.at(-1);
148
+ await runAction(action, commandInstance, createContext);
149
+ });
150
+ } else {
151
+ subcommands.push(action);
152
+ }
153
+ }
154
+ for (const action of subcommands) {
155
+ const spec = resolveCommandSpec(action);
156
+ const { name, args } = splitCommandSpec(spec);
157
+ if (!name) {
158
+ continue;
159
+ }
160
+ const subcommand = createCommand(action, createContext, [name, ...args].join(" "));
161
+ groupCommand.addCommand(subcommand);
162
+ }
163
+ if (!baseAction) {
164
+ groupCommand.description(groupName);
165
+ }
166
+ commands.push(groupCommand);
167
+ }
168
+ return commands;
169
+ }
170
+ function isActionRegistry(source) {
171
+ return "list" in source;
172
+ }
6
173
  export {
7
174
  buildCliCommands
8
175
  };
@@ -0,0 +1,3 @@
1
+ import "../shared/@outfitter/cli-w7w7ta31";
2
+ import { BORDERS, BorderCharacters, BorderStyle, LinePosition, drawHorizontalLine, getBorderCharacters } from "../shared/@outfitter/cli-fakncnjp";
3
+ export { getBorderCharacters, drawHorizontalLine, LinePosition, BorderStyle, BorderCharacters, BORDERS };
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ import"../shared/@outfitter/cli-ktqme80d.js";
3
+ import {
4
+ BORDERS,
5
+ drawHorizontalLine,
6
+ getBorderCharacters
7
+ } from "../shared/@outfitter/cli-85fg2vr5.js";
8
+ import"../shared/@outfitter/cli-v1tzwxkt.js";
9
+ export {
10
+ getBorderCharacters,
11
+ drawHorizontalLine,
12
+ BORDERS
13
+ };
@@ -0,0 +1,4 @@
1
+ import "../shared/@outfitter/cli-zfqz333z";
2
+ import { BoxAlign, BoxOptions, renderBox } from "../shared/@outfitter/cli-8xsmsbbd";
3
+ import "../shared/@outfitter/cli-fakncnjp";
4
+ export { renderBox, BoxOptions, BoxAlign };
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ import"../shared/@outfitter/cli-f75h8e94.js";
3
+ import {
4
+ renderBox
5
+ } from "../shared/@outfitter/cli-vp88gxev.js";
6
+ import"../shared/@outfitter/cli-jjemfdta.js";
7
+ import"../shared/@outfitter/cli-85fg2vr5.js";
8
+ import"../shared/@outfitter/cli-9nbyj2bt.js";
9
+ import"../shared/@outfitter/cli-d9ad0rqj.js";
10
+ import"../shared/@outfitter/cli-v1tzwxkt.js";
11
+ export {
12
+ renderBox
13
+ };
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createCLI
4
4
  } from "./shared/@outfitter/cli-efy6jfcj.js";
5
- import"./shared/@outfitter/cli-bt423m6y.js";
5
+ import"./shared/@outfitter/cli-v1tzwxkt.js";
6
6
  export {
7
7
  createCLI
8
8
  };
@@ -0,0 +1,3 @@
1
+ import "../shared/@outfitter/cli-qz47jk6d";
2
+ import { ANSI, ColorName, Theme, TokenOptions, Tokens, applyColor, createTheme, createTokens, resolveTokenColorEnabled } from "../shared/@outfitter/cli-xsaheemc";
3
+ export { resolveTokenColorEnabled, createTokens, createTheme, applyColor, Tokens, TokenOptions, Theme, ColorName, ANSI };
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ import"../shared/@outfitter/cli-0psys2vm.js";
3
+ import {
4
+ ANSI,
5
+ applyColor,
6
+ createTheme,
7
+ createTokens,
8
+ resolveTokenColorEnabled
9
+ } from "../shared/@outfitter/cli-9nbyj2bt.js";
10
+ import"../shared/@outfitter/cli-d9ad0rqj.js";
11
+ import"../shared/@outfitter/cli-v1tzwxkt.js";
12
+ export {
13
+ resolveTokenColorEnabled,
14
+ createTokens,
15
+ createTheme,
16
+ applyColor,
17
+ ANSI
18
+ };
package/dist/command.d.ts CHANGED
@@ -1,3 +1,40 @@
1
- import { command } from "./shared/@outfitter/cli-2yq94zst";
2
- import "./shared/@outfitter/cli-ttt7r0j7";
3
- export { command };
1
+ import { createCLI } from "./shared/@outfitter/cli-mhamvbty";
2
+ import { CommandBuilder } from "./shared/@outfitter/cli-ttt7r0j7";
3
+ /**
4
+ * Create a new command builder with the given name.
5
+ *
6
+ * The command builder provides a fluent API for defining CLI commands
7
+ * with typed flags, arguments, and actions.
8
+ *
9
+ * @param name - Command name and optional argument syntax (e.g., "list" or "get <id>")
10
+ * @returns A CommandBuilder instance for fluent configuration
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { command, output } from "@outfitter/cli";
15
+ *
16
+ * const list = command("list")
17
+ * .description("List all notes")
18
+ * .option("--limit <n>", "Max results", "20")
19
+ * .option("--json", "Output as JSON")
20
+ * .option("--next", "Continue from last position")
21
+ * .action(async ({ flags }) => {
22
+ * const results = await listNotes(flags);
23
+ * output(results);
24
+ * });
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Command with required argument
30
+ * const get = command("get <id>")
31
+ * .description("Get a note by ID")
32
+ * .action(async ({ args }) => {
33
+ * const [id] = args;
34
+ * const note = await getNote(id);
35
+ * output(note);
36
+ * });
37
+ * ```
38
+ */
39
+ declare function command(name: string): CommandBuilder;
40
+ export { createCLI, command };
package/dist/command.js CHANGED
@@ -1,8 +1,50 @@
1
1
  // @bun
2
2
  import {
3
- command
4
- } from "./shared/@outfitter/cli-8r0bnyyx.js";
5
- import"./shared/@outfitter/cli-bt423m6y.js";
3
+ createCLI
4
+ } from "./shared/@outfitter/cli-efy6jfcj.js";
5
+ import"./shared/@outfitter/cli-v1tzwxkt.js";
6
+
7
+ // packages/cli/src/command.ts
8
+ import { Command } from "commander";
9
+
10
+ class CommandBuilderImpl {
11
+ command;
12
+ constructor(name) {
13
+ this.command = new Command(name);
14
+ }
15
+ description(text) {
16
+ this.command.description(text);
17
+ return this;
18
+ }
19
+ option(flags, description, defaultValue) {
20
+ this.command.option(flags, description, defaultValue);
21
+ return this;
22
+ }
23
+ requiredOption(flags, description, defaultValue) {
24
+ this.command.requiredOption(flags, description, defaultValue);
25
+ return this;
26
+ }
27
+ alias(alias) {
28
+ this.command.alias(alias);
29
+ return this;
30
+ }
31
+ action(handler) {
32
+ this.command.action(async (...args) => {
33
+ const command = args.at(-1);
34
+ const flags = command.optsWithGlobals?.() ?? command.opts();
35
+ const positional = command.args;
36
+ await handler({ args: positional, flags, command });
37
+ });
38
+ return this;
39
+ }
40
+ build() {
41
+ return this.command;
42
+ }
43
+ }
44
+ function command(name) {
45
+ return new CommandBuilderImpl(name);
46
+ }
6
47
  export {
48
+ createCLI,
7
49
  command
8
50
  };
@@ -0,0 +1,78 @@
1
+ import { BORDER_STYLE_META, LIST_STYLE_META, PRIMITIVE_META, SPINNER_STYLE_META, THEME_METHOD_META, getBorderStyles, getListStyles, getPrimitiveIds, getSpinnerStyles, getThemeMethodsByCategory } from "../shared/@outfitter/cli-96b2p4td";
2
+ import "../shared/@outfitter/cli-e5ms1y0x";
3
+ import "../shared/@outfitter/cli-b0tzqgnf";
4
+ import "../shared/@outfitter/cli-fakncnjp";
5
+ import { SectionOptions, SubsectionOptions, codeBlock, demoContent, demoSection, demoSubsection, description } from "../shared/@outfitter/cli-d7jpshq5";
6
+ import "../shared/@outfitter/cli-6bztk73z";
7
+ import "../shared/@outfitter/cli-2g8bx1aq";
8
+ import { DEFAULT_EXAMPLES, getExample } from "../shared/@outfitter/cli-7nm6edvh";
9
+ import { DemoConfig, DemoRegistryEntry, DemoRenderer, ExampleTexts, PrimitiveId, PrimitiveMeta, ThemeMethodCategory, ThemeMethodMeta, VariantMeta, isPrimitiveId } from "../shared/@outfitter/cli-qjfc3j11";
10
+ import "../shared/@outfitter/cli-xsaheemc";
11
+ /**
12
+ * Renders a demo for a specific primitive.
13
+ *
14
+ * @param id - The primitive to demo
15
+ * @param config - Optional configuration for customization
16
+ * @returns Formatted demo output string
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Default examples
21
+ * console.log(renderDemo("colors"));
22
+ *
23
+ * // Custom examples
24
+ * console.log(renderDemo("colors", {
25
+ * examples: { success: "Build completed" }
26
+ * }));
27
+ *
28
+ * // No code examples
29
+ * console.log(renderDemo("table", { showCode: false }));
30
+ * ```
31
+ */
32
+ declare function renderDemo(id: PrimitiveId, config?: DemoConfig): string;
33
+ /**
34
+ * Renders demos for all primitives.
35
+ *
36
+ * @param config - Optional configuration applied to all demos
37
+ * @returns Combined output from all demos, separated by blank lines
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * console.log(renderAllDemos());
42
+ *
43
+ * // With custom config
44
+ * console.log(renderAllDemos({
45
+ * showCode: false,
46
+ * showDescriptions: true,
47
+ * }));
48
+ * ```
49
+ */
50
+ declare function renderAllDemos(config?: DemoConfig): string;
51
+ /**
52
+ * Gets metadata for a specific primitive.
53
+ *
54
+ * @param id - The primitive ID
55
+ * @returns Primitive metadata including name, description, and import example
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const meta = getPrimitive("colors");
60
+ * console.log(meta.name); // "Colors"
61
+ * console.log(meta.importExample); // 'import { createTheme } from "@outfitter/cli/render";'
62
+ * ```
63
+ */
64
+ declare function getPrimitive(id: PrimitiveId): PrimitiveMeta;
65
+ /**
66
+ * Gets all primitives with their metadata.
67
+ *
68
+ * @returns Array of all primitive metadata
69
+ */
70
+ declare function getAllPrimitives(): PrimitiveMeta[];
71
+ /**
72
+ * Gets a registry entry with both metadata and renderer.
73
+ *
74
+ * @param id - The primitive ID
75
+ * @returns Registry entry with meta and render function
76
+ */
77
+ declare function getDemoEntry(id: PrimitiveId): DemoRegistryEntry;
78
+ export { renderDemo, renderAllDemos, isPrimitiveId, getThemeMethodsByCategory, getSpinnerStyles, getPrimitiveIds, getPrimitive, getListStyles, getExample, getDemoEntry, getBorderStyles, getAllPrimitives, description, demoSubsection, demoSection, demoContent, codeBlock, VariantMeta, ThemeMethodMeta, ThemeMethodCategory, THEME_METHOD_META, SubsectionOptions, SectionOptions, SPINNER_STYLE_META, PrimitiveMeta, PrimitiveId, PRIMITIVE_META, LIST_STYLE_META, ExampleTexts, DemoRenderer, DemoRegistryEntry, DemoConfig, DEFAULT_EXAMPLES, BORDER_STYLE_META };