| Crates.io | sudo_ai |
| lib.rs | sudo_ai |
| version | 0.1.0 |
| created_at | 2025-05-07 19:41:16.458162+00 |
| updated_at | 2025-05-07 19:41:16.458162+00 |
| description | 'Rewrite' of sudo with AI |
| homepage | https://github.com/CestDiego/sudo-ai |
| repository | https://github.com/CestDiego/sudo-ai |
| max_upload_size | |
| id | 1664373 |
| size | 49,737 |
A command-line tool that uses AI to give you advice before you run a command with sudo.
sudo_ai acts as a wrapper around sudo. When you try to execute a command using sudo_ai, it first sends the command to an OpenAI model to get advice on whether the command is safe or appropriate to run with sudo privileges. It then presents this advice to you. If the AI advises to "ALLOW", you'll be prompted for final confirmation before the command is executed.
This tool aims to provide an extra layer of scrutiny for sudo commands, helping to prevent accidental or potentially harmful operations.
sudo commands.o4-mini).Once sudo_ai is published on crates.io, you can install it using cargo:
cargo install sudo_ai
Ensure that $HOME/.cargo/bin is in your system's PATH.
Simply prefix the command you intend to run with sudo with sudo_ai instead.
sudo_ai <your_command_and_arguments>
Example:
sudo_ai apt update && sudo_ai apt upgrade
# or
sudo_ai rm -rf /some/critical/path
sudo_ai your_command.sudo_ai sends your_command to the configured OpenAI model, asking if it should be allowed with sudo privileges.sudo_ai will ask for your confirmation (yes/no).sudo_ai then executes the original command using the actual sudo.sudo_ai is configured using environment variables:
OPENAI_API_KEY (Required): Your OpenAI API key.
The program will not run without this key.
export OPENAI_API_KEY="sk-your_openai_api_key"
OPENAI_MODEL (Optional): The OpenAI model to use for advice.
Defaults to o4-mini.
export OPENAI_MODEL="gpt-4-turbo"
OPENAI_BASE_URL (Optional): The base URL for the OpenAI API.
Defaults to https://api.openai.com/v1.
Useful if you are using a proxy or a compatible API endpoint. (Gemini, Claude, etc)
export OPENAI_BASE_URL="https://your-proxy-url/v1"
You can set these in your shell's configuration file (e.g., .bashrc, .zshrc) for them to persist across sessions.
This project is licensed under the MIT License - see the LICENSE file for details (though you'll need to create this file or refer to the one in Cargo.toml).
This is a J-O-K-E. Think leftpad in npm. But it does work.
sudo_ai provides advice generated by an AI model. This advice is for informational purposes only and should not be the sole basis for decisions with security implications. Always use your own judgment and understand the commands you are running with sudo. The developers of sudo_ai are not responsible for any misuse or damage caused by commands run through this tool.