Skip to content

@kjanat/dreamcli/runtime

Runtime adapter factory and platform detection.

ts
import {
  ,
  ,
} from '@kjanat/dreamcli/runtime';
import type { RuntimeAdapter } from '@kjanat/dreamcli/runtime';

createAdapter()

Create a runtime adapter via auto-detection.

ts
import {
  ,
  ,
  ,
  ,
} from '@kjanat/dreamcli/runtime';

const  = (); // auto-detect
const  = (); // explicit Node.js
const  = (); // explicit Bun
const  = (); // explicit Deno

RuntimeAdapter Interface

MemberKindDescription
argvreadonlyRaw command-line arguments
envreadonlyEnvironment variables
cwdreadonlyCurrent working directory
stdoutreadonlyStdout writer used by the output channel
stderrreadonlyStderr writer used by the output channel
stdinreadonlyLine reader used for interactive prompts
readStdin()methodRead all piped stdin as a single string, or null when stdin is a TTY / no data is piped
isTTYreadonlyWhether stdout is connected to a TTY
stdinIsTTYreadonlyWhether stdin is connected to a TTY
exit(code)methodExit the process
readFile(path)methodRead a UTF-8 file for config discovery
homedirreadonlyUser home directory
configDirreadonlyPlatform-specific configuration directory

detectRuntime()

Detect the current runtime environment.

ts
import {  } from '@kjanat/dreamcli/runtime';
import type {  } from '@kjanat/dreamcli/runtime';

const :  = ();

Supported Runtimes

RuntimeAdapterNotes
Node.js >= 22.22.2NodeAdapterFull support
Bun >= 1.3.11BunAdapterDelegates to Node adapter
Deno >= 2.6.0DenoAdapterPermission-safe Deno namespace

Adapter creation validates these minimum versions and throws immediately when the host runtime is too old.

Released under the MIT License.