AI-powered CLI coding assistant with API
Project description
๐ฅ Flame - AI-Powered CLI Coding Assistant
An intelligent command-line interface (CLI) application that functions as an AI coding assistant directly in your terminal, powered by API.
โจ Features
- Interactive REPL: Continuous chat loop with full conversation context
- System Awareness: Automatically gathers context about your environment (OS, project structure, git status)
- Real-time Streaming: Responses stream into the terminal as they're generated
- Safe File Operations: Create and edit files with intelligent diff preview and approval prompts
- Command Execution: Suggest and safely execute terminal commands with user approval
- Dangerous Command Detection: Blocks potentially harmful commands while allowing safe ones
- Multi-turn Conversations: Maintains full chat history across sessions
๐ Quick Start
Prerequisites
- Python 3.10+
- A API key
- pip or poetry for dependency management
Installation
-
Install via pip (recommended to use a virtual environment):
pip install flamecli
-
Setup configuration:
# Interactively securely configure your API key and preferences flame --setup
Test Connection
Before running the REPL, verify your setup:
flame --check
Expected output:
๐ Testing connection to API...
โ
Connection successful!
Start the CLI
flame
You'll see:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฅ Flame - AI Coding Assistant โ
โ Powered by API โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Type 'help' for commands, 'exit' to quit
You: _
๐ฌ Usage Examples
Basic Chat
You: What does this code do?
[paste code]
๐ค Flame: This code does...
Get Project Context
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
View System Context
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
...
AI-Suggested File Creation
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
AI-Suggested Command Execution
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...
...
Clear History
You: clear
โ
Conversation history cleared
๐๏ธ Architecture
Directory Structure
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)
Component Interaction
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ main.py (Entry Point) โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REPL (cli/repl.py) โ
โ โโ Interactive loop โ
โ โโ Message history โ
โ โโ Command handling โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโดโโโโโโโฌโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ
โHackClubAI API โ โFileExecutor โ โCommandExecutor
โ(api/client.py) โ โ(executor.py)โ โ(executor.py)
โ โ โ โ โ
โโข Streaming โ โโข Safe file โ โโข Command checks
โโข Non-streaming โ โ ops โ โโข Approval prompts
โโข Error handling โ โโข Diffs โ โโข History
โโโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ
SystemContext
(utils/context.py)
โโ OS info
โโ Git status
โโ Project structure
โโ File summary
๐ Security Features
File Operations Security
- 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
Command Execution Security
-
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
API Key Security
- Store in
.envfile (add to.gitignoreautomatically) - Never commit
.envto version control - Use environment variables in production
- Supports
.env.examplefor template sharing
๐ Configuration
Environment Variables
Create a .env file from .env.example:
# Required: Your API key
FLAME_API_KEY=hf_xxxxxxxxxxxxx
# Optional: API endpoint (usually pre-configured)
FLAME_API_BASE_URL=https://api.example.com/proxy/v1
# Optional: AI model to use
FLAME_MODEL=qwen/qwen3-32b
# Optional: CLI settings
CLI_THEME=dark
DEBUG=false
๐ฎ CLI Options
python 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 mode
๐ Troubleshooting
Connection Failed
Error: 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
Import Errors
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 .
Command Won't Execute
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
๐ Advanced Usage
Using with Different Models
# Override model at runtime
python main.py --model llama2
# Or set in .env:
FLAME_MODEL=llama2
Using Different Working Directory
# Analyze a different project
python main.py --dir /path/to/other/project
Debug Mode
# See detailed error messages
python main.py --debug
๐ง Development
Running Tests
pytest tests/
Code Style
# Format code
black api/ cli/ utils/ main.py
# Lint
flake8 api/ cli/ utils/ main.py
๐ License
MIT License - feel free to use and modify!
๐ค Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
๐ Support
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file flamecli-0.1.6.tar.gz.
File metadata
- Download URL: flamecli-0.1.6.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18919e4d09d1419e7b381f9d35f97618911c2d9d278b4b72bc5aafddfffd6de9
|
|
| MD5 |
3157091efe14f219e4271c67195cdcac
|
|
| BLAKE2b-256 |
7dcd8168a3767975ad0fa03ec358153db5461aebadf2eaa35fe6e84ffd4f448d
|
File details
Details for the file flamecli-0.1.6-py3-none-any.whl.
File metadata
- Download URL: flamecli-0.1.6-py3-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64ef9f3957d07c77e07f96a3f78b197196dcdf679a9421ae455e356885a05b77
|
|
| MD5 |
da41ed00f0fe7f03e2cb9f1b12b93372
|
|
| BLAKE2b-256 |
b69ffe0f0705a8e6a4cc23a6403b8c1b612605d289cd57b44ed4fdbb03d0a452
|