@kjanat/dreamcli 3.0.0-rc.1 → 3.0.0-rc.2

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 (136) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/dist/core/cli/dispatch.mjs +214 -1
  3. package/dist/core/cli/help-links.mjs +41 -1
  4. package/dist/core/cli/index.mjs +901 -1
  5. package/dist/core/cli/planner.mjs +300 -1
  6. package/dist/core/cli/plugin.mjs +41 -1
  7. package/dist/core/cli/propagate.mjs +57 -1
  8. package/dist/core/cli/root-help.mjs +208 -4
  9. package/dist/core/cli/root-surface.mjs +27 -1
  10. package/dist/core/cli/runtime-preflight.mjs +168 -1
  11. package/dist/core/completion/index.mjs +90 -1
  12. package/dist/core/completion/shells/bash.mjs +304 -3
  13. package/dist/core/completion/shells/fish.mjs +159 -2
  14. package/dist/core/completion/shells/powershell.mjs +353 -2
  15. package/dist/core/completion/shells/shared.mjs +154 -1
  16. package/dist/core/completion/shells/zsh.mjs +244 -2
  17. package/dist/core/config/index.mjs +246 -1
  18. package/dist/core/config/package-json.mjs +385 -3
  19. package/dist/core/errors/index.mjs +87 -1
  20. package/dist/core/execution/index.mjs +189 -1
  21. package/dist/core/help/ansi.mjs +122 -2
  22. package/dist/core/help/index.mjs +329 -7
  23. package/dist/core/json-schema/index.mjs +487 -9
  24. package/dist/core/json-schema/meta-descriptions.generated.mjs +93 -28
  25. package/dist/core/output/activity.mjs +452 -1
  26. package/dist/core/output/bind.mjs +56 -1
  27. package/dist/core/output/contracts.mjs +57 -1
  28. package/dist/core/output/display-value.mjs +32 -1
  29. package/dist/core/output/index.d.mts +21 -0
  30. package/dist/core/output/index.mjs +442 -2
  31. package/dist/core/output/renderers.mjs +46 -1
  32. package/dist/core/output/writer.mjs +12 -1
  33. package/dist/core/parse/index.mjs +555 -1
  34. package/dist/core/prompt/index.d.mts +0 -1
  35. package/dist/core/prompt/index.mjs +348 -6
  36. package/dist/core/resolve/args.mjs +105 -1
  37. package/dist/core/resolve/coerce.mjs +279 -1
  38. package/dist/core/resolve/config.mjs +19 -1
  39. package/dist/core/resolve/errors.mjs +140 -2
  40. package/dist/core/resolve/flags.mjs +196 -1
  41. package/dist/core/resolve/index.mjs +85 -1
  42. package/dist/core/resolve/property.d.mts +0 -1
  43. package/dist/core/resolve/property.mjs +45 -1
  44. package/dist/core/schema/arg.mjs +463 -1
  45. package/dist/core/schema/command.d.mts +18 -0
  46. package/dist/core/schema/command.mjs +712 -1
  47. package/dist/core/schema/flag.mjs +453 -1
  48. package/dist/core/schema/middleware.mjs +41 -1
  49. package/dist/core/schema/number-constraints.mjs +60 -1
  50. package/dist/core/schema-dsl/runtime.mjs +271 -2
  51. package/dist/core/schema-dsl/to-json-schema.mjs +74 -1
  52. package/dist/core/testkit/index.mjs +83 -1
  53. package/dist/index.d.mts +2 -1
  54. package/dist/index.mjs +22 -1
  55. package/dist/runtime/adapter.mjs +82 -1
  56. package/dist/runtime/auto.mjs +46 -1
  57. package/dist/runtime/bun.mjs +28 -1
  58. package/dist/runtime/deno.mjs +217 -2
  59. package/dist/runtime/detect.mjs +45 -1
  60. package/dist/runtime/node.mjs +169 -2
  61. package/dist/runtime/paths.mjs +48 -1
  62. package/dist/runtime.mjs +7 -1
  63. package/dist/strings.mjs +22 -1
  64. package/dist/testkit.mjs +5 -1
  65. package/dist/version.mjs +7 -1
  66. package/package.json +17 -26
  67. package/src/core/cli/dispatch.ts +0 -355
  68. package/src/core/cli/help-links.ts +0 -82
  69. package/src/core/cli/index.ts +0 -1614
  70. package/src/core/cli/planner.ts +0 -656
  71. package/src/core/cli/plugin.ts +0 -117
  72. package/src/core/cli/propagate.ts +0 -97
  73. package/src/core/cli/root-help.ts +0 -342
  74. package/src/core/cli/root-surface.ts +0 -87
  75. package/src/core/cli/runtime-preflight.ts +0 -456
  76. package/src/core/completion/index.ts +0 -138
  77. package/src/core/completion/shells/bash.ts +0 -459
  78. package/src/core/completion/shells/fish.ts +0 -259
  79. package/src/core/completion/shells/powershell.ts +0 -439
  80. package/src/core/completion/shells/shared.ts +0 -310
  81. package/src/core/completion/shells/zsh.ts +0 -381
  82. package/src/core/config/index.ts +0 -417
  83. package/src/core/config/package-json.ts +0 -560
  84. package/src/core/errors/index.ts +0 -193
  85. package/src/core/execution/index.ts +0 -265
  86. package/src/core/help/ansi.ts +0 -144
  87. package/src/core/help/index.ts +0 -563
  88. package/src/core/json-schema/index.ts +0 -910
  89. package/src/core/json-schema/meta-descriptions.generated.ts +0 -202
  90. package/src/core/output/activity.ts +0 -575
  91. package/src/core/output/bind.ts +0 -59
  92. package/src/core/output/contracts.ts +0 -194
  93. package/src/core/output/display-value.ts +0 -48
  94. package/src/core/output/index.ts +0 -704
  95. package/src/core/output/renderers.ts +0 -125
  96. package/src/core/output/writer.ts +0 -46
  97. package/src/core/parse/index.ts +0 -742
  98. package/src/core/prompt/index.ts +0 -623
  99. package/src/core/resolve/args.ts +0 -144
  100. package/src/core/resolve/coerce.ts +0 -500
  101. package/src/core/resolve/config.ts +0 -26
  102. package/src/core/resolve/contracts.ts +0 -135
  103. package/src/core/resolve/errors.ts +0 -227
  104. package/src/core/resolve/flags.ts +0 -269
  105. package/src/core/resolve/index.ts +0 -108
  106. package/src/core/resolve/property.ts +0 -99
  107. package/src/core/schema/activity.ts +0 -240
  108. package/src/core/schema/arg.ts +0 -841
  109. package/src/core/schema/command.ts +0 -1500
  110. package/src/core/schema/flag.ts +0 -917
  111. package/src/core/schema/index.ts +0 -96
  112. package/src/core/schema/middleware.ts +0 -171
  113. package/src/core/schema/number-constraints.ts +0 -153
  114. package/src/core/schema/prompt.ts +0 -171
  115. package/src/core/schema/run.ts +0 -198
  116. package/src/core/schema-dsl/index.ts +0 -109
  117. package/src/core/schema-dsl/parse.ts +0 -262
  118. package/src/core/schema-dsl/runtime.ts +0 -609
  119. package/src/core/schema-dsl/to-json-schema.ts +0 -102
  120. package/src/core/testkit/index.ts +0 -147
  121. package/src/index.ts +0 -181
  122. package/src/runtime/adapter.ts +0 -303
  123. package/src/runtime/auto.ts +0 -86
  124. package/src/runtime/bun.ts +0 -48
  125. package/src/runtime/deno.ts +0 -367
  126. package/src/runtime/detect.ts +0 -105
  127. package/src/runtime/index.ts +0 -21
  128. package/src/runtime/node-builtins.d.ts +0 -27
  129. package/src/runtime/node.ts +0 -289
  130. package/src/runtime/paths.ts +0 -64
  131. package/src/runtime/support.ts +0 -77
  132. package/src/runtime.ts +0 -31
  133. package/src/schema.ts +0 -16
  134. package/src/strings.ts +0 -34
  135. package/src/testkit.ts +0 -25
  136. 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 };