Skip to main content

🤖 AI Shell Agent

An AI-powered command-line assistant that converts natural language into Windows PowerShell commands using Google Gemini and LangChain. Before executing any command, the agent validates it and asks for user confirmation to ensure safe execution.


✨ Features

  • 🤖 Natural language to PowerShell command generation
  • 🧠 Powered by Google Gemini using LangChain
  • 🛡️ Command validation before execution
  • ✅ User confirmation before running commands
  • ⚡ Automatic PowerShell command execution
  • 💻 Interactive command-line interface
  • 🪟 Designed for Windows PowerShell

🏗️ Project Architecture

User Input
     │
     ▼
 AI Shell Agent
     │
     ▼
 LangChain + Gemini
     │
     ▼
 PowerShell Command
     │
     ▼
 Command Validator
     │
     ▼
 User Confirmation
     │
     ▼
 Command Executor
     │
     ▼
 Windows PowerShell

📂 Project Structure

ai-shell-agent/
│
├── app/
│   ├── __init__.py
│   ├── main.py
│   ├── agent.py
│   ├── llm.py
│   ├── validator.py
│   ├── executor.py
│   └── prompts.py
│
├── README.md
├── LICENSE
├── pyproject.toml
├── .env.example
└── .gitignore

⚙️ Tech Stack

  • Python 3.11+
  • LangChain
  • Google Gemini API
  • python-dotenv
  • subprocess (Python Standard Library)
  • PowerShell

🚀 Installation

Clone the repository:

git clone https://github.com/Nishtha-06/ai-shell-agent
cd ai-shell-agent

Install dependencies using uv:

uv sync

or using pip:

pip install -e .

🔑 Environment Variables

Create a .env file in the project root.

GEMINI_API_KEY=your_gemini_api_key

You can get an API key from:

https://aistudio.google.com/app/apikey


▶️ Running the Agent

Run the application:

ai-shell

or

python -m app.main

💬 Example

You > Create a folder named Project

Generated Command:
mkdir Project

Execute this command? (y/n): y

Command executed successfully.

🔄 Workflow

Natural Language
        │
        ▼
Gemini (LangChain)
        │
        ▼
PowerShell Command
        │
        ▼
Validator
        │
        ▼
Confirmation
        │
        ▼
Executor
        │
        ▼
PowerShell

🛡️ Safety

Before executing any generated command, the agent:

  • Validates the generated PowerShell command
  • Blocks potentially unsafe commands (based on validator rules)
  • Requests user confirmation before execution

This helps prevent accidental execution of harmful commands.


📌 Current Limitations

  • Supports Windows PowerShell only
  • Requires a Google Gemini API key
  • Executes one command at a time
  • Does not maintain conversation memory between commands

🚀 Future Improvements

  • Conversation memory
  • LangGraph integration
  • Tool calling
  • Command history
  • Plugin support
  • Persistent shell session
  • Linux and macOS support
  • Rich terminal interface

👩‍💻 Author

Nishtha Modi


📄 License

This project is licensed under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nishtha_ai_shell_agent-1.0.0.tar.gz (92.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nishtha_ai_shell_agent-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file nishtha_ai_shell_agent-1.0.0.tar.gz.

File metadata

  • Download URL: nishtha_ai_shell_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 92.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nishtha_ai_shell_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 031bb93107bd9bb563bf6d900b42029faba3616d59f580ffb8a70ff5a46a5d58
MD5 5663d721f95f44b93993e992a10c887c
BLAKE2b-256 53ee73ca1c340e972443167d70f866b768f5a6b1753baff02f1876ef05fbf107

See more details on using hashes here.

File details

Details for the file nishtha_ai_shell_agent-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: nishtha_ai_shell_agent-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nishtha_ai_shell_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d682ee53bd25855e95ff029166a0542d0eb310e6e68bdcc462096f875447499d
MD5 372ecf2eae207f8ecdb10fef0b7f3386
BLAKE2b-256 b9548a19b7ad111437de57e16a7c1d9f418cb4bc7b729e405670eddad2aec38f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page