@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
package/dist/runtime/paths.mjs
CHANGED
|
@@ -1 +1,48 @@
|
|
|
1
|
-
import{stripTrailing
|
|
1
|
+
import { stripTrailing } from "../strings.mjs";
|
|
2
|
+
//#region src/runtime/paths.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shared env-based path resolution for runtime adapters.
|
|
5
|
+
*
|
|
6
|
+
* Node, Bun, and Deno all need the same user home/config directory behavior.
|
|
7
|
+
* These helpers keep the fallback chain identical across runtimes while
|
|
8
|
+
* letting each adapter supply its own platform detection.
|
|
9
|
+
*
|
|
10
|
+
* @module @kjanat/dreamcli/runtime/paths
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the user's home directory from environment variables.
|
|
14
|
+
*
|
|
15
|
+
* @param env - Environment variable map.
|
|
16
|
+
* @param isWindows - Whether the platform is Windows.
|
|
17
|
+
* @returns Absolute path to the home directory.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
function resolveHomeDirectory(env, isWindows) {
|
|
21
|
+
if (isWindows) {
|
|
22
|
+
if (env.USERPROFILE) return env.USERPROFILE;
|
|
23
|
+
if (env.HOMEDRIVE && env.HOMEPATH) return env.HOMEDRIVE + env.HOMEPATH;
|
|
24
|
+
return env.HOME || "C:\\";
|
|
25
|
+
}
|
|
26
|
+
return env.HOME || "/";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the user's config directory (`XDG_CONFIG_HOME` / `APPDATA`).
|
|
30
|
+
*
|
|
31
|
+
* @param env - Environment variable map.
|
|
32
|
+
* @param isWindows - Whether the platform is Windows.
|
|
33
|
+
* @param homedir - Pre-resolved home directory (from {@link resolveHomeDirectory}).
|
|
34
|
+
* @returns Absolute path to the config directory.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
function resolveConfigDirectory(env, isWindows, homedir) {
|
|
38
|
+
if (isWindows) {
|
|
39
|
+
if (env.APPDATA !== void 0 && env.APPDATA !== "") return env.APPDATA;
|
|
40
|
+
return `${stripTrailing(homedir, [47, 92]) || homedir}\\AppData\\Roaming`;
|
|
41
|
+
}
|
|
42
|
+
const normalizedHome = stripTrailing(homedir, [47]);
|
|
43
|
+
if (env.XDG_CONFIG_HOME !== void 0 && env.XDG_CONFIG_HOME !== "") return env.XDG_CONFIG_HOME;
|
|
44
|
+
if (normalizedHome.length === 0) return "/.config";
|
|
45
|
+
return `${normalizedHome}/.config`;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { resolveConfigDirectory, resolveHomeDirectory };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createNodeAdapter } from "./runtime/node.mjs";
|
|
2
|
+
import { createBunAdapter } from "./runtime/bun.mjs";
|
|
3
|
+
import { createDenoAdapter } from "./runtime/deno.mjs";
|
|
4
|
+
import { RUNTIMES, detectRuntime } from "./runtime/detect.mjs";
|
|
5
|
+
import { createAdapter } from "./runtime/auto.mjs";
|
|
6
|
+
import { ExitError } from "./runtime/adapter.mjs";
|
|
7
|
+
export { ExitError, RUNTIMES, createAdapter, createBunAdapter, createDenoAdapter, createNodeAdapter, detectRuntime };
|
package/dist/strings.mjs
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/strings.ts
|
|
2
|
+
/**
|
|
3
|
+
* Remove trailing characters whose code points appear in `codes`.
|
|
4
|
+
*
|
|
5
|
+
* Linear-time replacement for trailing-character regexes such as
|
|
6
|
+
* `/[\\/]+$/`. Those patterns are polynomial-ReDoS prone: the engine
|
|
7
|
+
* greedily consumes the run, fails the end anchor, backtracks one
|
|
8
|
+
* character at a time, and repeats that work from every start position —
|
|
9
|
+
* O(n²) on adversarial input. This scan is O(n) with no backtracking.
|
|
10
|
+
*
|
|
11
|
+
* @param input - Source string.
|
|
12
|
+
* @param codes - Character codes to strip from the end of `input`.
|
|
13
|
+
* @returns `input` with all trailing matching characters removed.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function stripTrailing(input, codes) {
|
|
17
|
+
let end = input.length;
|
|
18
|
+
while (end > 0 && codes.includes(input.charCodeAt(end - 1))) end -= 1;
|
|
19
|
+
return end === input.length ? input : input.slice(0, end);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { stripTrailing };
|
package/dist/testkit.mjs
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import{createCaptureOutput
|
|
1
|
+
import { createCaptureOutput } from "./core/output/index.mjs";
|
|
2
|
+
import { PROMPT_CANCEL, createTestPrompter } from "./core/prompt/index.mjs";
|
|
3
|
+
import { runCommand } from "./core/testkit/index.mjs";
|
|
4
|
+
import { createTestAdapter } from "./runtime/adapter.mjs";
|
|
5
|
+
export { PROMPT_CANCEL, createCaptureOutput, createTestAdapter, createTestPrompter, runCommand };
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/version.ts
|
|
2
|
+
/** Package version (e.g. `"0.9.1"`). `"dev"` when running unbundled. */
|
|
3
|
+
const DREAMCLI_VERSION = "3.0.0-rc.2";
|
|
4
|
+
/** Git short SHA (e.g. `"f9b5f1a"`). `"dev"` when running unbundled. */
|
|
5
|
+
const DREAMCLI_REVISION = "9ba0c14";
|
|
6
|
+
//#endregion
|
|
7
|
+
export { DREAMCLI_REVISION, DREAMCLI_VERSION };
|
package/examples/basic.ts
CHANGED
|
@@ -24,7 +24,11 @@ const greet = command('greet')
|
|
|
24
24
|
// args.name: string — required positional
|
|
25
25
|
// flags.loud: boolean — defaults to false (all booleans do)
|
|
26
26
|
// flags.times: number — defaults to 1 (never undefined)
|
|
27
|
-
|
|
27
|
+
const repeatCount = Number.isFinite(flags.times)
|
|
28
|
+
? Math.max(0, Math.min(100, Math.floor(flags.times)))
|
|
29
|
+
: 1;
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < repeatCount; i++) {
|
|
28
32
|
const msg = `Hello, ${args.name}!`;
|
|
29
33
|
out.log(flags.loud ? msg.toUpperCase() : msg);
|
|
30
34
|
}
|
package/examples/gh/package.json
CHANGED
|
@@ -10,13 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"module": "src/main.ts",
|
|
13
|
-
"bin":
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"src",
|
|
18
|
-
"!src/**/*.test.ts"
|
|
19
|
-
],
|
|
13
|
+
"bin": "src/main.ts",
|
|
14
|
+
"files": ["src", "!src/**/*.test.ts"],
|
|
20
15
|
"scripts": {
|
|
21
16
|
"bd": "bun run build",
|
|
22
17
|
"build": "bun build src/main.ts --install --outdir=dist --format=esm --target=node --external @kjanat/dreamcli",
|
|
@@ -13,13 +13,7 @@
|
|
|
13
13
|
"bin": {
|
|
14
14
|
"pwsh-demo": "src/main.ts"
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
17
|
-
"src",
|
|
18
|
-
"README.md",
|
|
19
|
-
"smoke-powershell.ps1",
|
|
20
|
-
"pwsh-demo.cmd",
|
|
21
|
-
"!src/**/*.test.ts"
|
|
22
|
-
],
|
|
16
|
+
"files": ["src", "README.md", "smoke-powershell.ps1", "pwsh-demo.cmd", "!src/**/*.test.ts"],
|
|
23
17
|
"scripts": {
|
|
24
18
|
"build": "bun build src/main.ts --install --outdir=dist --format=esm --target=node --external @kjanat/dreamcli",
|
|
25
19
|
"smoke:powershell": "pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File ./smoke-powershell.ps1",
|
|
@@ -40,9 +40,6 @@ describe('pwsh-demo example', () => {
|
|
|
40
40
|
const result = await pwshDemo.execute(['bravo', '--profile', 'ops', '--shell', 'cmd']);
|
|
41
41
|
|
|
42
42
|
expect(result.exitCode).toBe(0);
|
|
43
|
-
expect(result.stdout).toEqual([
|
|
44
|
-
'Opening bravo with ops profile in cmd\n',
|
|
45
|
-
'Format: table\n',
|
|
46
|
-
]);
|
|
43
|
+
expect(result.stdout).toEqual(['Opening bravo with ops profile in cmd\n', 'Format: table\n']);
|
|
47
44
|
});
|
|
48
45
|
});
|
|
@@ -35,7 +35,9 @@ const open = command('open')
|
|
|
35
35
|
.flag('format', flag.enum(['table', 'json', 'yaml']).alias('f').describe('Output format'))
|
|
36
36
|
.flag('verbose', flag.boolean().alias('v').describe('Verbose logging'))
|
|
37
37
|
.action(({ args, flags, out }) => {
|
|
38
|
-
out.log(
|
|
38
|
+
out.log(
|
|
39
|
+
`Opening ${args.workspace} with ${flags.profile ?? 'default'} profile in ${flags.shell}`,
|
|
40
|
+
);
|
|
39
41
|
out.log(`Format: ${flags.format ?? 'table'}`);
|
|
40
42
|
if (flags.verbose) out.log('Verbose output enabled');
|
|
41
43
|
});
|
|
@@ -55,7 +57,9 @@ const deploy = command('deploy')
|
|
|
55
57
|
.flag('approval', flag.enum(['manual', 'auto']).describe('Approval mode'))
|
|
56
58
|
.flag('dryRun', flag.boolean().alias('d').describe('Preview the rollout without applying it'))
|
|
57
59
|
.action(({ args, flags, out }) => {
|
|
58
|
-
out.log(
|
|
60
|
+
out.log(
|
|
61
|
+
`Deploying ${args.target} to ${flags.region ?? 'us'} with ${flags.strategy ?? 'rolling'}`,
|
|
62
|
+
);
|
|
59
63
|
out.log(`Approval: ${flags.approval ?? 'manual'}`);
|
|
60
64
|
if (flags.dryRun) out.log('Dry run only');
|
|
61
65
|
});
|
|
@@ -82,7 +86,10 @@ const configSet = command('set')
|
|
|
82
86
|
.description('Write a saved setting')
|
|
83
87
|
.arg('key', arg.enum(['theme', 'region', 'profile']).describe('Setting to write'))
|
|
84
88
|
.arg('value', arg.string().describe('New value'))
|
|
85
|
-
.flag(
|
|
89
|
+
.flag(
|
|
90
|
+
'scope',
|
|
91
|
+
flag.enum(['user', 'workspace']).alias('s').default('user').describe('Config scope'),
|
|
92
|
+
)
|
|
86
93
|
.action(({ args, flags, out }) => {
|
|
87
94
|
out.log(`Saved ${args.key}=${args.value} to ${flags.scope} scope`);
|
|
88
95
|
});
|
|
@@ -107,7 +114,10 @@ const debugDump = command('debug-dump')
|
|
|
107
114
|
.hidden()
|
|
108
115
|
.flag(
|
|
109
116
|
'section',
|
|
110
|
-
flag
|
|
117
|
+
flag
|
|
118
|
+
.enum(['schema', 'completions', 'runtime'])
|
|
119
|
+
.default('schema')
|
|
120
|
+
.describe('Section to inspect'),
|
|
111
121
|
)
|
|
112
122
|
.action(({ flags, out }) => {
|
|
113
123
|
out.log(JSON.stringify({ section: flags.section, hidden: true }, null, 2));
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Single-transport launcher (language-server style).
|
|
4
|
+
*
|
|
5
|
+
* A launcher that must be started over exactly one transport. dreamcli has no
|
|
6
|
+
* native "mutually exclusive" / "exactly one of" modifier, so the rule is
|
|
7
|
+
* expressed in `.derive()` — the resolution-time hook that runs after flags
|
|
8
|
+
* resolve and before the action. The derived, fully typed `Transport` is then
|
|
9
|
+
* handed to `.action()` through `ctx`.
|
|
10
|
+
*
|
|
11
|
+
* Demonstrates: an "exactly one of" rule via `.derive()` throwing `CLIError`, a
|
|
12
|
+
* kebab-case flag name accessed with bracket notation (`flags['node-ipc']`), and
|
|
13
|
+
* passing a typed result to the action through derived context.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* npx tsx examples/transport-launcher.ts --stdio
|
|
17
|
+
* npx tsx examples/transport-launcher.ts --node-ipc
|
|
18
|
+
* npx tsx examples/transport-launcher.ts --socket 6009
|
|
19
|
+
* npx tsx examples/transport-launcher.ts # error: pick exactly one
|
|
20
|
+
* npx tsx examples/transport-launcher.ts --stdio --node-ipc # error: only one
|
|
21
|
+
* npx tsx examples/transport-launcher.ts --help
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { CLIError, cli, command, flag } from '@kjanat/dreamcli';
|
|
25
|
+
|
|
26
|
+
// One resolved transport — illegal states are unrepresentable.
|
|
27
|
+
type Transport =
|
|
28
|
+
| { readonly kind: 'stdio' }
|
|
29
|
+
| { readonly kind: 'node-ipc' }
|
|
30
|
+
| { readonly kind: 'socket'; readonly port: number };
|
|
31
|
+
|
|
32
|
+
const launcher = command('lsp-server')
|
|
33
|
+
.description('Launch the language server over exactly one transport')
|
|
34
|
+
.flag('stdio', flag.boolean().describe('Use the stdio transport'))
|
|
35
|
+
.flag('node-ipc', flag.boolean().describe('Use the Node IPC transport'))
|
|
36
|
+
.flag('socket', flag.number().describe('Use a TCP socket on <port>'))
|
|
37
|
+
// `.derive()` runs after resolution and before the action — the idiomatic
|
|
38
|
+
// place for a constraint dreamcli does not express declaratively.
|
|
39
|
+
.derive(({ flags }): { transport: Transport } => {
|
|
40
|
+
const selected: Transport[] = [];
|
|
41
|
+
if (flags.stdio) selected.push({ kind: 'stdio' });
|
|
42
|
+
// Kebab-case flag names stay kebab in the handler: bracket access, no camelCasing.
|
|
43
|
+
if (flags['node-ipc']) selected.push({ kind: 'node-ipc' });
|
|
44
|
+
if (flags.socket !== undefined) {
|
|
45
|
+
if (!Number.isInteger(flags.socket)) {
|
|
46
|
+
throw new CLIError(`--socket expects an integer port (got ${flags.socket}).`, {
|
|
47
|
+
code: 'INVALID_SOCKET_PORT',
|
|
48
|
+
suggest: 'Pass a whole number, e.g. --socket 6009',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
selected.push({ kind: 'socket', port: flags.socket });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const [transport, ...rest] = selected;
|
|
55
|
+
if (transport === undefined) {
|
|
56
|
+
throw new CLIError('No transport selected.', {
|
|
57
|
+
code: 'NO_TRANSPORT',
|
|
58
|
+
suggest: 'Pass exactly one of --stdio, --node-ipc, or --socket <port>',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (rest.length > 0) {
|
|
62
|
+
throw new CLIError('Choose exactly one transport flag.', {
|
|
63
|
+
code: 'TOO_MANY_TRANSPORTS',
|
|
64
|
+
suggest: 'Use only one of --stdio, --node-ipc, or --socket <port>',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { transport };
|
|
69
|
+
})
|
|
70
|
+
.action(({ ctx, out }) => {
|
|
71
|
+
// ctx.transport: Transport — fully typed, ready to hand to the server.
|
|
72
|
+
switch (ctx.transport.kind) {
|
|
73
|
+
case 'stdio':
|
|
74
|
+
out.log('Starting language server over stdio');
|
|
75
|
+
break;
|
|
76
|
+
case 'node-ipc':
|
|
77
|
+
out.log('Starting language server over node-ipc');
|
|
78
|
+
break;
|
|
79
|
+
case 'socket':
|
|
80
|
+
out.log(`Starting language server over socket :${ctx.transport.port}`);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
void cli('lsp-server').default(launcher).run();
|
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kjanat/dreamcli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-rc.2",
|
|
4
4
|
"description": "Schema-first, fully typed TypeScript CLI framework",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"dreamcli",
|
|
7
|
-
"cli",
|
|
8
|
-
"typescript",
|
|
9
|
-
"framework",
|
|
10
|
-
"schema-first",
|
|
11
|
-
"command-line"
|
|
12
|
-
],
|
|
5
|
+
"keywords": ["dreamcli", "cli", "typescript", "framework", "schema-first", "command-line"],
|
|
13
6
|
"homepage": "https://dreamcli.kjanat.dev",
|
|
14
7
|
"bugs": {
|
|
15
8
|
"url": "https://github.com/kjanat/dreamcli/issues"
|
|
@@ -36,42 +29,28 @@
|
|
|
36
29
|
"exports": {
|
|
37
30
|
".": {
|
|
38
31
|
"types": "./dist/index.d.mts",
|
|
39
|
-
"bun": "./src/index.ts",
|
|
40
|
-
"deno": "./src/index.ts",
|
|
41
32
|
"default": "./dist/index.mjs"
|
|
42
33
|
},
|
|
43
34
|
"./runtime": {
|
|
44
35
|
"types": "./dist/runtime.d.mts",
|
|
45
|
-
"bun": "./src/runtime.ts",
|
|
46
|
-
"deno": "./src/runtime.ts",
|
|
47
36
|
"default": "./dist/runtime.mjs"
|
|
48
37
|
},
|
|
49
38
|
"./testkit": {
|
|
50
39
|
"types": "./dist/testkit.d.mts",
|
|
51
|
-
"bun": "./src/testkit.ts",
|
|
52
|
-
"deno": "./src/testkit.ts",
|
|
53
40
|
"default": "./dist/testkit.mjs"
|
|
54
41
|
},
|
|
55
|
-
"./
|
|
56
|
-
"./
|
|
42
|
+
"./package.json": "./package.json",
|
|
43
|
+
"./schema": "./dreamcli.schema.json"
|
|
57
44
|
},
|
|
58
45
|
"files": [
|
|
59
46
|
"CHANGELOG.md",
|
|
60
|
-
"LICENSE",
|
|
61
|
-
"README.md",
|
|
62
47
|
"dist",
|
|
63
48
|
"dreamcli.schema.json",
|
|
64
49
|
"examples",
|
|
65
|
-
"
|
|
66
|
-
"package.json",
|
|
67
|
-
"src",
|
|
68
|
-
"!src/**/*.test.ts",
|
|
69
|
-
"!src/**/*test-helpers.ts",
|
|
50
|
+
"!**/.cache",
|
|
70
51
|
"!**/AGENTS.md"
|
|
71
52
|
],
|
|
72
|
-
"workspaces": [
|
|
73
|
-
"./examples/*"
|
|
74
|
-
],
|
|
53
|
+
"workspaces": ["./examples/*"],
|
|
75
54
|
"scripts": {
|
|
76
55
|
"bd": "run build",
|
|
77
56
|
"build": "bun --bun tsdown",
|
|
@@ -118,30 +97,33 @@
|
|
|
118
97
|
"overrides": {
|
|
119
98
|
"vitepress": "next"
|
|
120
99
|
},
|
|
100
|
+
"dependencies": {
|
|
101
|
+
"ansispeck": "^0.1.2"
|
|
102
|
+
},
|
|
121
103
|
"devDependencies": {
|
|
122
104
|
"@arethetypeswrong/core": "^0.18.4",
|
|
123
|
-
"@biomejs/biome": "^2.5.
|
|
105
|
+
"@biomejs/biome": "^2.5.2",
|
|
124
106
|
"@iarna/toml": "^2.2.5",
|
|
125
|
-
"@shikijs/transformers": "^4.
|
|
126
|
-
"@shikijs/vitepress-twoslash": "^4.
|
|
107
|
+
"@shikijs/transformers": "^4.3.1",
|
|
108
|
+
"@shikijs/vitepress-twoslash": "^4.3.1",
|
|
127
109
|
"@types/bun": "^1.3.14",
|
|
128
110
|
"@types/deno": "^2.7.0",
|
|
129
|
-
"@types/node": ">=
|
|
130
|
-
"@typescript/native-preview": "^7.0.0-dev",
|
|
111
|
+
"@types/node": ">=26.1.0",
|
|
112
|
+
"@typescript/native-preview": "^7.0.0-dev.20260705.1",
|
|
131
113
|
"@vitest/coverage-v8": "^4.1.9",
|
|
132
|
-
"dprint": "^0.
|
|
114
|
+
"dprint": "^0.55.1",
|
|
133
115
|
"floating-vue": "^5.2.2",
|
|
134
|
-
"knip": "^6.
|
|
135
|
-
"mermaid": "^11.
|
|
116
|
+
"knip": "^6.24.0",
|
|
117
|
+
"mermaid": "^11.16.0",
|
|
136
118
|
"publint": "^0.3.21",
|
|
137
|
-
"runner-run": "0.
|
|
119
|
+
"runner-run": "0.19.1",
|
|
138
120
|
"tsdown": "^0.22.3",
|
|
139
121
|
"typedoc": "^0.28.19",
|
|
140
122
|
"typescript": "^6.0.3",
|
|
141
|
-
"vite": "^8.1.
|
|
123
|
+
"vite": "^8.1.3",
|
|
142
124
|
"vitepress": "^2.0.0-alpha.17",
|
|
143
125
|
"vitest": "^4.1.9",
|
|
144
|
-
"wrangler": "^4.
|
|
126
|
+
"wrangler": "^4.107.0",
|
|
145
127
|
"yaml": "^2.9.0"
|
|
146
128
|
},
|
|
147
129
|
"packageManager": "bun@1.3.14",
|
|
@@ -161,8 +143,8 @@
|
|
|
161
143
|
}
|
|
162
144
|
},
|
|
163
145
|
"volta": {
|
|
164
|
-
"node": "26.
|
|
165
|
-
"npm": "11.
|
|
146
|
+
"node": "26.4.0",
|
|
147
|
+
"npm": "11.18.0"
|
|
166
148
|
},
|
|
167
149
|
"publishConfig": {
|
|
168
150
|
"access": "public",
|
|
@@ -170,7 +152,7 @@
|
|
|
170
152
|
},
|
|
171
153
|
"catalog": {
|
|
172
154
|
"@types/bun": "^1.3.14",
|
|
173
|
-
"@types/node": ">=
|
|
155
|
+
"@types/node": ">=26.1.0",
|
|
174
156
|
"typescript": "^6.0.3"
|
|
175
157
|
}
|
|
176
158
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region src/runtime/support.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Runtime compatibility matrix and version guard helpers.
|
|
4
|
-
*
|
|
5
|
-
* Keeps the supported runtime story in one place so adapter guards,
|
|
6
|
-
* package engines, and docs can stay aligned.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
* @module @kjanat/dreamcli/runtime/support
|
|
10
|
-
*/
|
|
11
|
-
type SupportedRuntime = 'node' | 'bun' | 'deno';
|
|
12
|
-
/**
|
|
13
|
-
* Support entry for a single runtime: version bounds, display names, and adapter mapping.
|
|
14
|
-
*
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
interface RuntimeSupportEntry {
|
|
18
|
-
/** Runtime identifier key. */
|
|
19
|
-
readonly runtime: SupportedRuntime;
|
|
20
|
-
/** Human-readable name (e.g. `'Node.js'`, `'Bun'`). */
|
|
21
|
-
readonly displayName: string;
|
|
22
|
-
/** Minimum supported version (semver, e.g. `'22.22.2'`). */
|
|
23
|
-
readonly minimum: string;
|
|
24
|
-
/** `engines` range string for package.json (e.g. `'>=22.22.2'`). */
|
|
25
|
-
readonly engineRange: string;
|
|
26
|
-
/** npm/JSR package name that ships this adapter. */
|
|
27
|
-
readonly packageName: string;
|
|
28
|
-
/** Adapter factory function name (e.g. `'NodeAdapter'`). */
|
|
29
|
-
readonly adapterName: string;
|
|
30
|
-
}
|
|
31
|
-
/** All supported runtimes with their version bounds and adapter metadata. @internal */
|
|
32
|
-
declare const SUPPORTED_RUNTIMES: readonly RuntimeSupportEntry[];
|
|
33
|
-
/** Look up the support entry for a given runtime. Throws on unknown runtime. @internal */
|
|
34
|
-
declare function getRuntimeSupport(runtime: SupportedRuntime): RuntimeSupportEntry;
|
|
35
|
-
/** Format a human-readable version requirement string (e.g. `'Node.js >= 22.22.2'`). @internal */
|
|
36
|
-
declare function formatRuntimeRequirement(runtime: SupportedRuntime): string;
|
|
37
|
-
/** Check whether a version string meets the minimum for the given runtime. @internal */
|
|
38
|
-
declare function isRuntimeVersionSupported(runtime: SupportedRuntime, version: string): boolean;
|
|
39
|
-
/** Throw if the detected version is below the minimum. No-op when version is undefined. @internal */
|
|
40
|
-
declare function assertRuntimeVersionSupported(runtime: SupportedRuntime, version: string | undefined): void;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { type RuntimeSupportEntry, SUPPORTED_RUNTIMES, type SupportedRuntime, assertRuntimeVersionSupported, formatRuntimeRequirement, getRuntimeSupport, isRuntimeVersionSupported };
|
package/dist/runtime/support.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=[{runtime:`node`,displayName:`Node.js`,minimum:`22.22.2`,engineRange:`>=22.22.2`,packageName:`@kjanat/dreamcli`,adapterName:`NodeAdapter`},{runtime:`bun`,displayName:`Bun`,minimum:`1.3`,engineRange:`>=1.3`,packageName:`@kjanat/dreamcli`,adapterName:`BunAdapter`},{runtime:`deno`,displayName:`Deno`,minimum:`2.6.0`,engineRange:`>=2.6.0`,packageName:`@kjanat/dreamcli`,adapterName:`DenoAdapter`}],t=/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/;function n(t){for(let n of e)if(n.runtime===t)return n;throw Error(`Unknown supported runtime '${t}'`)}function r(e){let n=t.exec(e);if(n===null)return;let r=Number.parseInt(n[1]??``,10),i=n[2],a=i===void 0?0:Number.parseInt(i,10),o=n[3],s=o===void 0?0:Number.parseInt(o,10);if(!(Number.isNaN(r)||Number.isNaN(a)||Number.isNaN(s)))return{major:r,minor:a,patch:s}}function i(e,t){return e.major===t.major?e.minor===t.minor?e.patch-t.patch:e.minor-t.minor:e.major-t.major}function a(e){let t=n(e);return`${t.displayName} >= ${t.minimum}`}function o(e,t){let a=r(t),o=r(n(e).minimum);return a===void 0||o===void 0?!1:i(a,o)>=0}function s(e,t){if(t!==void 0&&!o(e,t))throw Error(`@kjanat/dreamcli requires ${a(e)}. Detected ${n(e).displayName} ${t}.`)}export{s as assertRuntimeVersionSupported};
|