Seed CLISeed CLI

System

Shell commands, system info, and executable discovery.

bun add @seedcli/system

The system module provides shell command execution, executable discovery, system information, and environment access.

Command Execution

exec(command, options?)

Run shell commands and capture output:

const result = await seed.system.exec('git status')
console.log(result.stdout)
console.log(result.exitCode)

Exec Options

OptionTypeDefaultDescription
cwdstringprocess.cwd()Working directory
envRecord<string, string>Environment variables
streambooleanfalseStream output to terminal
stdinstring | BufferInput to feed to command
timeoutnumberTimeout in milliseconds
throwOnErrorbooleanfalseThrow on non-zero exit
shellbooleantrueRun in shell
trimbooleantrueTrim stdout/stderr whitespace

Exec Result

PropertyTypeDescription
stdoutstringStandard output
stderrstringStandard error
exitCodenumberProcess exit code
// Stream output in real time
await seed.system.exec('npm install', { stream: true })

// With environment variables
const result = await seed.system.exec('echo $MY_VAR', {
  env: { MY_VAR: 'hello' },
})

// Throw on failure
try {
  await seed.system.exec('make build', { throwOnError: true })
} catch (error) {
  // ExecError with stdout, stderr, exitCode
}

// With timeout
await seed.system.exec('long-task', { timeout: 30000 })

shell

Direct access to Bun's $ shell template literal:

const { shell } = seed.system

await shell`git add .`
await shell`git commit -m "feat: initial commit"`

// Pipe commands
const result = await shell`cat package.json | grep version`

Executable Discovery

which(name)

Find an executable in PATH (returns undefined if not found). This is a synchronous function:

const dockerPath = seed.system.which('docker')
if (dockerPath) {
  seed.print.info(`Docker found at ${dockerPath}`)
}

whichOrThrow(name)

Same as which, but throws ExecutableNotFoundError if not found. Also synchronous:

try {
  seed.system.whichOrThrow('docker')
} catch (error) {
  seed.print.error('Docker is required but not installed')
}

System Info

seed.system.os()         // 'macos' | 'linux' | 'windows'
seed.system.arch()       // 'x64' | 'arm64' | 'arm'
seed.system.platform()   // Node.js platform string
seed.system.hostname()   // Machine hostname
seed.system.cpus()       // Number of CPU cores
seed.system.uptime()     // System uptime in seconds

const mem = seed.system.memory()
// { total: 17179869184, free: 8589934592 }

Open

Open a file or URL in the default application:

// Open a URL in the browser
await seed.system.open('https://seedcli.dev')

// Open a file in its default app
await seed.system.open('report.pdf')

Environment

// Get an env variable
const token = seed.system.env('API_TOKEN')

// With default value
const port = seed.system.env('PORT', '3000')

Interactive Detection

Check if the terminal supports interactive prompts:

if (seed.system.isInteractive()) {
  const name = await seed.prompt.input('Name?')
} else {
  // CI or piped — use defaults
}

Error Types

import { ExecError, ExecutableNotFoundError, ExecTimeoutError } from '@seedcli/system'
ErrorDescription
ExecErrorCommand exited with non-zero code (when throwOnError: true)
ExecutableNotFoundErrorExecutable not found (from whichOrThrow)
ExecTimeoutErrorCommand exceeded timeout

On this page