padrone 1.4.0 → 1.5.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 (82) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +105 -284
  3. package/dist/{args-CVDbyyzG.mjs → args-D5PNDyNu.mjs} +41 -18
  4. package/dist/args-D5PNDyNu.mjs.map +1 -0
  5. package/dist/chunk-CjcI7cDX.mjs +15 -0
  6. package/dist/codegen/index.d.mts +28 -3
  7. package/dist/codegen/index.d.mts.map +1 -1
  8. package/dist/codegen/index.mjs +169 -19
  9. package/dist/codegen/index.mjs.map +1 -1
  10. package/dist/command-utils-B1D-HqCd.mjs +1117 -0
  11. package/dist/command-utils-B1D-HqCd.mjs.map +1 -0
  12. package/dist/completion.d.mts +1 -1
  13. package/dist/completion.d.mts.map +1 -1
  14. package/dist/completion.mjs +77 -29
  15. package/dist/completion.mjs.map +1 -1
  16. package/dist/docs/index.d.mts +22 -2
  17. package/dist/docs/index.d.mts.map +1 -1
  18. package/dist/docs/index.mjs +94 -7
  19. package/dist/docs/index.mjs.map +1 -1
  20. package/dist/errors-BiVrBgi6.mjs +114 -0
  21. package/dist/errors-BiVrBgi6.mjs.map +1 -0
  22. package/dist/{formatter-ClUK5hcQ.d.mts → formatter-DtHzbP22.d.mts} +34 -5
  23. package/dist/formatter-DtHzbP22.d.mts.map +1 -0
  24. package/dist/help-bbmu9-qd.mjs +735 -0
  25. package/dist/help-bbmu9-qd.mjs.map +1 -0
  26. package/dist/index.d.mts +32 -3
  27. package/dist/index.d.mts.map +1 -1
  28. package/dist/index.mjs +493 -265
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/mcp-mLWIdUIu.mjs +379 -0
  31. package/dist/mcp-mLWIdUIu.mjs.map +1 -0
  32. package/dist/serve-B0u43DK7.mjs +404 -0
  33. package/dist/serve-B0u43DK7.mjs.map +1 -0
  34. package/dist/stream-BcC146Ud.mjs +56 -0
  35. package/dist/stream-BcC146Ud.mjs.map +1 -0
  36. package/dist/test.d.mts +1 -1
  37. package/dist/test.mjs +4 -15
  38. package/dist/test.mjs.map +1 -1
  39. package/dist/{types-DjIdJN5G.d.mts → types-Ch8Mk6Qb.d.mts} +310 -62
  40. package/dist/types-Ch8Mk6Qb.d.mts.map +1 -0
  41. package/dist/{update-check-EbNDkzyV.mjs → update-check-CFX1FV3v.mjs} +2 -2
  42. package/dist/{update-check-EbNDkzyV.mjs.map → update-check-CFX1FV3v.mjs.map} +1 -1
  43. package/dist/zod.d.mts +32 -0
  44. package/dist/zod.d.mts.map +1 -0
  45. package/dist/zod.mjs +50 -0
  46. package/dist/zod.mjs.map +1 -0
  47. package/package.json +10 -2
  48. package/src/args.ts +68 -40
  49. package/src/cli/docs.ts +1 -7
  50. package/src/cli/doctor.ts +195 -10
  51. package/src/cli/index.ts +1 -1
  52. package/src/cli/init.ts +2 -3
  53. package/src/cli/link.ts +2 -2
  54. package/src/codegen/discovery.ts +80 -28
  55. package/src/codegen/index.ts +2 -1
  56. package/src/codegen/parsers/bash.ts +179 -0
  57. package/src/codegen/schema-to-code.ts +2 -1
  58. package/src/colorizer.ts +126 -13
  59. package/src/command-utils.ts +380 -30
  60. package/src/completion.ts +120 -47
  61. package/src/create.ts +480 -128
  62. package/src/docs/index.ts +122 -8
  63. package/src/formatter.ts +171 -125
  64. package/src/help.ts +45 -12
  65. package/src/index.ts +29 -1
  66. package/src/interactive.ts +45 -4
  67. package/src/mcp.ts +390 -0
  68. package/src/repl-loop.ts +16 -3
  69. package/src/runtime.ts +195 -2
  70. package/src/serve.ts +442 -0
  71. package/src/stream.ts +75 -0
  72. package/src/test.ts +7 -16
  73. package/src/type-utils.ts +28 -4
  74. package/src/types.ts +212 -30
  75. package/src/wrap.ts +23 -25
  76. package/src/zod.ts +50 -0
  77. package/dist/args-CVDbyyzG.mjs.map +0 -1
  78. package/dist/chunk-y_GBKt04.mjs +0 -5
  79. package/dist/formatter-ClUK5hcQ.d.mts.map +0 -1
  80. package/dist/help-CcBe91bV.mjs +0 -1254
  81. package/dist/help-CcBe91bV.mjs.map +0 -1
  82. package/dist/types-DjIdJN5G.d.mts.map +0 -1
package/src/colorizer.ts CHANGED
@@ -1,19 +1,56 @@
1
- // ANSI color codes
2
- const colors = {
1
+ // ANSI color/style codes
2
+ const ansiCodes: Record<AnsiStyle, string> = {
3
3
  reset: '\x1b[0m',
4
4
  bold: '\x1b[1m',
5
5
  dim: '\x1b[2m',
6
6
  italic: '\x1b[3m',
7
7
  underline: '\x1b[4m',
8
8
  strikethrough: '\x1b[9m',
9
- cyan: '\x1b[36m',
9
+ red: '\x1b[31m',
10
10
  green: '\x1b[32m',
11
11
  yellow: '\x1b[33m',
12
12
  blue: '\x1b[34m',
13
13
  magenta: '\x1b[35m',
14
+ cyan: '\x1b[36m',
15
+ white: '\x1b[37m',
14
16
  gray: '\x1b[90m',
15
17
  };
16
18
 
19
+ /**
20
+ * Available ANSI styles that can be combined for each color role.
21
+ */
22
+ export type AnsiStyle =
23
+ | 'reset'
24
+ | 'bold'
25
+ | 'dim'
26
+ | 'italic'
27
+ | 'underline'
28
+ | 'strikethrough'
29
+ | 'red'
30
+ | 'green'
31
+ | 'yellow'
32
+ | 'blue'
33
+ | 'magenta'
34
+ | 'cyan'
35
+ | 'white'
36
+ | 'gray';
37
+
38
+ /**
39
+ * Maps each semantic color role to an array of ANSI styles.
40
+ * Partial configs are merged with the default theme.
41
+ */
42
+ export type ColorConfig = {
43
+ command?: AnsiStyle[];
44
+ arg?: AnsiStyle[];
45
+ type?: AnsiStyle[];
46
+ description?: AnsiStyle[];
47
+ label?: AnsiStyle[];
48
+ meta?: AnsiStyle[];
49
+ example?: AnsiStyle[];
50
+ exampleValue?: AnsiStyle[];
51
+ deprecated?: AnsiStyle[];
52
+ };
53
+
17
54
  export type Colorizer = {
18
55
  command: (text: string) => string;
19
56
  arg: (text: string) => string;
@@ -26,16 +63,92 @@ export type Colorizer = {
26
63
  deprecated: (text: string) => string;
27
64
  };
28
65
 
29
- export function createColorizer(): Colorizer {
66
+ // ============================================================================
67
+ // Predefined Themes
68
+ // ============================================================================
69
+
70
+ const defaultTheme: Required<ColorConfig> = {
71
+ command: ['cyan', 'bold'],
72
+ arg: ['green'],
73
+ type: ['yellow'],
74
+ description: ['dim'],
75
+ label: ['bold'],
76
+ meta: ['gray'],
77
+ example: ['underline'],
78
+ exampleValue: ['italic'],
79
+ deprecated: ['strikethrough', 'gray'],
80
+ };
81
+
82
+ const oceanTheme: Required<ColorConfig> = {
83
+ command: ['blue', 'bold'],
84
+ arg: ['cyan'],
85
+ type: ['green'],
86
+ description: ['dim'],
87
+ label: ['bold'],
88
+ meta: ['gray'],
89
+ example: ['underline', 'cyan'],
90
+ exampleValue: ['italic'],
91
+ deprecated: ['strikethrough', 'gray'],
92
+ };
93
+
94
+ const warmTheme: Required<ColorConfig> = {
95
+ command: ['yellow', 'bold'],
96
+ arg: ['red'],
97
+ type: ['magenta'],
98
+ description: ['dim'],
99
+ label: ['bold'],
100
+ meta: ['gray'],
101
+ example: ['underline', 'yellow'],
102
+ exampleValue: ['italic'],
103
+ deprecated: ['strikethrough', 'gray'],
104
+ };
105
+
106
+ const monochromeTheme: Required<ColorConfig> = {
107
+ command: ['bold'],
108
+ arg: ['underline'],
109
+ type: ['dim'],
110
+ description: ['dim'],
111
+ label: ['bold'],
112
+ meta: ['dim'],
113
+ example: ['underline'],
114
+ exampleValue: ['italic'],
115
+ deprecated: ['strikethrough', 'dim'],
116
+ };
117
+
118
+ /**
119
+ * Available predefined color themes.
120
+ */
121
+ export type ColorTheme = 'default' | 'ocean' | 'warm' | 'monochrome';
122
+
123
+ export const colorThemes: Record<ColorTheme, Required<ColorConfig>> = {
124
+ default: defaultTheme,
125
+ ocean: oceanTheme,
126
+ warm: warmTheme,
127
+ monochrome: monochromeTheme,
128
+ };
129
+
130
+ function makeStyleFn(styles: AnsiStyle[]): (text: string) => string {
131
+ const prefix = styles.map((s) => ansiCodes[s]).join('');
132
+ return (text: string) => `${prefix}${text}${ansiCodes.reset}`;
133
+ }
134
+
135
+ function resolveConfig(config?: ColorTheme | ColorConfig): Required<ColorConfig> {
136
+ if (!config) return defaultTheme;
137
+ if (typeof config === 'string') return colorThemes[config] ?? defaultTheme;
138
+ return { ...defaultTheme, ...config };
139
+ }
140
+
141
+ export function createColorizer(config?: ColorTheme | ColorConfig): Colorizer {
142
+ const resolved = resolveConfig(config);
30
143
  return {
31
- command: (text: string) => `${colors.cyan}${colors.bold}${text}${colors.reset}`,
32
- arg: (text: string) => `${colors.green}${text}${colors.reset}`,
33
- type: (text: string) => `${colors.yellow}${text}${colors.reset}`,
34
- description: (text: string) => `${colors.dim}${text}${colors.reset}`,
35
- label: (text: string) => `${colors.bold}${text}${colors.reset}`,
36
- meta: (text: string) => `${colors.gray}${text}${colors.reset}`,
37
- example: (text: string) => `${colors.underline}${text}${colors.reset}`,
38
- exampleValue: (text: string) => `${colors.italic}${text}${colors.reset}`,
39
- deprecated: (text: string) => `${colors.strikethrough}${colors.gray}${text}${colors.reset}`,
144
+ command: makeStyleFn(resolved.command),
145
+ arg: makeStyleFn(resolved.arg),
146
+ type: makeStyleFn(resolved.type),
147
+ description: makeStyleFn(resolved.description),
148
+ label: makeStyleFn(resolved.label),
149
+ meta: makeStyleFn(resolved.meta),
150
+ example: makeStyleFn(resolved.example),
151
+ exampleValue: makeStyleFn(resolved.exampleValue),
152
+ deprecated: makeStyleFn(resolved.deprecated),
40
153
  };
41
154
  }