AI agent for multi-provider integration, command execution, and MCP protocol support with SQLite storage.
Harper provides a unified interface to multiple AI providers (OpenAI, Sambanova, Gemini) with persistent chat sessions, command execution capabilities, and Model Context Protocol (MCP) support.
- Rust: 1.82.0 or later (install Rust)
- Operating System: Linux, macOS, or Windows
- Database: SQLite3 (included with most systems)
- Network: Internet connectivity for AI provider APIs
- Memory: 512MB RAM minimum, 1GB recommended
-
Install Rust (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env
-
Clone and build:
git clone https://github.com/harpertoken/harper.git cd harper cargo build --release -
Configure environment:
cp config/env.example .env # Edit .env with your API keys (see Configuration section below) -
Run Harper:
cargo run --release
Harper provides pre-built Docker images for easy deployment.
# Clone the repository
git clone https://github.com/harpertoken/harper.git
cd harper
# Copy and configure environment
cp config/env.example .env
# Edit .env with your API keys
# Build and run
docker build -t harper .
docker run --rm -it --env-file .env -v harper_data:/app/data harperNote: Docker builds are validated in CI via GitHub Actions. For detailed Docker instructions, see docker/DOCKER.md.
Harper includes a comprehensive test suite covering unit tests, integration tests, security, and performance benchmarks.
To run all tests, use the provided script:
./harpertestThis executes:
- Unit tests: Core functionality tests
- Integration tests: End-to-end API and database tests
- Error handling tests: Failure scenario validation
- Security tests: Input validation and encryption
- Performance benchmarks: Response time measurements
Running all tests and benchmarks...
=================================
Running unit tests...
...
Running integration tests...
...
Running error handling tests...
...
Running security tests...
...
Running performance benchmarks...
...
All tests completed successfully!
=================================
The test suite includes:
- 12 unit tests - Core component functionality
- 10 integration tests - Full system workflows
- 6 error handling tests - Edge cases and failures
- 3 security tests - Encryption and validation
- Performance benchmarks - Speed and efficiency metrics
# Run specific test types
cargo test --lib # Unit tests only
cargo test --test integration_test # Integration tests
cargo test --test session_service_test # Session service tests
# Run with verbose output
cargo test -- --nocapture
# Run specific test
cargo test test_nameInstall from Release
# Check latest release at https://github.com/harpertoken/harper/releases
cargo install --git https://github.com/harpertoken/harper.git --tag <latest-tag>CI/CD
Harper uses GitHub Actions for automated testing and deployment:
- CI: Comprehensive testing, linting, and security audits
- Docker: Builds, tests, and publishes Docker images
- Title Checks: Validates commit messages and PR titles
- Release Drafter: Generates changelogs and draft releases
- Release: Automated cross-platform binary builds and publishing
Workflows run on pushes and pull requests. See .github/workflows/ for details.
This project uses conventional commit standards to ensure consistent and meaningful commit messages.
To enable commit message validation:
cp scripts/commit-msg .git/hooks/commit-msg
chmod +x .git/hooks/commit-msgCommit messages must follow the format: type(scope): description
- Type: feat, fix, docs, style, refactor, test, chore, perf, ci, build, revert
- Scope: Optional, e.g., (api), (ui)
- Description: Lowercase, ≤60 characters
Examples:
feat: add user authenticationfix(ui): resolve button alignment issuedocs: update installation instructions
To rewrite existing commit messages in the history:
git filter-branch --msg-filter 'bash scripts/rewrite_msg.sh' -- --all
git push --force-with-leaseThis will lowercase and truncate first lines to 60 characters.
After installation, run Harper and follow the interactive menu:
cargo run --release
# or
docker run --rm -it --env-file .env harperHarper will display the configured AI provider and present a text-based menu for:
- Starting new chat sessions
- Managing conversation history
- Exporting sessions
- Running commands
Harper runs in interactive mode by default, providing a menu-driven interface:
🤖 Using OpenAI - gpt-4-turbo
📍 API: https://api.openai.com/v1/chat/completions
đź’ľ Database: ./chat_sessions.db
1. Start new chat session
2. List previous sessions
3. View a session's history
4. Export a session's history
5. Quit
Enter choice:
Within chat sessions, you can use special commands:
[SEARCH: query] # Web search functionality
[RUN_COMMAND command] # Execute system commands
[TOOL: name] { "param": "value" } # Use MCP tools
Harper supports multiple AI providers with automatic model selection:
| Provider | Model | Capabilities | Status |
|---|---|---|---|
| OpenAI | GPT-4 Turbo | Text generation, coding, analysis | âś… Production |
| Sambanova | Meta-Llama-3.2-1B-Instruct | Open-source LLM, cost-effective | âś… Production |
| Gemini | Gemini 2.0 Flash | Multimodal processing, fast responses | âś… Production |
- Multi-Provider AI Integration: Seamless switching between AI providers
- Command Execution: Safe execution of system commands with output capture
- Web Search: Integrated search capabilities for real-time information
- Persistent Sessions: SQLite-based conversation history with full export
- Interactive CLI: User-friendly text-based interface
- Session Management: List, view, and export chat histories
- CodeQL Security Scanning: Automated vulnerability detection
- DevSkim Analysis: Security-focused code review
- Dependency Auditing: Regular security updates
- AES-GCM Encryption: Secure data storage and transmission
- Input Validation: Comprehensive request sanitization
- Error Handling: Robust failure recovery and logging
Status: Temporarily disabled in v0.1.3+ due to dependency conflicts.
When re-enabled, MCP provides:
- Tool integration capabilities
- External service connections
- Extended functionality through plugins
[mcp]
enabled = true
server_url = "http://localhost:5000"- SQLite Storage: Lightweight, file-based database
- Local Credentials: No external account requirements
- Session Persistence: Automatic conversation saving
- Export Functionality: JSON/CSV export of chat histories
- Backup Support: Easy data migration and recovery
| Command | Description |
|---|---|
cargo build --release |
Optimized release build |
cargo run --release |
Run the release binary |
cargo test |
Execute test suite |
cargo clippy |
Run linting and static analysis |
cargo fmt -- --check |
Check code formatting |
cargo doc |
Generate documentation |
cargo clean |
Remove build artifacts |
# Full development cycle
cargo fmt # Format code
cargo clippy # Lint code
cargo test # Run tests
cargo build --release # Build optimized binary
cargo run --release # Run applicationHarper can be built for multiple platforms:
# Linux (x86_64)
cargo build --release --target x86_64-unknown-linux-gnu
# Windows (x86_64)
cargo build --release --target x86_64-pc-windows-msvc
# macOS Intel
cargo build --release --target x86_64-apple-darwin
# macOS Apple Silicon
cargo build --release --target aarch64-apple-darwinFor maximum performance in production:
# Enable Link Time Optimization (LTO)
cargo build --release --config profile.release.lto=true
# Use specific optimization level
cargo build --release --config profile.release.opt-level=3Harper uses environment variables for configuration. Set one of the following API keys:
# Choose your AI provider
export OPENAI_API_KEY="your-openai-key"
# OR
export SAMBASTUDIO_API_KEY="your-sambanova-key"
# OR
export GEMINI_API_KEY="your-gemini-key"
# Optional: Custom database location
export DATABASE_PATH="./harper.db"Harper automatically selects the appropriate model based on your API key:
| Environment Variable | Provider | Model | Base URL |
|---|---|---|---|
OPENAI_API_KEY |
OpenAI | gpt-4-turbo |
https://api.openai.com/v1/chat/completions |
SAMBASTUDIO_API_KEY |
Sambanova | Llama-4-Maverick-17B-128E-Instruct |
https://api.sambanova.ai/v1/chat/completions |
GEMINI_API_KEY |
Gemini | gemini-2.0-flash-exp |
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent |
For advanced configuration, edit config/local.toml:
[api]
provider = "OpenAI" # OpenAI, Sambanova, or Gemini
api_key = "your_api_key_here"
base_url = "https://api.openai.com/v1/chat/completions"
model_name = "gpt-4-turbo"
[database]
path = "./harper.db"
[mcp]
enabled = false
server_url = "http://localhost:5000"- Environment variables (highest priority)
config/local.toml(overrides defaults)config/default.toml(fallback defaults)
Harper implements multiple layers of security to protect your data and ensure safe operation:
- Local Storage Only: All data stored locally in SQLite database
- No External Transmission: Conversations never leave your device
- Environment-Based Credentials: API keys stored in environment variables
- AES-GCM-256 Encryption: Secure encryption for sensitive data
- CodeQL Scanning: Automated vulnerability detection in CI/CD
- DevSkim Analysis: Security-focused static analysis
- Dependency Auditing: Regular security updates and checks
- Input Validation: Comprehensive request sanitization
- Command Sandboxing: Safe command execution with restricted permissions
- Error Handling: Secure failure responses without information leakage
- Logging Security: Sensitive data redaction in logs
- GDPR Compliant: No personal data collection or transmission
- Privacy-First: All processing happens locally
- Open Source: Full transparency and community review
For security issues, please see our Security Policy.
We welcome contributions! Please see our Contributing Guide for detailed information.
-
Clone the repository:
git clone https://github.com/harpertoken/harper.git cd harper -
Install dependencies:
cargo fetch
-
Run the test suite:
cargo test -
Code quality checks:
cargo clippy # Linting cargo fmt -- --check # Formatting check
-
Build and test:
cargo build --release ./harpertest # Run full test suite
- Follow Conventional Commits for commit messages
- Run tests before submitting PRs
- Ensure code passes all CI checks
- Update documentation for new features
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: See docs/ directory
This project follows a code of conduct to ensure a welcoming environment for all contributors. See CODE_OF_CONDUCT.md.
Harper is actively maintained and under continuous development. Current focus areas:
- Performance Optimization: Reducing latency and improving response times
- MCP Protocol: Re-enabling Model Context Protocol support
- Additional Providers: Expanding AI provider integrations
- Enhanced Security: Ongoing security improvements and audits
- Web interface for chat sessions
- Plugin system for custom tools
- Multi-language support
- Advanced session analytics
- Cloud deployment options
Harper builds upon the excellent work of the open-source community:
- Rust Ecosystem: For the robust systems programming language
- SQLite: For reliable, embedded database functionality
- AI Providers: OpenAI, Sambanova, and Google for accessible AI APIs
- Contributors: The community driving Harper's development