Back to Cline

Core Configuration

.agents/skills/opentui/references/core/configuration.md

3.88.04.5 KB
Original Source

Core Configuration

Renderer Configuration

createCliRenderer Options

typescript
import { createCliRenderer, ConsolePosition } from "@opentui/core"

const renderer = await createCliRenderer({
  // Rendering
  targetFPS: 60,                    // Target frames per second (default: 60)

  // Behavior
  exitOnCtrlC: true,                // Exit on Ctrl+C (default: true)

  // Console overlay
  consoleOptions: {
    position: ConsolePosition.BOTTOM,  // BOTTOM | TOP | LEFT | RIGHT
    sizePercent: 30,                   // Percentage of screen
    colorInfo: "#00FFFF",
    colorWarn: "#FFFF00",
    colorError: "#FF0000",
    colorDebug: "#888888",
    startInDebugMode: false,
  },

  // Lifecycle
  onDestroy: () => {
    // Cleanup callback
  },
})

Environment Variables

OpenTUI respects several environment variables for configuration and debugging.

Debug & Development

VariableTypeDefaultDescription
OTUI_DEBUGbooleanfalseEnable debug mode, capture raw input
OTUI_DEBUG_FFIbooleanfalseDebug logging for FFI bindings
OTUI_TRACE_FFIbooleanfalseTracing for FFI bindings
OTUI_SHOW_STATSbooleanfalseShow debug overlay at startup
OTUI_DUMP_CAPTURESbooleanfalseDump captured output on exit

Console

VariableTypeDefaultDescription
OTUI_USE_CONSOLEbooleantrueEnable console capture
SHOW_CONSOLEbooleanfalseShow console at startup

Rendering

VariableTypeDefaultDescription
OTUI_NO_NATIVE_RENDERbooleanfalseDisable ANSI output (for debugging)
OTUI_USE_ALTERNATE_SCREENbooleantrueUse alternate screen buffer
OTUI_OVERRIDE_STDOUTbooleantrueOverride stdout stream

Terminal Capabilities

VariableTypeDefaultDescription
OPENTUI_NO_GRAPHICSbooleanfalseDisable Kitty graphics protocol
OPENTUI_FORCE_UNICODEbooleanfalseForce Mode 2026 Unicode support
OPENTUI_FORCE_WCWIDTHbooleanfalseUse wcwidth for character width
OPENTUI_FORCE_NOZWJbooleanfalseDisable ZWJ emoji joining
OPENTUI_FORCE_EXPLICIT_WIDTHstring-Force explicit width ("true"/"false")

Tree-sitter (Syntax Highlighting)

VariableTypeDefaultDescription
OTUI_TS_STYLE_WARNbooleanfalseWarn on missing syntax styles
OTUI_TREE_SITTER_WORKER_PATHstring""Custom tree-sitter worker path

XDG Paths

VariableTypeDefaultDescription
XDG_CONFIG_HOMEstring""User config directory
XDG_DATA_HOMEstring""User data directory

Usage Examples

Development Mode

bash
# Show debug overlay and console
OTUI_SHOW_STATS=true SHOW_CONSOLE=true bun run src/index.ts

# Debug FFI issues
OTUI_DEBUG_FFI=true OTUI_TRACE_FFI=true bun run src/index.ts

# Disable native rendering for testing
OTUI_NO_NATIVE_RENDER=true bun run src/index.ts

Terminal Compatibility

bash
# Force wcwidth for problematic terminals
OPENTUI_FORCE_WCWIDTH=true bun run src/index.ts

# Disable graphics for SSH sessions
OPENTUI_NO_GRAPHICS=true bun run src/index.ts

Project Setup

package.json

json
{
  "name": "my-tui-app",
  "type": "module",
  "scripts": {
    "start": "bun run src/index.ts",
    "dev": "bun --watch run src/index.ts",
    "test": "bun test"
  },
  "dependencies": {
    "@opentui/core": "latest"
  },
  "devDependencies": {
    "@types/bun": "latest",
    "typescript": "latest"
  }
}

tsconfig.json

json
{
  "compilerOptions": {
    "lib": ["ESNext"],
    "target": "ESNext",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "skipLibCheck": true,
    "noEmit": true,
    "types": ["bun-types"]
  },
  "include": ["src/**/*"]
}

Note: OpenTUI uses NodeNext module resolution. All internal imports use .js extensions. If you use bundler resolution, imports still work but NodeNext is recommended for compatibility.

Building Native Code

Native code changes require rebuilding:

bash
# From repo root (if developing OpenTUI itself)
bun run build

# Zig is required for native compilation
# Install: https://ziglang.org/learn/getting-started/

Note: TypeScript changes do NOT require building. Bun runs TypeScript directly.