This is a custom terminal application built in Python that combines traditional command-line functionality with a powerful natural language interface. Instead of just typing commands, users can describe what they want to do in plain English, and the terminal will translate the request into the correct command, execute it, and provide the result.
The project was developed as a submission for the Gemini API Challenge, showcasing the ability to integrate advanced AI capabilities into a practical, real-world application.
- Natural Language Processing (NLP): Translate conversational commands into a list of executable terminal commands.
- Dynamic Command Execution: A robust system that maps natural language queries to supported file system and system monitoring commands.
- File System Commands: Includes
ls
,cd
,pwd
,mkdir
,rm
,mv
,touch
, andecho
for file and directory management. - System Monitoring: Commands like
cpu
,mem
, andps
to check system performance. - Robust Error Handling: The system is designed to handle common issues like invalid API responses and missing commands gracefully.
git clone [https://github.com/your-username/your-project-repo.git](https://github.com/your-username/your-project-repo.git)
cd your-project-repo
Install the necessary Python packages using pip
.
pip install -r requirements.txt
Note: Make sure your requirements.txt
file includes google-generativeai
, colorama
, and psutil
.
You must set your Gemini API key as an environment variable to allow the application to access the AI.
On Windows:
setx GEMINI_API_KEY "YOUR_API_KEY"
On macOS/Linux:
export GEMINI_API_KEY="YOUR_API_KEY"
After setting the variable, you must restart your terminal for the changes to take effect.
To start the terminal, run the main.py
script from your project's root directory:
python main.py
You can then enter both traditional terminal commands and natural language queries.
Examples:
- Traditional Command:
ls
- Natural Language Query:
create a new folder called projects
- Complex Query:
create a text file named notes.txt in the documents folder and add the text "initial notes" to it
This project presented several real-world debugging challenges that were successfully overcome:
- Environment Variable Issues: Initial setup was blocked by the
ValueError
for theGEMINI_API_KEY
. This was resolved by correctly setting and verifying the environment variable. - API Integration & Parsing: The Gemini API sometimes returned non-JSON data (e.g., Markdown blocks), causing a
JSONDecodeError
. This was fixed by implementing a custom fallback parser to extract the commands. - Command Handling: Several commands, like
touch
andecho
, were not initially supported. These were added and registered in the command map. Theecho
command required a robust parser to handle quoted strings and redirection symbols (>
), which was addressed by updating the core parsing logic.
This iterative debugging process was a core part of the project's development and is a testament to the code's resilience.