Purpose
SmallShell is a Linux shell integrated with an LLM to enable users to perform system tasks via natural language. It eliminates the need to memorize Linux commands by translating queries into commands, executing them securely, and presenting results in human-readable formats.
Scope
- Natural language processing (NLP) for command generation.
- Secure command execution with user consent.
- Translation of command outputs into user-friendly summaries.
- Configurable settings and history tracking.
SmallShell comprises five modules:
- User Interface (UI)
- Natural Language Processing (NLP) Engine
- Command Execution Manager
- Result Translation Module
- Configuration & History Module
- CLI Prompt:
SmallShell>for input. - Commands:
exit: Terminate the shell.history: View past commands/results.config: Modify settings.
- LLM Integration: Use OpenAI API or a local model (e.g., Llama 2) to convert queries to commands.
- Caching: Store frequent queries to reduce API calls.
- Security: Mask sensitive data (e.g., passwords) before sending to external APIs.
- Permission Workflow:
user_query = "how big is my hard drive?" generated_command = "df -h /" print(f"Generated command: {generated_command}\nExecute? [y/N]")
- Execution: Use
subprocess.run()with timeouts and error handling.
- Convert technical outputs (e.g.,
df -h) into summaries (e.g., "Your hard drive is 75% full"). - Leverage LLM for output interpretation.
- Config File: YAML-based settings (e.g., default LLM, auto-execute).
- History: SQLite database storing queries, commands, and results.
- Python 3.8+ with libraries:
argparse(CLI parsing),requests(API calls),pyyaml(config).sqlite3(history),subprocess(command execution).
- LLM: OpenAI API or DeepSeek with Ollama for local models.
- Input Sanitization: Prevent command injection via regex checks.
- Local Model Option: Avoid external API dependencies for sensitive environments.
- Allow List Commands: Only commands in the allow list can be executed by the shell.
- Accuracy: Test LLM-generated commands against common queries (e.g.,
dffor disk usage). - Latency: Cache frequent queries and use lightweight local models.
- Safety: Always prompt before executing commands like
rmorchmod.
- Multi-Step Queries: Support chained commands (e.g., "Compress logs older than 7 days").
- Plugin System: Allow custom command templates.
- User Feedback: Improve LLM accuracy by letting users correct commands.
- Unit Tests: Validate command generation, execution, and result translation.
- Integration Tests: End-to-end workflow (e.g., "What’s my CPU usage?" →
mpstat→ summary). - User Testing: Gather feedback on usability and edge cases.
- Phase 1 (Research): 2 weeks (LLM selection, architecture).
- Phase 2 (Core Development): 3 weeks (UI, execution manager).
- Phase 3 (NLP Integration): 3 weeks (LLM API/local model).
- Phase 4 (Testing): 2 weeks.
- Phase 5 (Deployment): 1 week (Packaging, docs).
SmallShell bridges the gap between natural language and Linux commands, prioritizing security and usability. Future iterations will expand functionality while maintaining robust error handling and user control.
Documentation: Include setup guides, examples, and security best practices.
License: Open-source (MIT License).