AITerm is an AI-powered terminal command assistant that converts natural language descriptions into shell commands. It features an intelligent two-step process: first determining if context is needed, then generating appropriate command suggestions.
- Natural language to shell command translation
- Multi-model support (OpenAI, Anthropic, Ollama)
- Intelligent context gathering before command generation
- Structured XML-based prompting system
- JSON-formatted responses for consistency
- Model-specific configuration and instructions
- Interactive command selection with rich TUI
- Non-interactive mode for automation
- Test mode for development
Add to your flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
aiterm.url = "github:0kenx/aiterm";
};
outputs = { self, nixpkgs, aiterm, ... }: {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
modules = [
({ pkgs, ... }: {
environment.systemPackages = [
aiterm.packages.${pkgs.system}.default
];
})
];
};
};
}Or use the provided NixOS module:
{
modules = [
aiterm.nixosModules.default
{
programs.aiterm = {
enable = true;
defaultConfig = {
default_model = "gpt-4o";
enforce_json_output = true;
};
};
}
];
}# Run without installing
nix run github:0kenx/aiterm -- list python files
# Install to user profile
nix profile install github:0kenx/aitermAdd to your Home Manager configuration:
{ config, pkgs, ... }:
{
home.packages = [
(pkgs.callPackage (builtins.fetchTarball {
url = "https://github.com/0kenx/aiterm/archive/main.tar.gz";
}) {})
];
# Optional: manage aiterm config with Home Manager
xdg.configFile."aiterm/config.yaml".text = ''
enforce_json_output: true
default_model: gpt-4o
providers:
openai:
api_key: ''${OPENAI_API_KEY}
anthropic:
api_key: ''${ANTHROPIC_API_KEY}
models:
gpt-4o:
provider: openai
model: gpt-4o
include_path_commands: true
'';
}Or using flakes in Home Manager:
{
inputs = {
home-manager.url = "github:nix-community/home-manager";
aiterm.url = "github:0kenx/aiterm";
};
outputs = { self, home-manager, aiterm, ... }: {
homeConfigurations.myuser = home-manager.lib.homeManagerConfiguration {
modules = [
({ pkgs, ... }: {
home.packages = [
aiterm.packages.${pkgs.system}.default
];
})
];
};
};
}# Clone the repository
git clone https://github.com/0kenx/aiterm
cd aiterm
# Run directly with uv
uv run ait list all python filespip install .
ait list all python files# Use default model
ait find large files over 100MB
# Specify a model
ait -m gpt-4o list docker containers
ait -m claude-3.7 show system resources
ait -m ollama compress this directory
# Use test mode (no API required)
ait -m test show network connections# Pipe input
echo "list all python files" | ait
# Use in scripts
ait --no-interactive find files modified todayAITerm uses a YAML configuration file located at ~/.config/aiterm/config.yaml (or config.yaml in the local directory).
# Enable strict JSON responses
enforce_json_output: true
# Default model to use
default_model: gpt-4o
# Provider configurations
providers:
openai:
api_key: ${OPENAI_API_KEY} # Environment variable
anthropic:
api_key: ${ANTHROPIC_API_KEY}
ollama:
base_url: http://localhost:11434
# Model configurations
models:
gpt-4o:
provider: openai
model: gpt-4o
instructions: |
You are a terminal command expert. Focus on practical solutions.
include_path_commands: true
include_history_context: true
claude-3.7:
provider: anthropic
model: claude-3-7-sonnet-20250122
instructions: |
Provide clear and efficient command suggestions.
ollama:
provider: ollama
model: llama3.1
test:
provider: test
model: testEach model can have custom instructions that guide its behavior:
models:
gpt-4o:
provider: openai
model: gpt-4o
instructions: |
Focus on modern best practices.
Prefer using newer command options when available.
Always consider cross-platform compatibility.-
Config System (
config.py)- Manages providers and models
- Handles environment variable substitution
- Supports layered configuration
-
Prompt Builder (
prompt_builder.py)- Creates structured XML prompts
- Enforces JSON response format
- Handles context injection
-
LLM Adapters (
llm/)- Base adapter with async support
- Provider-specific implementations
- Test adapter for development
-
Context Gathering (
context_gather.py)- PATH command collection
- Shell history analysis
- Smart context filtering
-
Command Executor (
executor.py)- Safe command execution
- Timeout handling
- Result formatting
# Run all tests
uv run python tests/test_simple.py
# Run specific test
uv run tests/test_adapters.pyThe test mode provides mock responses for development:
ait -m test list all python filesaiterm/
├── src/
│ └── aiterm/
│ ├── config.py # Configuration management
│ ├── context_gather.py # Context collection
│ ├── executor.py # Command execution
│ ├── llm/ # LLM adapters
│ │ ├── base.py
│ │ ├── openai.py
│ │ ├── anthropic.py
│ │ ├── ollama.py
│ │ └── test.py
│ ├── main.py # Main entry point
│ ├── prompt_builder.py # Prompt construction
│ └── tui.py # Terminal UI
├── tests/ # Test suite
├── README.md
└── pyproject.toml
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT