An intelligent command-line interface (CLI) application that functions as an AI coding assistant directly in your terminal, powered by your choice of API.
- Interactive REPL: Continuous chat loop with full conversation context.
- System Awareness: Automatically gathers context about your environment (OS, project structure, git status, etc.).
- Global Configuration: Persistent settings (API key, model, etc.) stored globally in
~/.flame/.env. - Real-time Streaming: Responses stream directly into your terminal for a responsive experience.
- Safe File Operations: Create and edit files with intelligent diff previews and explicit user approval.
- Terminal Execution: Command suggestions that you can execute safely with a single keypress.
- Security First: Dangerous command detection and path validation protect your system.
- Multi-turn Logic: Full chat history maintenance for complex workflow handling.
- Python 3.10+
- A API key
- pip or poetry for dependency management
-
Install via pip:
pip install flamecli
-
Setup configuration:
# Run the interactive setup to configure your API key, base URL, and model. # This will save your settings globally in ~/.flame/.env flame --setup
Before running the REPL, verify your setup:
flame --checkExpected output:
๐ Testing connection to API...
โ
Connection successful!
flameHappy coding! ๐ฅ
You: What does this code do?
[paste code]
๐ค Flame: This code does...
You: help
Available Commands:
help - Show this help message
context - Show current system context
clear - Clear conversation history
exit - Exit the program
/run <cmd> - Suggest running a command (AI-aware)
/edit <file> - Suggest editing a file
/create <file> - Suggest creating a file
You: context
๐ System Context:
๐ Working Directory: /path/to/project
๐ฅ๏ธ System: Linux 6.1.0 | Python 3.11.0
๐ฟ Git Status: On branch main
๐ Project Structure:
project-name/
โโโ main.py
โโโ utils/
โโโ ...
๐ File Summary:
Total files: 24
.py: 12
.md: 3
...
You: Create a requirements.txt with common Python packages
๐ค Flame: I'll create a requirements.txt with popular packages...
๐ Create File: requirements.txt
Suggested by AI assistant
Preview:
requests>=2.28.0
python-dotenv>=0.20.0
rich>=13.0.0
...
โ
Create this file? [y/n]: y
โ
File created: requirements.txt
You: How do I install the dependencies?
๐ค Flame: You can run pip install...
๐ง Run Command:
Suggested by AI assistant
Command:
pip install -r requirements.txt
โ
Execute this command? [y/n]: y
โ
Command executed successfully
Output:
Collecting requests...
...
You: clear
โ
Conversation history cleared
flame/
โโโ api/
โ โโโ __init__.py
โ โโโ client.py # API wrapper
โโโ cli/
โ โโโ __init__.py
โ โโโ repl.py # Interactive REPL loop
โ โโโ executor.py # File and command execution
โโโ utils/
โ โโโ __init__.py
โ โโโ context.py # System context collector
โโโ main.py # Entry point
โโโ pyproject.toml # Project configuration
โโโ .env.example # Environment template
โโโ .env # Your configuration (gitignored)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ main.py (Entry Point) โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REPL (cli/repl.py) โ
โ โโ Interactive loop โ
โ โโ Message history โ
โ โโ Command handling โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโดโโโโโโโฌโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ
โ API โ โFileExecutor โ โCommandExecutor
โ Client โ โ(executor.py)โ โ(executor.py)
โ โ โ โ โ
โโข Stream โ โโข Safe file โ โโข Command checks
โโข Validateโ โ ops โ โโข Approval prompts
โโข Async โ โโข Diffs โ โโข History
โโโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ
SystemContext
(utils/context.py)
โโ OS info
โโ Git status
โโ Project structure
โโ File summary
- Path Validation: All file paths are validated to stay within the project directory
- Diff Preview: Before writing, users see exactly what changes will be made
- User Approval: Every file creation/edit requires explicit user confirmation
- Safe by Default: Operations are blocked if path escapes project root
-
Dangerous Pattern Detection: Blocks commands matching risky patterns:
rm -rf /(recursive root deletion)sudo(privilege escalation)dd(disk operations)mkfs(filesystem formatting)- Fork bombs
-
User Approval: Every command execution requires explicit confirmation
-
Timeout Protection: Commands are forcibly terminated after 30 seconds
-
Error Reporting: Command failures are clearly reported
- Store in
.envfile (add to.gitignoreautomatically) - Never commit
.envto version control - Use environment variables in production
- Supports
.env.examplefor template sharing
Flame uses a .env file for configuration. The --setup command handles this for you, but you can also manually edit the file at ~/.flame/.env.
# Required: Your API key
FLAME_API_KEY=your_key_here
# Optional: API endpoint (defaults to a standard proxy)
FLAME_API_BASE_URL=https://api.example.com/v1
# AI model to use
FLAME_MODEL=google/gemini-3-flash-preview
# CLI settings
CLI_THEME=dark
CLI_STREAM_SPEED=normal
DEBUG=falsepython main.py --help
usage: main.py [-h] [--version] [--check] [--dir DIR] [--model MODEL] [--debug]
Flame - AI Coding Assistant powered by API
options:
-h, --help show this help message and exit
--version show program's version number and exit
--check Test connection to API
--setup Interactive setup to configure your API key and settings
--dir DIR Working directory (defaults to current directory)
--model MODEL AI model to use (overrides FLAME_MODEL env var)
--debug Enable debug modeError: Connection failed. Check your API key and network.
Solutions:
- Verify API key is correct in
.env - Check internet connection
- Verify API base URL is correct
- Test with:
python main.py --check --debug
Error: ModuleNotFoundError: No module named 'api'
Solutions:
- Ensure you're in the project root directory
- Virtual environment is activated
- Dependencies are installed:
pip install -e .
Error: Dangerous Command Detected
Solutions:
- Command matches safety patterns (by design)
- Use
--debugto see pattern matching - Use safer alternative commands
- File path must be within project directory
# Override model at runtime
python main.py --model llama2
# Or set in .env:
FLAME_MODEL=llama2# Analyze a different project
python main.py --dir /path/to/other/project# See detailed error messages
python main.py --debugpytest tests/# Format code
black api/ cli/ utils/ main.py
# Lint
flake8 api/ cli/ utils/ main.pyMIT License - feel free to use and modify!
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
Need help? Try:
- Check
.envconfiguration - Run
python main.py --checkto verify setup - Use
--debugflag for detailed error messages - Review this README for common issues
Made with ๐ฅ by API Community