Hamster
Hamster is a lightweight, high-performance Command Line Interface (CLI) software engineering agent. Utilizing the OpenRouter API framework, Hamster drafts changes in an isolated temporary sandbox, presenting rich terminal previews and allowing you to accept or discard all changes at the end of each task.
🌟 Key Features
- Isolated Draft Workspace: All reads, writes, and command executions target a temporary sandbox (
/tmp/hamster-sandbox-<uuid>/). The real project directory is touched only when you explicitly approve changes at task completion. - Cross-Platform Compatibility: Fully compatible with macOS, Linux, and Windows (CMD, PowerShell, Git Bash, WSL2).
- APFS Fast-Cloning: On macOS, utilizes APFS copy-on-write (
cp -c) for instant (<10ms) sandbox instantiation without physically duplicating file contents. - Ephemeral Docker Sandbox Backend: Command execution delegates to an ephemeral, network-isolated Docker container (
--network=none,--memory=256m,--cpus=1) when Docker is present, falling back seamlessly to host process execution. - Two-Stage Planning → Execution Engine: Automatically detects structured planning responses from the model and injects an execution prompt before invoking tools.
- Persistent LSP Integration: Integrates a persistent JSON-RPC 2.0 language server daemon (
pyright-langserver) for real-time code diagnostics and definition resolution. - Windowed File Reading & Fuzzy Patching: Supports line-range slicing (
start_line,end_line) for reading large files, and trailing-whitespace-tolerant fuzzy diff matching for edits. - Token Budget Context Compactor: Built-in context compaction using
tiktokenBPE token estimation (cl100k_base) to maximize context retention without overflowing model limits. - Strict Security Policy: Path containment checks prevent sandbox escaping, combined with regex command filtering and strict binary allowlists (
git,python,pytest,npm, etc.).
🛠️ Tooling Overview
Hamster exposes six permission-gated tools to the AI model:
| Tool | Description |
|---|---|
search_codebase(query) |
Conducts fast string searches across the sandbox workspace using ripgrep (rg). |
read_file(filepath, start_line, end_line) |
Safely reads project files by relative path with optional line-range slicing. |
edit_file_patch(filepath, target_text, replacement_text) |
Performs surgical replacements in file text (with exact and fuzzy whitespace-tolerant matching). |
write_file(filepath, content) |
Creates or overwrites a draft file, automatically scaffolding parent directories. |
web_search(query) |
Permission-gated DuckDuckGo search for technical documentation, APIs, and syntax lookup. |
run_sandbox_command(command) |
Executes pre-filtered shell commands in an isolated container or sandboxed environment. |
💻 Cross-Platform Prerequisites
Hamster requires Python 3.11+ and ripgrep (rg) on system PATH.
macOS
brew install ripgrep
Linux (Ubuntu/Debian)
sudo apt update && sudo apt install ripgrep
Windows
winget install BurntSushi.ripgrep.MSVC
# Or via Chocolatey: choco install ripgrep
🚀 Setup & Installation
Install Hamster globally using uv (recommended) or pip:
uv tool install hamster-agent
# OR
pip install hamster-agent
⚙️ Configuration
Set up your OpenRouter API key using the built-in command:
hamster set-key your_openrouter_api_key_here
You can optionally log in with Google to enable advanced features:
hamster login
🎮 Usage & Available Commands
Start the interactive CLI:
hamster
Interactive CLI Commands
| Command | Description |
|---|---|
/help |
Show the command guide and tooling overview. |
/version |
Show Hamster version, model, and Python info. |
/files |
List files in the current draft. |
/search <query> |
Ask Hamster to search technical documentation. |
/pending |
Show pending draft changes. |
/apply |
Save pending draft changes to disk. |
/sync |
Refresh draft state from disk. |
/undo [N] |
Revert workspace N turns (default 1), keeps conversation log. |
/set-key <key> |
Set or rotate the OpenRouter API key. |
/login |
Log in with Google (OAuth 2.0 PKCE flow). |
/whoami |
Show the currently logged-in user. |
/logout |
Clear saved Google credentials. |
/clear |
Clear the terminal and redraw the splash. |
/exit |
Leave Hamster (prints farewell graphic). |
🛡️ Security Measures
Hamster implements strict defense-in-depth security:
- Path Canonicalization: Resolves relative paths against the active sandbox root using
os.path.realpath, rejecting any breakout attempts (../../.env). - Binary Allowlisting & Command Filtering: Blocks dangerous commands (
sudo,rm,chmod,chown, curl-to-shell pipes) while validating commands against an allowed binary matrix. - 3-Way Conflict Detection: Prevents overwriting external host edits when applying drafted changes.
🧪 Running Tests
Hamster includes a full unit test suite covering sandbox lifecycle, isolation, fuzzy patching, and policy analysis:
uv run python -m unittest discover tests
📄 License
MIT License. See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hamster_agent-0.1.0.tar.gz.
File metadata
- Download URL: hamster_agent-0.1.0.tar.gz
- Upload date:
- Size: 72.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4524dcb27e387db562c0ecedcb95a17405d5597401059e489680e0a9b98cfbb
|
|
| MD5 |
041251c8ff21856fc91667f615149cab
|
|
| BLAKE2b-256 |
b271977964f8e820f0b81a673899c7d8d4dcbace1cad7c05846ab4787dd31f20
|
File details
Details for the file hamster_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hamster_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 86.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b74f45f17984d8f00dea88abf778d0e3947604098b08ff69d943686f6cdf6c1
|
|
| MD5 |
9dbc2a89e2bc8c94b9107552a09ea7f1
|
|
| BLAKE2b-256 |
20900087f203812b5f74677a5a6d60275ec35a46954bfd394119d1ea0ba83332
|