Open-source terminal AI coding assistant - a Python reimplementation of Claude Code
Project description
OpenLaoKe
Open-source terminal AI coding assistant - a Python reimplementation of Claude Code.
Features
- Interactive REPL with rich terminal UI (optional Textual TUI mode)
- Tool System with 9 built-in tools:
Bash- Execute shell commands with streaming outputRead- Read file contents with line range supportWrite- Create/overwrite filesEdit- Targeted find-and-replace file edits with diff outputGlob- Fast file pattern matching (respects .gitignore)Grep- Regex search across files with multiple output modesAgent- Spawn sub-agents for parallel workTaskkill- Kill running tasksNotebookWrite- Write Jupyter notebook cells
- MCP Support - Connect to external MCP tool servers
- Permission System - Three modes: default, auto, bypass
- Session Persistence - Auto-save and resume sessions
- Cost Tracking - Real-time token usage and cost display
- Slash Commands - 11 built-in commands (
/help,/model,/cost,/compact, etc.) - Hook System - Extensible pre/post hooks for tool and API calls
- Multi-Model Support - Works with any Anthropic-compatible API
Installation
# Clone and install
cd OpenLaoKe
pip install -e .
# Or with uv (recommended)
uv pip install -e .
Usage
# Set your API key
export ANTHROPIC_API_KEY=your_key_here
# Interactive mode
openlaoke
# Non-interactive mode
openlaoke "Write a Python script that sorts a list"
# With options
openlaoke -m claude-sonnet-4-20250514 -p auto
openlaoke --thinking-budget 4000 --max-tokens 16000
openlaoke --cwd /path/to/project
Environment Variables
| Variable | Description | Default |
|---|---|---|
ANTHROPIC_API_KEY |
API key | (required) |
ANTHROPIC_BASE_URL |
API base URL | https://api.anthropic.com |
OPENLAOKE_MODEL |
Default model | claude-sonnet-4-20250514 |
OPENLAOKE_MAX_TOKENS |
Max response tokens | 8192 |
OPENLAOKE_THINKING_BUDGET |
Thinking tokens | 0 |
OPENLAOKE_TIMEOUT |
API timeout (seconds) | 300 |
HTTP_PROXY / HTTPS_PROXY |
Proxy URL | (none) |
Slash Commands
| Command | Description |
|---|---|
/help |
Show available commands |
/exit |
Exit OpenLaoKe |
/clear |
Clear screen and conversation |
/model [name] |
Show or change model |
/permission [mode] |
Change permission mode |
/compact |
Compact conversation |
/cost |
Show session cost and usage |
/cwd [path] |
Show or change working directory |
/resume |
Resume last session |
/commands |
Show example commands |
/settings |
Show current settings |
Architecture
openlaoke/
├── core/ # Core systems
│ ├── state.py # Centralized state management
│ ├── tool.py # Tool base class and registry
│ ├── task.py # Task lifecycle management
│ ├── api.py # Anthropic API client
│ ├── repl.py # REPL interaction loop
│ ├── hooks.py # Hook system
│ ├── sessions.py # Session persistence
│ ├── system_prompt.py # System prompt builder
│ └── agent_runner.py # Sub-agent execution
├── tools/ # Tool implementations
├── commands/ # Slash commands
├── services/ # External services (MCP)
├── components/ # UI components (TUI)
├── types/ # Type definitions
└── utils/ # Utilities
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run linter
ruff check .
# Run type checker
mypy openlaoke
# Run tests
pytest
# Run with dev mode
python -m openlaoke.entrypoints.cli
Configuration
User config is stored at ~/.openlaoke/config.json. You can edit it directly or use /settings in the REPL.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
openlaoke-0.1.1.tar.gz
(39.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
openlaoke-0.1.1-py3-none-any.whl
(48.4 kB
view details)
File details
Details for the file openlaoke-0.1.1.tar.gz.
File metadata
- Download URL: openlaoke-0.1.1.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1953a974bb4f45e56c4f5caab5c346abe8613d3b903b017e98564618a9d0dccd
|
|
| MD5 |
b2c0279eb4cfa968ccc2ffac4420c520
|
|
| BLAKE2b-256 |
0ba2733ef75da4309ea2f5b5f8d9e6b1ac48f1f9b0580d141706a52016b34574
|
File details
Details for the file openlaoke-0.1.1-py3-none-any.whl.
File metadata
- Download URL: openlaoke-0.1.1-py3-none-any.whl
- Upload date:
- Size: 48.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a2844557062a1b88f01d81b7e46ff5b73de7f9d6170257c4c5a142a9133ec5e
|
|
| MD5 |
bcbcafe0fd8dd5d637ca857b8076dc8f
|
|
| BLAKE2b-256 |
65ebb5ec654c5908179b037b4cdbec71df044cae8542ee7a9af75d52ac9d225a
|