A modern terminal library with a powerful CLI interface for building beautiful terminal applications in Python.
- ๐จ Rich UI Components: Banners, prompts, formatters, and code display with syntax highlighting
- ๐ฏ Centralized Output Management: Consistent console output with multiple log levels
- ๐ญ Theme Support: 8 built-in themes including default, dark, light, minimal, terminal, monokai, dracula, and solarized
- ๐ Code Display: Syntax highlighting, diffs, code reviews, and side-by-side comparisons
- ๐ง Terminal Management: Screen control, cursor management, hyperlinks, and color detection
- ๐ฌ Interactive Prompts: Text input, confirmations, number input, single/multi selection menus
- ๐ Data Formatting: Tables, trees, JSON, timestamps, and structured output
- ๐ Streaming Support: Live-updating messages for real-time content streaming (LLM-style)
- ๐ค AI-Friendly: Designed for AI agents with comprehensive docs and consistent APIs
- ๐ Environment Adaptation: Automatically adapts to TTY, CI, and NO_COLOR environments
# Install as dependency
uv add chuk-term
# Install globally as tool
uv tool install chuk-term# Install from PyPI
pip install chuk-term
# With development dependencies
pip install chuk-term[dev]# Clone the repository
git clone https://github.com/yourusername/chuk-term.git
cd chuk-term
# Install with uv (recommended)
uv sync --dev
# Or with pip
pip install -e ".[dev]"
# Verify installation
chuk-term --versionFor detailed installation instructions, see the Getting Started Guide.
ChukTerm is designed to be AI-friendly. For comprehensive guidance:
- ๐ Read the Getting Started Guide
- ๐ค Check llms.txt for LLM-optimized documentation
- ๐ Browse examples for working code
from chuk_term.ui import output
# Different message types
output.success("โ Operation completed successfully")
output.error("โ An error occurred")
output.warning("โ This needs attention")
output.info("โน Information message")
output.debug("๐ Debug information")
# Special formatting
output.tip("๐ก Pro tip: Use themes for better visuals")
output.hint("This is a subtle hint")
output.command("git commit -m 'Initial commit'")from chuk_term.ui import ask, confirm, select_from_list, ask_number
# Get user input
name = ask("What's your name?")
age = ask_number("How old are you?", min_value=0, max_value=150)
# Confirmation
if confirm("Would you like to continue?"):
output.success("Great! Let's proceed...")
# Selection menu
theme = select_from_list(
["default", "dark", "light", "minimal", "terminal"],
"Choose a theme:"
)from chuk_term.ui import display_code, display_diff
# Show code with syntax highlighting
code = '''def hello_world():
print("Hello from ChukTerm!")
return True'''
display_code(code, language="python", title="Example Function")
# Show a diff
display_diff(
old_text="Hello World",
new_text="Hello ChukTerm!",
title="Changes"
)from chuk_term.ui.streaming import StreamingMessage, StreamingAssistant
import time
# Basic streaming message
with StreamingMessage(title="๐ค Assistant") as stream:
stream.update("Processing your request")
time.sleep(0.5)
stream.update("...")
time.sleep(0.5)
stream.update(" Done!")
# Automatically finalizes with Markdown rendering
# Using StreamingAssistant for simpler API
assistant = StreamingAssistant()
stream = assistant.start()
for word in "Hello from ChukTerm streaming!".split():
assistant.update(word + " ")
time.sleep(0.2)
assistant.finalize()from chuk_term.ui import output
from chuk_term.ui.theme import set_theme, get_theme
# Set a theme
set_theme("monokai") # or dracula, solarized, minimal, terminal
# Get current theme
current = get_theme()
output.info(f"Using theme: {current.name}")ChukTerm includes a CLI for testing and demonstrating features:
# Show library information
chuk-term info
chuk-term info --verbose
# Run interactive demo
chuk-term demo
# Run a command with theming
chuk-term run "ls -la"
# Test with specific theme
chuk-term test --theme monokai# Clone the repository
git clone https://github.com/yourusername/chuk-term.git
cd chuk-term
# Install with dev dependencies using uv
uv sync --dev
# Install pre-commit hooks
pre-commit install# Run all tests with coverage
uv run pytest --cov=chuk_term
# Run specific test file
uv run pytest tests/ui/test_output.py
# Run with verbose output
uv run pytest -v# Run linting
uv run ruff check src/ tests/
# Auto-fix linting issues
uv run ruff check --fix src/ tests/
# Format code
uv run black src/ tests/
# Type checking
uv run mypy src/
# Run all checks
make checkmake help # Show all available commands
make dev # Install for development
make test # Run tests with coverage
make lint # Run linting checks
make format # Format code
make clean # Remove build artifacts- ๐ Getting Started Guide - Installation, examples, and best practices
- ๐ค LLM Documentation - AI-optimized reference (llmstxt.org)
- ๐ Examples Directory - Working code examples
- Output Management - Centralized console output system
- Terminal Management - Terminal control and state management
- Theme System - Theming and styling guide
- Package Management - Using uv for dependency management
- Unit Testing - Testing guidelines and best practices
- Test Coverage - Coverage requirements and reports
- Code Quality - Linting, formatting, and quality standards
output.debug()- Debug information (only in verbose mode)output.info()- Informational messagesoutput.success()- Success confirmationsoutput.warning()- Warning messagesoutput.error()- Error messages (non-fatal)output.fatal()- Fatal errors (exits program)
- default - Balanced colors, good for most terminals
- dark - High contrast on dark backgrounds
- light - Optimized for light terminals
- minimal - Plain text, no colors or icons
- terminal - Basic ANSI colors only
- monokai - Popular dark theme
- dracula - Gothic dark theme
- solarized - Low contrast, easy on eyes
The examples directory contains demonstration scripts:
| File | Description |
|---|---|
ui_demo.py |
Comprehensive UI component showcase |
ui_code_demo.py |
Code display and syntax highlighting |
ui_output_demo.py |
Output management features |
ui_terminal_demo.py |
Terminal control capabilities |
ui_theme_independence.py |
Theme system demonstration |
| Streaming Demos | |
ui_streaming_demo.py |
Advanced streaming UI capabilities |
ui_streaming_message_demo.py |
StreamingMessage and StreamingAssistant demos |
ui_streaming_practical_demo.py |
Real-world streaming use cases |
ui_streaming_quickstart.py |
Simple streaming examples to get started |
streaming_long_text_demo.py |
Token-by-token streaming with proper wrapping |
| Other | |
ui_quick_test.py |
Quick functionality test |
Run any example:
# Run the main demo
uv run python examples/ui_demo.py
# Try the streaming demos
uv run python examples/ui_streaming_quickstart.py
uv run python examples/ui_streaming_practical_demo.pychuk-term/
โโโ src/chuk_term/
โ โโโ __init__.py # Package metadata
โ โโโ cli.py # CLI interface
โ โโโ ui/ # UI components
โ โโโ output.py # Output management (singleton)
โ โโโ terminal.py # Terminal control
โ โโโ theme.py # Theme system (8 themes)
โ โโโ prompts.py # User prompts
โ โโโ formatters.py # Data formatters
โ โโโ code.py # Code display
โ โโโ banners.py # Banner displays
โ โโโ streaming.py # Streaming message support
โโโ tests/ # Test suite (351 tests)
โโโ examples/ # Example scripts
โ โโโ ui_demo.py
โ โโโ ui_streaming_*.py # Streaming demonstrations
โ โโโ ...
โโโ docs/ # Documentation
โ โโโ ui/
โ โโโ GETTING_STARTED.md # Quick start guide
โโโ llms.txt # LLM-optimized docs
โโโ CLAUDE.md # Project context
โโโ pyproject.toml # Package configuration
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
uv run pytest) - Commit with a descriptive message
- Push to your fork
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- ๐ซ Report issues at GitHub Issues
- ๐ฌ Discuss at GitHub Discussions
- ๐ Read docs at GitHub Wiki