Skip to main content

An AI-powered PowerShell assistant that converts natural language into PowerShell commands using Gemini and LangChain.

Project description

๐Ÿค– 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.

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

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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page