An intelligent AI-powered coding agent CLI (based on LangChain) that helps you write, analyze, and understand code with natural language commands.
- AI-Powered Code Assistant: Interact with your codebase using natural language
- Human-in-the-Loop Approval: Review and approve tool executions before they run
- Tabbed Question Interface: Beautiful TUI for multi-step user interactions with:
- Tabbed navigation between questions
- Progress indicator ("Step X of Y")
- Arrow key navigation (←→ for tabs, ↑↓ for options)
- Preview panel for options with rich markdown/code preview
- Dark mode styling with blue highlights
- Submit validation (all questions must be answered)
- Inline custom input for "Other" options (supports English/Chinese)
- Rich Terminal UI: Beautiful output with markdown rendering and syntax highlighting
- Multi-Model Support: Works with OpenAI-compatible APIs (OpenAI, DeepSeek, etc.)
- Extensible Middleware System: Add custom behaviors via middleware
- Async Architecture: Built on asyncio for responsive interactions
- Python 3.11 or higher
- uv (recommended package manager)
# Clone the repository
git clone https://github.com/77z-zhou/DeepCode.git
cd deepcode
# Install dependencies
uv sync
# Or install in development mode
uv pip install -e .pip install -e .# Run deepcode
deepcode
# Or with Python
python -m deepcodeFirst run will prompt you to configure:
- API provider (OpenAI, DeepSeek, etc.)
- API key
- Model name
- Workspace directory
Start the CLI and chat with the agent:
deepcodeExample interactions:
You: Read the main.py file and summarize what it does
You: Add error handling to the parse_config function
You: Create a test for the User class
You: What files use the Database connection?
/help- Show help information/clear- Clear the screen/model- Change the AI model/compact- Compact conversation context/cost- Show API usage costs/exit- Exit the program/init- Reinitialize configuration
Configuration is stored in your project directory. The first run will guide you through setup:
# Sample configuration structure
{
"model": "gpt-4", # Model identifier
"api_key": "sk-...", # API key
"base_url": null, # Custom API base URL (optional)
"workspace": ".", # Working directory
"recursion_limit": 50, # Agent recursion limit
"skills_dir": ".claude/skills" # Custom skills directory
}deepcode/
├── deepcode/
│ ├── __init__.py
│ ├── __main__.py # Entry point
│ ├── cli/ # CLI interface
│ │ ├── app.py # Main CLI application
│ │ ├── commands/ # Built-in commands
│ │ └── utils.py # TUI components (tabbed interface)
│ ├── core/
│ │ ├── agent.py # Main agent logic
│ │ ├── model.py # Model factory
│ │ └── middleware/ # Agent middleware
│ ├── config/ # Configuration management
│ └── bus/ # Message bus for async communication
├── tests/ # Test suite
├── pyproject.toml # Project metadata
└── README.md
# Run all tests
pytest
# Run with coverage
pytest --cov=deepcodeThis project follows standard Python conventions with type hints.
-
Tabbed Question Interface (
deepcode/cli/utils.py):_present_user_questions()- Main TUI entry point- Full prompt_toolkit implementation with custom key bindings
- Rich markdown preview with syntax highlighting
-
Agent (
deepcode/core/agent.py):- LangGraph-based agent with LangChain integration
- Streaming responses with progress callbacks
- HITL (Human-in-the-Loop) support
-
Message Bus (
deepcode/bus/):- Async pub/sub for inbound/outbound messages
- Coordinates between CLI and agent
- langchain - Agent framework
- langgraph - Agent orchestration
- prompt_toolkit - Terminal UI framework
- rich - Rich text and formatting
- typer - CLI framework
- pydantic - Data validation
- loguru - Logging
- questionary - Interactive prompts
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
Built with:
- LangChain - AI agent framework
- prompt_toolkit - Terminal UI
- Rich - Terminal formatting