@kjanat/dreamcli 2.5.0 → 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.
- package/CHANGELOG.md +153 -1
- package/README.md +9 -2
- package/dist/core/cli/dispatch.mjs +214 -1
- package/dist/core/cli/help-links.mjs +41 -1
- package/dist/core/cli/index.d.mts +109 -16
- package/dist/core/cli/index.mjs +901 -1
- package/dist/core/cli/planner.d.mts +27 -5
- package/dist/core/cli/planner.mjs +300 -1
- package/dist/core/cli/plugin.mjs +41 -1
- package/dist/core/cli/propagate.mjs +57 -1
- package/dist/core/cli/root-help.d.mts +16 -2
- package/dist/core/cli/root-help.mjs +208 -6
- package/dist/core/cli/root-surface.d.mts +18 -3
- package/dist/core/cli/root-surface.mjs +27 -1
- package/dist/core/cli/runtime-preflight.d.mts +16 -1
- package/dist/core/cli/runtime-preflight.mjs +168 -1
- package/dist/core/completion/index.d.mts +32 -1
- package/dist/core/completion/index.mjs +90 -1
- package/dist/core/completion/shells/bash.mjs +304 -3
- package/dist/core/completion/shells/fish.mjs +159 -2
- package/dist/core/completion/shells/powershell.mjs +353 -2
- package/dist/core/completion/shells/shared.d.mts +10 -0
- package/dist/core/completion/shells/shared.mjs +154 -1
- package/dist/core/completion/shells/zsh.mjs +244 -2
- package/dist/core/config/index.mjs +246 -1
- package/dist/core/config/package-json.mjs +385 -3
- package/dist/core/errors/index.mjs +87 -1
- package/dist/core/execution/index.mjs +189 -1
- package/dist/core/help/ansi.mjs +122 -2
- package/dist/core/help/index.d.mts +45 -1
- package/dist/core/help/index.mjs +329 -7
- package/dist/core/json-schema/index.mjs +487 -9
- package/dist/core/json-schema/meta-descriptions.generated.d.mts +38 -38
- package/dist/core/json-schema/meta-descriptions.generated.mjs +93 -28
- package/dist/core/output/activity.mjs +452 -1
- package/dist/core/output/bind.mjs +56 -1
- package/dist/core/output/contracts.mjs +57 -1
- package/dist/core/output/display-value.mjs +32 -1
- package/dist/core/output/index.d.mts +21 -0
- package/dist/core/output/index.mjs +442 -2
- package/dist/core/output/renderers.mjs +46 -1
- package/dist/core/output/writer.mjs +12 -1
- package/dist/core/parse/index.d.mts +15 -1
- package/dist/core/parse/index.mjs +555 -1
- package/dist/core/prompt/index.d.mts +11 -4
- package/dist/core/prompt/index.mjs +348 -6
- package/dist/core/resolve/args.mjs +105 -1
- package/dist/core/resolve/coerce.mjs +279 -1
- package/dist/core/resolve/config.mjs +19 -1
- package/dist/core/resolve/errors.mjs +140 -2
- package/dist/core/resolve/flags.mjs +196 -1
- package/dist/core/resolve/index.mjs +85 -1
- package/dist/core/resolve/property.d.mts +2 -1
- package/dist/core/resolve/property.mjs +45 -1
- package/dist/core/schema/arg.d.mts +90 -10
- package/dist/core/schema/arg.mjs +463 -1
- package/dist/core/schema/command.d.mts +21 -1
- package/dist/core/schema/command.mjs +712 -1
- package/dist/core/schema/flag.d.mts +92 -2
- package/dist/core/schema/flag.mjs +453 -1
- package/dist/core/schema/index.d.mts +2 -1
- package/dist/core/schema/middleware.mjs +41 -1
- package/dist/core/schema/number-constraints.d.mts +96 -0
- package/dist/core/schema/number-constraints.mjs +60 -0
- package/dist/core/schema/prompt.d.mts +15 -0
- package/dist/core/schema/run.d.mts +4 -4
- package/dist/core/schema-dsl/runtime.mjs +271 -2
- package/dist/core/schema-dsl/to-json-schema.mjs +74 -1
- package/dist/core/testkit/index.d.mts +9 -5
- package/dist/core/testkit/index.mjs +83 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +22 -1
- package/dist/runtime/adapter.mjs +82 -1
- package/dist/runtime/auto.mjs +46 -1
- package/dist/runtime/bun.mjs +28 -1
- package/dist/runtime/deno.mjs +217 -2
- package/dist/runtime/detect.mjs +45 -1
- package/dist/runtime/node.mjs +169 -2
- package/dist/runtime/paths.mjs +48 -1
- package/dist/runtime.mjs +7 -1
- package/dist/strings.mjs +22 -1
- package/dist/testkit.mjs +5 -1
- package/dist/version.mjs +7 -1
- package/examples/basic.ts +5 -1
- package/examples/gh/package.json +2 -7
- package/examples/pwsh-demo/package.json +1 -7
- package/examples/pwsh-demo/src/main.test.ts +1 -4
- package/examples/pwsh-demo/src/main.ts +14 -4
- package/examples/transport-launcher.ts +85 -0
- package/package.json +23 -41
- package/dist/runtime/support.d.mts +0 -42
- package/dist/runtime/support.mjs +0 -1
- package/src/core/cli/dispatch.ts +0 -349
- package/src/core/cli/help-links.ts +0 -82
- package/src/core/cli/index.ts +0 -1413
- package/src/core/cli/planner.ts +0 -487
- package/src/core/cli/plugin.ts +0 -117
- package/src/core/cli/propagate.ts +0 -97
- package/src/core/cli/root-help.ts +0 -252
- package/src/core/cli/root-surface.ts +0 -74
- package/src/core/cli/runtime-preflight.ts +0 -438
- package/src/core/completion/index.ts +0 -88
- package/src/core/completion/shells/bash.ts +0 -459
- package/src/core/completion/shells/fish.ts +0 -259
- package/src/core/completion/shells/powershell.ts +0 -439
- package/src/core/completion/shells/shared.ts +0 -283
- package/src/core/completion/shells/zsh.ts +0 -381
- package/src/core/config/index.ts +0 -417
- package/src/core/config/package-json.ts +0 -560
- package/src/core/errors/index.ts +0 -193
- package/src/core/execution/index.ts +0 -268
- package/src/core/help/ansi.ts +0 -144
- package/src/core/help/index.ts +0 -516
- package/src/core/json-schema/index.ts +0 -891
- package/src/core/json-schema/meta-descriptions.generated.ts +0 -185
- package/src/core/output/activity.ts +0 -575
- package/src/core/output/bind.ts +0 -59
- package/src/core/output/contracts.ts +0 -194
- package/src/core/output/display-value.ts +0 -48
- package/src/core/output/index.ts +0 -704
- package/src/core/output/renderers.ts +0 -125
- package/src/core/output/writer.ts +0 -46
- package/src/core/parse/index.ts +0 -681
- package/src/core/prompt/index.ts +0 -583
- package/src/core/resolve/args.ts +0 -144
- package/src/core/resolve/coerce.ts +0 -432
- package/src/core/resolve/config.ts +0 -26
- package/src/core/resolve/contracts.ts +0 -135
- package/src/core/resolve/errors.ts +0 -227
- package/src/core/resolve/flags.ts +0 -255
- package/src/core/resolve/index.ts +0 -108
- package/src/core/resolve/property.ts +0 -99
- package/src/core/schema/activity.ts +0 -240
- package/src/core/schema/arg.ts +0 -719
- package/src/core/schema/command.ts +0 -1498
- package/src/core/schema/flag.ts +0 -801
- package/src/core/schema/index.ts +0 -91
- package/src/core/schema/middleware.ts +0 -171
- package/src/core/schema/prompt.ts +0 -156
- package/src/core/schema/run.ts +0 -198
- package/src/core/schema-dsl/index.ts +0 -109
- package/src/core/schema-dsl/parse.ts +0 -262
- package/src/core/schema-dsl/runtime.ts +0 -609
- package/src/core/schema-dsl/to-json-schema.ts +0 -102
- package/src/core/testkit/index.ts +0 -123
- package/src/index.ts +0 -179
- package/src/runtime/adapter.ts +0 -303
- package/src/runtime/auto.ts +0 -110
- package/src/runtime/bun.ts +0 -55
- package/src/runtime/deno.ts +0 -369
- package/src/runtime/detect.ts +0 -105
- package/src/runtime/index.ts +0 -21
- package/src/runtime/node-builtins.d.ts +0 -27
- package/src/runtime/node.ts +0 -300
- package/src/runtime/paths.ts +0 -64
- package/src/runtime/support.ts +0 -135
- package/src/runtime.ts +0 -31
- package/src/strings.ts +0 -34
- package/src/testkit.ts +0 -25
- 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 };
|