API Reference¶
Main Modules¶
smart_shell.main: Entry point, CLI logic, interactive mode, and special commandssmart_shell.ai_wrapper: Handles AI model communication (Gemini)smart_shell.safety: Safety checks, command validation, and user confirmation logicsmart_shell.config: Configuration, API key management, and model selectionsmart_shell.shell_builder: Bash/Zsh command construction and banner displaysmart_shell.utils: Utility functions (execution, logging, sudo, OS detection)smart_shell.setup_logic: Setup and installation logic
Key Classes & Functions¶
ai_wrapper.py¶
get_wrapper(api_key): Returns an AIWrapper instance for GeminiAIWrapper.list_available_models(): List supported Gemini modelsAIWrapper.generate_command(prompt, model): Generate Bash/Zsh command from prompt
safety.py¶
check_command_safety(command): Returns safety analysis with status ("safe", "medium", "high", "info_leak") and detailed reason- Safety levels trigger appropriate confirmation prompts in the main application
config.py¶
load_config(): Loads config filesave_model(model): Saves selected modelget_current_model(): Gets current modelENV_API_KEY: Environment variable for API key
shell_builder.py¶
generate_command_plan(prompt, api_key, model, os_info): Returns a list of command(s) for a promptdisplay_banner(): Prints the Smart-Shell bannerBANNER: Banner string
utils.py¶
execute_command(command): Runs a shell command safelyprint_plan_preview(plan, safety_results): Shows command plan with safety analysisreset_sudo_password(): Clears cached sudo passwordlog_error(error): Logs errors to fileget_os_info(): Returns detailed OS informationdetect_shell(): Detects current shell (Bash or Zsh)validate_sudo_password(password): Validates sudo credentials
setup_logic.py¶
setup_config(): Runs interactive setup wizardsetup_api_key(config): Handles API key configuration with validationsetup_sudo_password(config): Handles sudo password setup with security warningsset_default_model(api_key, config): Interactive model selection during setup
Special Commands¶
The interactive mode supports various special commands:
!help: Show comprehensive help!history: Display command history!last: Show last generated command!redo: Re-execute last command!clear: Clear the screen!models: List available AI models!model <name>: Switch AI model!web: Toggle web search integration!update: Check for and install updates from GitHub!errors: Show error log!forget-sudo: Clear cached sudo password!creator: Show creator information!docs: Show documentation link
For more, see the source code and inline docstrings. All modules are designed for Bash and Zsh compatibility, and safety checks always prompt for confirmation on high-risk commands.