@kjanat/dreamcli 2.5.0 → 3.0.0-rc.10

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 (202) hide show
  1. package/CHANGELOG.md +344 -1
  2. package/README.md +9 -2
  3. package/dist/core/cli/dispatch.d.mts +6 -5
  4. package/dist/core/cli/dispatch.mjs +205 -1
  5. package/dist/core/cli/help-links.d.mts +0 -1
  6. package/dist/core/cli/help-links.mjs +41 -1
  7. package/dist/core/cli/index.d.mts +185 -19
  8. package/dist/core/cli/index.mjs +945 -1
  9. package/dist/core/cli/planner.d.mts +32 -6
  10. package/dist/core/cli/planner.mjs +300 -1
  11. package/dist/core/cli/plugin.d.mts +1 -1
  12. package/dist/core/cli/plugin.mjs +41 -1
  13. package/dist/core/cli/propagate.d.mts +1 -1
  14. package/dist/core/cli/propagate.mjs +57 -1
  15. package/dist/core/cli/root-help.d.mts +18 -3
  16. package/dist/core/cli/root-help.mjs +226 -6
  17. package/dist/core/cli/root-surface.d.mts +30 -4
  18. package/dist/core/cli/root-surface.mjs +28 -1
  19. package/dist/core/cli/runtime-preflight.d.mts +30 -3
  20. package/dist/core/cli/runtime-preflight.mjs +169 -1
  21. package/dist/core/completion/index.d.mts +32 -2
  22. package/dist/core/completion/index.mjs +90 -1
  23. package/dist/core/completion/shells/bash.d.mts +0 -1
  24. package/dist/core/completion/shells/bash.mjs +308 -3
  25. package/dist/core/completion/shells/fish.d.mts +0 -1
  26. package/dist/core/completion/shells/fish.mjs +162 -2
  27. package/dist/core/completion/shells/powershell.d.mts +0 -1
  28. package/dist/core/completion/shells/powershell.mjs +358 -2
  29. package/dist/core/completion/shells/shared.d.mts +23 -2
  30. package/dist/core/completion/shells/shared.mjs +176 -1
  31. package/dist/core/completion/shells/zsh.d.mts +0 -1
  32. package/dist/core/completion/shells/zsh.mjs +251 -2
  33. package/dist/core/config/index.d.mts +2 -3
  34. package/dist/core/config/index.mjs +246 -1
  35. package/dist/core/config/package-json.d.mts +27 -4
  36. package/dist/core/config/package-json.mjs +386 -3
  37. package/dist/core/errors/index.d.mts +3 -3
  38. package/dist/core/errors/index.mjs +87 -1
  39. package/dist/core/execution/index.d.mts +0 -1
  40. package/dist/core/execution/index.mjs +201 -1
  41. package/dist/core/help/ansi.d.mts +11 -5
  42. package/dist/core/help/ansi.mjs +121 -2
  43. package/dist/core/help/index.d.mts +65 -2
  44. package/dist/core/help/index.mjs +341 -7
  45. package/dist/core/help/theme.d.mts +68 -0
  46. package/dist/core/help/theme.mjs +46 -0
  47. package/dist/core/json-schema/index.d.mts +15 -2
  48. package/dist/core/json-schema/index.mjs +536 -12
  49. package/dist/core/json-schema/meta-descriptions.generated.d.mts +22 -5
  50. package/dist/core/json-schema/meta-descriptions.generated.mjs +102 -28
  51. package/dist/core/output/activity.d.mts +0 -1
  52. package/dist/core/output/activity.mjs +452 -1
  53. package/dist/core/output/bind.mjs +56 -1
  54. package/dist/core/output/contracts.d.mts +4 -5
  55. package/dist/core/output/contracts.mjs +57 -1
  56. package/dist/core/output/display-value.mjs +32 -1
  57. package/dist/core/output/index.d.mts +21 -1
  58. package/dist/core/output/index.mjs +442 -2
  59. package/dist/core/output/renderers.d.mts +0 -1
  60. package/dist/core/output/renderers.mjs +46 -1
  61. package/dist/core/output/writer.mjs +12 -1
  62. package/dist/core/parse/index.d.mts +54 -7
  63. package/dist/core/parse/index.mjs +727 -1
  64. package/dist/core/prompt/index.d.mts +12 -4
  65. package/dist/core/prompt/index.mjs +348 -6
  66. package/dist/core/resolve/args.d.mts +1 -1
  67. package/dist/core/resolve/args.mjs +105 -1
  68. package/dist/core/resolve/coerce.d.mts +1 -1
  69. package/dist/core/resolve/coerce.mjs +336 -1
  70. package/dist/core/resolve/config.mjs +19 -1
  71. package/dist/core/resolve/contracts.d.mts +9 -4
  72. package/dist/core/resolve/errors.d.mts +0 -1
  73. package/dist/core/resolve/errors.mjs +140 -2
  74. package/dist/core/resolve/flags.d.mts +7 -2
  75. package/dist/core/resolve/flags.mjs +251 -1
  76. package/dist/core/resolve/index.d.mts +2 -2
  77. package/dist/core/resolve/index.mjs +85 -1
  78. package/dist/core/resolve/property.d.mts +6 -2
  79. package/dist/core/resolve/property.mjs +53 -1
  80. package/dist/core/schema/activity.d.mts +31 -11
  81. package/dist/core/schema/arg.d.mts +92 -13
  82. package/dist/core/schema/arg.mjs +463 -1
  83. package/dist/core/schema/command.d.mts +29 -7
  84. package/dist/core/schema/command.mjs +726 -1
  85. package/dist/core/schema/flag.d.mts +577 -21
  86. package/dist/core/schema/flag.mjs +705 -1
  87. package/dist/core/schema/index.d.mts +5 -2
  88. package/dist/core/schema/middleware.d.mts +4 -3
  89. package/dist/core/schema/middleware.mjs +41 -1
  90. package/dist/core/schema/number-constraints.d.mts +96 -0
  91. package/dist/core/schema/number-constraints.mjs +60 -0
  92. package/dist/core/schema/prompt.d.mts +21 -3
  93. package/dist/core/schema/run.d.mts +24 -5
  94. package/dist/core/schema/string-constraints.d.mts +97 -0
  95. package/dist/core/schema/string-constraints.mjs +69 -0
  96. package/dist/core/schema/value-parsers.d.mts +78 -0
  97. package/dist/core/schema/value-parsers.mjs +142 -0
  98. package/dist/core/schema-dsl/runtime.mjs +271 -2
  99. package/dist/core/schema-dsl/to-json-schema.d.mts +0 -1
  100. package/dist/core/schema-dsl/to-json-schema.mjs +74 -1
  101. package/dist/core/testkit/index.d.mts +9 -36
  102. package/dist/core/testkit/index.mjs +83 -1
  103. package/dist/index.d.mts +12 -6
  104. package/dist/index.mjs +22 -1
  105. package/dist/runtime/adapter.d.mts +38 -2
  106. package/dist/runtime/adapter.mjs +87 -1
  107. package/dist/runtime/auto.d.mts +2 -3
  108. package/dist/runtime/auto.mjs +45 -1
  109. package/dist/runtime/deno.d.mts +24 -5
  110. package/dist/runtime/deno.mjs +262 -2
  111. package/dist/runtime/detect.mjs +45 -1
  112. package/dist/runtime/index.d.mts +3 -4
  113. package/dist/runtime/node.d.mts +8 -2
  114. package/dist/runtime/node.mjs +220 -2
  115. package/dist/runtime/paths.mjs +48 -1
  116. package/dist/runtime.d.mts +4 -4
  117. package/dist/runtime.mjs +6 -1
  118. package/dist/strings.mjs +22 -1
  119. package/dist/testkit.d.mts +1 -0
  120. package/dist/testkit.mjs +5 -1
  121. package/dist/version.d.mts +7 -3
  122. package/dist/version.mjs +7 -1
  123. package/dreamcli.schema.json +36 -7
  124. package/examples/basic.ts +5 -1
  125. package/examples/gh/package.json +2 -7
  126. package/examples/pwsh-demo/package.json +1 -7
  127. package/examples/pwsh-demo/src/main.test.ts +1 -4
  128. package/examples/pwsh-demo/src/main.ts +14 -4
  129. package/examples/transport-launcher.ts +85 -0
  130. package/package.json +43 -49
  131. package/dist/runtime/bun.d.mts +0 -28
  132. package/dist/runtime/bun.mjs +0 -1
  133. package/dist/runtime/support.d.mts +0 -42
  134. package/dist/runtime/support.mjs +0 -1
  135. package/src/core/cli/dispatch.ts +0 -349
  136. package/src/core/cli/help-links.ts +0 -82
  137. package/src/core/cli/index.ts +0 -1413
  138. package/src/core/cli/planner.ts +0 -487
  139. package/src/core/cli/plugin.ts +0 -117
  140. package/src/core/cli/propagate.ts +0 -97
  141. package/src/core/cli/root-help.ts +0 -252
  142. package/src/core/cli/root-surface.ts +0 -74
  143. package/src/core/cli/runtime-preflight.ts +0 -438
  144. package/src/core/completion/index.ts +0 -88
  145. package/src/core/completion/shells/bash.ts +0 -459
  146. package/src/core/completion/shells/fish.ts +0 -259
  147. package/src/core/completion/shells/powershell.ts +0 -439
  148. package/src/core/completion/shells/shared.ts +0 -283
  149. package/src/core/completion/shells/zsh.ts +0 -381
  150. package/src/core/config/index.ts +0 -417
  151. package/src/core/config/package-json.ts +0 -560
  152. package/src/core/errors/index.ts +0 -193
  153. package/src/core/execution/index.ts +0 -268
  154. package/src/core/help/ansi.ts +0 -144
  155. package/src/core/help/index.ts +0 -516
  156. package/src/core/json-schema/index.ts +0 -891
  157. package/src/core/json-schema/meta-descriptions.generated.ts +0 -185
  158. package/src/core/output/activity.ts +0 -575
  159. package/src/core/output/bind.ts +0 -59
  160. package/src/core/output/contracts.ts +0 -194
  161. package/src/core/output/display-value.ts +0 -48
  162. package/src/core/output/index.ts +0 -704
  163. package/src/core/output/renderers.ts +0 -125
  164. package/src/core/output/writer.ts +0 -46
  165. package/src/core/parse/index.ts +0 -681
  166. package/src/core/prompt/index.ts +0 -583
  167. package/src/core/resolve/args.ts +0 -144
  168. package/src/core/resolve/coerce.ts +0 -432
  169. package/src/core/resolve/config.ts +0 -26
  170. package/src/core/resolve/contracts.ts +0 -135
  171. package/src/core/resolve/errors.ts +0 -227
  172. package/src/core/resolve/flags.ts +0 -255
  173. package/src/core/resolve/index.ts +0 -108
  174. package/src/core/resolve/property.ts +0 -99
  175. package/src/core/schema/activity.ts +0 -240
  176. package/src/core/schema/arg.ts +0 -719
  177. package/src/core/schema/command.ts +0 -1498
  178. package/src/core/schema/flag.ts +0 -801
  179. package/src/core/schema/index.ts +0 -91
  180. package/src/core/schema/middleware.ts +0 -171
  181. package/src/core/schema/prompt.ts +0 -156
  182. package/src/core/schema/run.ts +0 -198
  183. package/src/core/schema-dsl/index.ts +0 -109
  184. package/src/core/schema-dsl/parse.ts +0 -262
  185. package/src/core/schema-dsl/runtime.ts +0 -609
  186. package/src/core/schema-dsl/to-json-schema.ts +0 -102
  187. package/src/core/testkit/index.ts +0 -123
  188. package/src/index.ts +0 -179
  189. package/src/runtime/adapter.ts +0 -303
  190. package/src/runtime/auto.ts +0 -110
  191. package/src/runtime/bun.ts +0 -55
  192. package/src/runtime/deno.ts +0 -369
  193. package/src/runtime/detect.ts +0 -105
  194. package/src/runtime/index.ts +0 -21
  195. package/src/runtime/node-builtins.d.ts +0 -27
  196. package/src/runtime/node.ts +0 -300
  197. package/src/runtime/paths.ts +0 -64
  198. package/src/runtime/support.ts +0 -135
  199. package/src/runtime.ts +0 -31
  200. package/src/strings.ts +0 -34
  201. package/src/testkit.ts +0 -25
  202. package/src/version.ts +0 -20
@@ -1,194 +0,0 @@
1
- /**
2
- * Internal output policy contract for mode selection and cleanup semantics.
3
- *
4
- * Captures the stable seam between semantic output decisions and the concrete
5
- * rendering layer before the output module is split more aggressively.
6
- *
7
- * @module dreamcli/core/output/contracts
8
- * @internal
9
- */
10
-
11
- import type { Fallback, TableOptions } from '#internals/core/schema/activity.ts';
12
-
13
- /** Ordered output verbosity levels owned by the output policy layer. */
14
- const OUTPUT_VERBOSITY_LEVELS = ['normal', 'quiet'] as const;
15
-
16
- /** Stable output text streams. */
17
- const OUTPUT_STREAMS = ['stdout', 'stderr'] as const;
18
-
19
- /** Stable activity rendering modes. */
20
- const ACTIVITY_RENDER_MODES = ['noop', 'static', 'tty', 'capture'] as const;
21
-
22
- /** Stable activity cleanup actions. */
23
- const ACTIVITY_CLEANUP_KINDS = ['none', 'stop', 'done'] as const;
24
-
25
- /** Stable text verbosity labels. */
26
- type Verbosity = (typeof OUTPUT_VERBOSITY_LEVELS)[number];
27
-
28
- /** Stable output stream labels. */
29
- type OutputStream = (typeof OUTPUT_STREAMS)[number];
30
-
31
- /** Stable activity-render labels. */
32
- type ActivityRenderMode = (typeof ACTIVITY_RENDER_MODES)[number];
33
-
34
- /** Stable cleanup labels for tracked activity handles. */
35
- type ActivityCleanupKind = (typeof ACTIVITY_CLEANUP_KINDS)[number];
36
-
37
- /** Semantic output facts chosen before concrete rendering begins. */
38
- interface OutputPolicy {
39
- /** Whether `--json` was requested, routing structured data to stdout. */
40
- readonly jsonMode: boolean;
41
- /** Whether the output stream is connected to an interactive terminal. */
42
- readonly isTTY: boolean;
43
- /** Active verbosity level controlling which message categories emit. */
44
- readonly verbosity: Verbosity;
45
- }
46
-
47
- /** Inputs for building an {@linkcode OutputPolicy} snapshot. */
48
- interface ResolveOutputPolicyOptions {
49
- /** Whether `--json` was requested on the command line. */
50
- readonly jsonMode: boolean;
51
- /** Whether the output stream is connected to an interactive terminal. */
52
- readonly isTTY: boolean;
53
- /** Verbosity level to apply for this channel instance. */
54
- readonly verbosity: Verbosity;
55
- }
56
-
57
- /** Concrete activity policy chosen for spinner/progress creation. */
58
- interface ActivityPolicy {
59
- /** Render strategy for the activity indicator (never `'capture'` here). */
60
- readonly mode: Exclude<ActivityRenderMode, 'capture'>;
61
- /** Activity output always targets stderr to avoid polluting structured stdout. */
62
- readonly stream: 'stderr';
63
- /** Cleanup action the output layer must run when the handle is discarded. */
64
- readonly cleanup: ActivityCleanupKind;
65
- }
66
-
67
- /** Stable output-policy facts the re-foundation workstream is freezing. */
68
- interface OutputContract {
69
- /** In JSON mode, stdout carries only machine-readable structured output. */
70
- readonly jsonReservesStdoutForStructuredData: true;
71
- /** Quiet verbosity suppresses `info()` messages entirely. */
72
- readonly quietSuppressesInfo: true;
73
- /** Spinner/progress writes go to stderr so stdout stays parseable. */
74
- readonly activityUsesStderrOutsideCapture: true;
75
- /** Animated TTY spinners require both a real terminal and non-JSON mode. */
76
- readonly ttyActivityRequiresTTYAndNonJson: true;
77
- /** Spinner handles clean up via `stop()` to clear the animation line. */
78
- readonly spinnerCleanupUsesStop: true;
79
- /** Progress handles clean up via `done()` to render the final state. */
80
- readonly progressCleanupUsesDone: true;
81
- }
82
-
83
- /** Runtime-accessible copy of the frozen output-policy invariants. */
84
- const outputContract = {
85
- jsonReservesStdoutForStructuredData: true,
86
- quietSuppressesInfo: true,
87
- activityUsesStderrOutsideCapture: true,
88
- ttyActivityRequiresTTYAndNonJson: true,
89
- spinnerCleanupUsesStop: true,
90
- progressCleanupUsesDone: true,
91
- } satisfies OutputContract;
92
-
93
- /** Build the stable output-policy snapshot for one channel instance. */
94
- function resolveOutputPolicy(options: ResolveOutputPolicyOptions): OutputPolicy {
95
- return {
96
- jsonMode: options.jsonMode,
97
- isTTY: options.isTTY,
98
- verbosity: options.verbosity,
99
- };
100
- }
101
-
102
- /** Resolve the default text stream for non-JSON structured output. */
103
- function resolveTextStream(policy: OutputPolicy): OutputStream {
104
- return policy.jsonMode ? 'stderr' : 'stdout';
105
- }
106
-
107
- /** Whether `info()` messages should be emitted under the current policy. */
108
- function shouldEmitInfo(policy: OutputPolicy): boolean {
109
- return policy.verbosity !== 'quiet';
110
- }
111
-
112
- /** Resolve the concrete table format under the current policy. */
113
- function resolveTableFormat(policy: OutputPolicy, options?: TableOptions): 'text' | 'json' {
114
- switch (options?.format) {
115
- case 'json':
116
- return 'json';
117
- case 'text':
118
- return 'text';
119
- case 'auto':
120
- case undefined:
121
- return policy.jsonMode ? 'json' : 'text';
122
- }
123
- }
124
-
125
- /** Resolve the text-table stream after table-format selection. */
126
- function resolveTableTextStream(policy: OutputPolicy, options?: TableOptions): OutputStream {
127
- if (options?.format === 'text' && 'stream' in options && options.stream !== undefined) {
128
- return options.stream;
129
- }
130
-
131
- return resolveTextStream(policy);
132
- }
133
-
134
- /** Resolve the non-capture activity mode shared by spinner and progress. */
135
- function resolveActivityRenderMode(
136
- policy: OutputPolicy,
137
- fallback: Fallback,
138
- ): ActivityPolicy['mode'] {
139
- if (policy.jsonMode) {
140
- return 'noop';
141
- }
142
-
143
- if (policy.isTTY) {
144
- return 'tty';
145
- }
146
-
147
- return fallback === 'static' ? 'static' : 'noop';
148
- }
149
-
150
- /** Resolve spinner activity policy including cleanup ownership. */
151
- function resolveSpinnerPolicy(policy: OutputPolicy, fallback: Fallback): ActivityPolicy {
152
- const mode = resolveActivityRenderMode(policy, fallback);
153
- return {
154
- mode,
155
- stream: 'stderr',
156
- cleanup: mode === 'noop' ? 'none' : 'stop',
157
- };
158
- }
159
-
160
- /** Resolve progress activity policy including cleanup ownership. */
161
- function resolveProgressPolicy(policy: OutputPolicy, fallback: Fallback): ActivityPolicy {
162
- const mode = resolveActivityRenderMode(policy, fallback);
163
- return {
164
- mode,
165
- stream: 'stderr',
166
- cleanup: mode === 'noop' ? 'none' : 'done',
167
- };
168
- }
169
-
170
- export type {
171
- ActivityCleanupKind,
172
- ActivityPolicy,
173
- ActivityRenderMode,
174
- OutputContract,
175
- OutputPolicy,
176
- OutputStream,
177
- ResolveOutputPolicyOptions,
178
- Verbosity,
179
- };
180
- export {
181
- ACTIVITY_CLEANUP_KINDS,
182
- ACTIVITY_RENDER_MODES,
183
- OUTPUT_STREAMS,
184
- OUTPUT_VERBOSITY_LEVELS,
185
- outputContract,
186
- resolveActivityRenderMode,
187
- resolveOutputPolicy,
188
- resolveProgressPolicy,
189
- resolveSpinnerPolicy,
190
- resolveTableFormat,
191
- resolveTableTextStream,
192
- resolveTextStream,
193
- shouldEmitInfo,
194
- };
@@ -1,48 +0,0 @@
1
- /**
2
- * Shared runtime-value formatting for human-readable output.
3
- *
4
- * Used by help text and table rendering so default values and structured cells
5
- * stringify consistently across the CLI surface.
6
- *
7
- * @module dreamcli/core/output/display-value
8
- * @internal
9
- */
10
-
11
- /**
12
- * Format an unknown runtime value for human-readable output.
13
- *
14
- * @param value - The value to format (any type).
15
- * @returns A string representation suitable for table cells and help text.
16
- */
17
- function formatDisplayValue(value: unknown): string {
18
- if (value === null || value === undefined) return '';
19
-
20
- if (
21
- typeof value === 'string' ||
22
- typeof value === 'number' ||
23
- typeof value === 'boolean' ||
24
- typeof value === 'bigint' ||
25
- typeof value === 'symbol'
26
- ) {
27
- return String(value);
28
- }
29
-
30
- if (value instanceof Date) {
31
- if (Number.isNaN(value.getTime())) {
32
- return 'Invalid Date';
33
- }
34
- return value.toISOString();
35
- }
36
-
37
- if (typeof value === 'function') {
38
- return value.name.length > 0 ? `[Function: ${value.name}]` : '[Function]';
39
- }
40
-
41
- try {
42
- return JSON.stringify(value) ?? '[unserializable]';
43
- } catch {
44
- return '[unserializable]';
45
- }
46
- }
47
-
48
- export { formatDisplayValue };