Merge pull request 'docs: add hermes-setup.md from issue #1 research' (#8) from docs/hermes-setup into main
This commit was merged in pull request #8.
This commit is contained in:
@@ -15,6 +15,7 @@ Overview of research topics and notes.
|
|||||||
| Topic | Status | Last Updated |
|
| Topic | Status | Last Updated |
|
||||||
|-------|--------|--------------|
|
|-------|--------|--------------|
|
||||||
| [OpenCode Usage & Parallelization](./opencode-usage.md) | Active | 2025-03-27 |
|
| [OpenCode Usage & Parallelization](./opencode-usage.md) | Active | 2025-03-27 |
|
||||||
|
| [Hermes Setup](./hermes-setup.md) | In Progress | 2026-03-27 |
|
||||||
|
|
||||||
### More topics...
|
### More topics...
|
||||||
|
|
||||||
|
|||||||
@@ -1,201 +1,342 @@
|
|||||||
# Hermes Setup Guide
|
# Hermes Setup Guide for Kugetsu
|
||||||
|
|
||||||
## Overview
|
**Date:** 2026-03-27
|
||||||
|
**Status:** In Progress
|
||||||
|
**Related Issue:** #1
|
||||||
|
|
||||||
Hermes is the primary orchestrator and gateway in the Kugetsu system. It handles:
|
## Summary
|
||||||
|
|
||||||
- Spawning and managing subagents
|
Guide for setting up Hermes as the orchestration layer for Kugetsu's multi-agent parallel workflow. Hermes manages OpenCode coding agents that work in isolated git worktrees, communicating via Gitea issues and PRs.
|
||||||
- Message passing between agents
|
|
||||||
- Repository access via Git API
|
|
||||||
- Task delegation and parallelization
|
|
||||||
|
|
||||||
**Key Constraint:** The delegate_task function has a hard limit of 3 concurrent tasks.
|
## 1. Installation
|
||||||
|
|
||||||
---
|
### Recommended: curl (One-Liner)
|
||||||
|
|
||||||
## Installation via Curl Script
|
```bash
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash -s -- --skip-setup
|
||||||
|
```
|
||||||
|
|
||||||
|
The `--skip-setup` flag skips the interactive setup wizard, ideal for CI environments.
|
||||||
|
|
||||||
|
**What it installs:**
|
||||||
|
- `uv` (fast Python package manager)
|
||||||
|
- Python 3.11 via uv
|
||||||
|
- Node.js v22 LTS (for browser tools & WhatsApp bridge)
|
||||||
|
- ripgrep (fast file search)
|
||||||
|
- ffmpeg (TTS/audio)
|
||||||
|
- Clones repo to `~/.hermes/hermes-agent/`
|
||||||
|
- Creates venv, installs deps, sets up `hermes` symlink in `~/.local/bin/`
|
||||||
|
- Creates config templates in `~/.hermes/`
|
||||||
|
|
||||||
|
### Verification
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hermes version # Check command exists
|
||||||
|
hermes doctor # Full diagnostics
|
||||||
|
source ~/.bashrc # Reload shell if hermes not found
|
||||||
|
```
|
||||||
|
|
||||||
|
### Alternative Methods
|
||||||
|
|
||||||
|
| Method | Command | Best For |
|
||||||
|
|--------|---------|----------|
|
||||||
|
| **curl** | `curl -fsSL ... \| bash` | **Recommended** — fresh machines, CI |
|
||||||
|
| **Manual/Source** | `git clone` + `uv venv` + `uv pip install -e ".[all]"` | Full control, developers |
|
||||||
|
| **Nix** | `nix develop` or NixOS module | Nix/NixOS users, declarative configs |
|
||||||
|
| **Docker** | Not for installation | Docker is a *terminal backend* for sandboxing |
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- Linux/macOS environment
|
Only `git` and `curl` are required. All other dependencies are installed by the script.
|
||||||
- curl, git, and basic build tools installed
|
|
||||||
- LLM provider API key (for cloud providers)
|
|
||||||
|
|
||||||
### Installation Steps
|
## 2. Configuration (API Key Auth)
|
||||||
|
|
||||||
```bash
|
|
||||||
# Clone the Hermes repository
|
|
||||||
git clone https://git.example.com/shoko/hermes.git ~/repositories/hermes
|
|
||||||
|
|
||||||
# Run the installation script
|
|
||||||
cd ~/repositories/hermes && ./install.sh
|
|
||||||
|
|
||||||
# Verify installation
|
|
||||||
hermes --version
|
|
||||||
|
|
||||||
# Initialize with non-interactive mode (if config exists)
|
|
||||||
hermes init --non-interactive
|
|
||||||
```
|
|
||||||
Alternative: Direct Download
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -L https://git.example.com/shoko/hermes/releases/latest/download/hermes -o ~/.local/bin/hermes
|
|
||||||
chmod +x ~/.local/bin/hermes
|
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
|
||||||
hermes --version
|
|
||||||
```
|
|
||||||
---
|
|
||||||
|
|
||||||
## Programmatic Configuration
|
|
||||||
|
|
||||||
If you already have an API token, configure Hermes entirely via files and commands.
|
|
||||||
|
|
||||||
### Directory Structure
|
### Directory Structure
|
||||||
|
|
||||||
```bash
|
```
|
||||||
mkdir -p ~/.hermes/skills ~/.hermes/cache
|
~/.hermes/
|
||||||
|
├── config.yaml # Non-secret settings (model, provider, terminal, etc.)
|
||||||
|
├── .env # API keys and secrets
|
||||||
|
├── auth.json # OAuth tokens (Nous Portal, Codex, etc.)
|
||||||
|
├── SOUL.md # Agent identity
|
||||||
|
├── memories/ # Persistent memory
|
||||||
|
├── skills/ # Agent skills
|
||||||
|
├── sessions/ # Gateway sessions
|
||||||
|
└── logs/ # Error and gateway logs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configure via .env File
|
### CLI Configuration
|
||||||
|
|
||||||
Create `~/.hermes/.env`:
|
Set API keys directly via the CLI (auto-routes to `~/.hermes/.env`):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ANTHROPIC_API_KEY=sk-ant-...
|
hermes config set OPENROUTER_API_KEY sk-or-...
|
||||||
OPENROUTER_API_KEY=sk-or-...
|
hermes config set ANTHROPIC_API_KEY sk-ant-...
|
||||||
GITEA_TOKEN=your_token
|
hermes config set OPENAI_API_KEY sk-...
|
||||||
HERMES_DEFAULT_MODEL=openrouter/anthropic/claude-sonnet-4
|
|
||||||
|
hermes config set model.provider openrouter
|
||||||
|
hermes config set model.default anthropic/claude-opus-4.6
|
||||||
|
|
||||||
|
hermes config # View current config
|
||||||
|
hermes config edit # Edit config.yaml
|
||||||
|
hermes config check # Validate configuration
|
||||||
|
```
|
||||||
|
|
||||||
|
### Supported Providers (API Key Auth)
|
||||||
|
|
||||||
|
| Provider | Env Var | Config Provider | Notes |
|
||||||
|
|----------|---------|-----------------|-------|
|
||||||
|
| **OpenRouter** | `OPENROUTER_API_KEY` | `openrouter` | Recommended default |
|
||||||
|
| **OpenAI** | `OPENAI_API_KEY` | `openai` | |
|
||||||
|
| **Anthropic** | `ANTHROPIC_API_KEY` | `anthropic` | |
|
||||||
|
| **OpenAI-Compatible** | `OPENAI_API_KEY` + `OPENAI_BASE_URL` | `custom` | vLLM, SGLang, llama.cpp, LocalAI, Jan, Ollama |
|
||||||
|
| **Ollama** | `OPENAI_API_KEY=ollama` + `OPENAI_BASE_URL` | `custom` | Local models (no API key) |
|
||||||
|
| **DeepSeek** | `DEEPSEEK_API_KEY` | `custom` + base_url | |
|
||||||
|
| **Together AI** | `OPENAI_API_KEY` | `custom` + base_url | |
|
||||||
|
| **Groq** | `OPENAI_API_KEY` | `custom` + base_url | |
|
||||||
|
| **Fireworks AI** | `OPENAI_API_KEY` | `custom` + base_url | |
|
||||||
|
|
||||||
|
### Example Configs
|
||||||
|
|
||||||
|
**OpenRouter (Recommended):**
|
||||||
|
```bash
|
||||||
|
# ~/.hermes/.env
|
||||||
|
OPENROUTER_API_KEY=sk-or-v1-...
|
||||||
|
LLM_MODEL=anthropic/claude-opus-4.6
|
||||||
```
|
```
|
||||||
### Configure via config.yaml
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
hermes:
|
# ~/.hermes/config.yaml
|
||||||
name: kugetsu-orchestrator
|
model:
|
||||||
log_level: info
|
provider: "openrouter"
|
||||||
max_parallel_tasks: 3
|
default: "anthropic/claude-opus-4.6"
|
||||||
task_timeout: 3600
|
|
||||||
|
|
||||||
gitea:
|
|
||||||
instance: https://git.example.com
|
|
||||||
owner: shoko
|
|
||||||
repo: kugetsu
|
|
||||||
token_env: GITEA_TOKEN
|
|
||||||
|
|
||||||
agents:
|
|
||||||
default_model: openrouter/anthropic/claude-sonnet-4
|
|
||||||
temperature: 0.7
|
|
||||||
thinking_enabled: true
|
|
||||||
```
|
```
|
||||||
### Automate Configuration with hermes config set
|
|
||||||
|
|
||||||
Set configuration programmatically:
|
**Ollama (Local):**
|
||||||
|
```bash
|
||||||
|
# ~/.hermes/.env
|
||||||
|
OPENAI_BASE_URL=http://localhost:11434/v1
|
||||||
|
OPENAI_API_KEY=ollama
|
||||||
|
LLM_MODEL=llama3.1:70b
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# ~/.hermes/config.yaml
|
||||||
|
model:
|
||||||
|
provider: "custom"
|
||||||
|
default: "llama3.1:70b"
|
||||||
|
base_url: "http://localhost:11434/v1"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Anthropic Direct:**
|
||||||
|
```bash
|
||||||
|
# ~/.hermes/.env
|
||||||
|
ANTHROPIC_API_KEY=sk-ant-...
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# ~/.hermes/config.yaml
|
||||||
|
model:
|
||||||
|
provider: "anthropic"
|
||||||
|
default: "claude-sonnet-4-6"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Quick-Start Template
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hermes config set agents.default_model "openrouter/anthropic/claude-sonnet-4"
|
# ~/.hermes/.env (create this)
|
||||||
hermes config set agents.temperature 0.7
|
OPENROUTER_API_KEY=your-key-here
|
||||||
hermes config set gitea.instance "https://git.example.com"
|
LLM_MODEL=anthropic/claude-opus-4.6
|
||||||
hermes config set gitea.owner "shoko"
|
|
||||||
hermes config set gitea.repo "kugetsu"
|
# ~/.hermes/config.yaml (minimal)
|
||||||
hermes config set opencode.managed_by "hermes"
|
model:
|
||||||
hermes config set opencode.default_mode "agent"
|
provider: "openrouter"
|
||||||
hermes config list
|
default: "anthropic/claude-opus-4.6"
|
||||||
```
|
```
|
||||||
## LLM Providers with API Key Only
|
|
||||||
|
|
||||||
These providers work with just an environment variable or API key:
|
## 3. OpenCode Integration
|
||||||
|
|
||||||
### OpenRouter (Recommended)
|
### How Hermes Delegates to OpenCode
|
||||||
|
|
||||||
|
Hermes does **NOT** have a native agent-to-agent protocol. Delegation happens via terminal/process spawning:
|
||||||
|
|
||||||
|
```
|
||||||
|
Hermes (orchestrator)
|
||||||
|
└── terminal(command="opencode run 'task'", workdir="...")
|
||||||
|
└── OpenCode subprocess (child process)
|
||||||
|
└── Executes autonomously
|
||||||
|
```
|
||||||
|
|
||||||
|
### delegate_task vs terminal(opencode run)
|
||||||
|
|
||||||
|
| Pattern | Command | Concurrency Limit | Context |
|
||||||
|
|---------|---------|-------------------|---------|
|
||||||
|
| `delegate_task()` | Native LLM subagent | **Max 3** (hard schema limit) | Fresh isolated context |
|
||||||
|
| `terminal(opencode run)` | CLI subprocess wrapper | **No hard cap** | Streams output via process() |
|
||||||
|
|
||||||
|
For Kugetsu's parallel workflow, prefer `terminal(opencode run ...)` for coding agents since we need more than 3 concurrent agents.
|
||||||
|
|
||||||
|
### Example Delegation Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export OPENROUTER_API_KEY="sk-or-..."
|
# One-shot task (blocks until complete)
|
||||||
hermes config set agents.default_model "openrouter/anthropic/claude-sonnet-4"
|
terminal(command="opencode run 'Fix issue #1: add retry logic'", workdir="/tmp/issue-1")
|
||||||
```
|
|
||||||
Supports: Anthropic, OpenAI, Mistral, Llama, Gemini, and more.
|
|
||||||
|
|
||||||
### Anthropic (Direct)
|
# Background TUI (interactive, returns session_id)
|
||||||
|
terminal(command="opencode", workdir="~/project", background=true, pty=true)
|
||||||
|
|
||||||
|
# Monitor background session
|
||||||
|
process(action="poll", session_id="<id>")
|
||||||
|
process(action="log", session_id="<id>")
|
||||||
|
process(action="submit", session_id="<id>", data="Continue work...")
|
||||||
|
|
||||||
|
# Kill session
|
||||||
|
process(action="kill", session_id="<id>")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Kugetsu's Gitea-Based Communication Hub
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────────┐
|
||||||
|
│ Hermes (Orchestrator/PM) │
|
||||||
|
│ - terminal(opencode run ...) for OpenCode agents │
|
||||||
|
│ - delegate_task() for LLM subagents (max 3) │
|
||||||
|
└─────────────────────────────────────────────────────────────┘
|
||||||
|
│ (CLI subprocess)
|
||||||
|
▼
|
||||||
|
┌──────────────────────┐
|
||||||
|
│ OpenCode Subagent │
|
||||||
|
│ - Works in isolated │
|
||||||
|
│ git worktree │
|
||||||
|
│ - Posts findings to │
|
||||||
|
│ Gitea via curl │
|
||||||
|
└──────────────────────┘
|
||||||
|
│ (Gitea API)
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────────────────────────────────────┐
|
||||||
|
│ Gitea (Communication Hub) │
|
||||||
|
│ - Issues as task tickets │
|
||||||
|
│ - Comments as progress updates │
|
||||||
|
│ - PRs as code deliverables │
|
||||||
|
└─────────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Git Worktree Isolation (Per-Issue)
|
||||||
|
|
||||||
|
### Why Worktrees?
|
||||||
|
|
||||||
|
Running multiple agents on the same repo can cause:
|
||||||
|
- **File conflicts** when agents edit the same files
|
||||||
|
- **Branch state confusion** when agents checkout different branches
|
||||||
|
- **Lost work** if one agent's changes get overwritten
|
||||||
|
|
||||||
|
Each issue gets its own worktree so any agent can jump into the right context.
|
||||||
|
|
||||||
|
### Manual Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export ANTHROPIC_API_KEY="sk-ant-..."
|
# Create worktree for an issue
|
||||||
hermes config set agents.default_model "anthropic/claude-sonnet-4"
|
git worktree add -b fix/issue-{N}-title ../kugetsu-issue-{N} main
|
||||||
|
|
||||||
|
# List worktrees
|
||||||
|
git worktree list
|
||||||
|
|
||||||
|
# Remove worktree (after PR merged)
|
||||||
|
git worktree remove ../kugetsu-issue-{N}
|
||||||
|
git branch -D fix/issue-{N}-title
|
||||||
```
|
```
|
||||||
|
|
||||||
### OpenAI Compatible
|
### opencode-worktree Skill
|
||||||
|
|
||||||
|
Kugetsu provides an automated skill at `skills/opencode-worktree/`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export OPENAI_API_KEY="sk-..."
|
# Source the script
|
||||||
hermes config set agents.default_model "openai/gpt-4o"
|
. skills/opencode-worktree/opencode-worktree.sh
|
||||||
|
|
||||||
|
# Create session with purpose tag
|
||||||
|
. opencode-worktree.sh refactor-auth
|
||||||
|
# Creates: session-{timestamp}-{random6}-refactor-auth
|
||||||
|
|
||||||
|
# Cleanup all session-* worktrees
|
||||||
|
. opencode-worktree.sh --cleanup
|
||||||
|
|
||||||
|
# Cleanup specific worktree
|
||||||
|
. opencode-worktree.sh --cleanup session-20260327-134524-9c1e3f-refactor-auth
|
||||||
```
|
```
|
||||||
|
|
||||||
### Groq (Fast, Free Tier)
|
### Hermes Built-in Worktree Isolation
|
||||||
|
|
||||||
|
Hermes has native support via config:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# ~/.hermes/config.yaml
|
||||||
|
worktree: true # Always create a worktree per session
|
||||||
|
```
|
||||||
|
|
||||||
|
Each CLI session creates a fresh worktree under `.worktrees/` with its own branch. Clean worktrees are removed on exit; dirty ones are kept for manual recovery.
|
||||||
|
|
||||||
|
### Branch Hygiene
|
||||||
|
|
||||||
|
**Always use explicit base when creating branches:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export GROQ_API_KEY="gsk_..."
|
# WRONG - depends on current HEAD
|
||||||
hermes config set agents.default_model "groq/llama-3.1-70b"
|
git checkout -b fix/issue-{N}-title
|
||||||
|
|
||||||
|
# CORRECT - always from main explicitly
|
||||||
|
git checkout -b fix/issue-{N}-title main
|
||||||
```
|
```
|
||||||
## OpenCode Integration
|
|
||||||
|
|
||||||
OpenCode can be managed by Hermes as an orchestrator-controlled coding agent.
|
**Detect contamination:**
|
||||||
|
|
||||||
### Setup
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install OpenCode
|
# Check for commits beyond main
|
||||||
curl -L https://opencode.ai/install.sh | sh
|
git log main..HEAD --oneline
|
||||||
|
# If non-empty, branch is contaminated
|
||||||
# Configure Hermes to manage OpenCode
|
|
||||||
hermes config set opencode.managed_by "hermes"
|
|
||||||
hermes config set opencode.binary_path "~/.opencode/bin/opencode"
|
|
||||||
hermes config set opencode.default_mode "agent"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Usage
|
**Fix contamination:**
|
||||||
|
|
||||||
OpenCode runs as a subagent under Hermes:
|
|
||||||
|
|
||||||
```
|
|
||||||
Task: Write a Python script
|
|
||||||
Agent: opencode
|
|
||||||
Model: openrouter/anthropic/claude-sonnet-4
|
|
||||||
```
|
|
||||||
|
|
||||||
### Benefits
|
|
||||||
|
|
||||||
- Orchestrated: Hermes manages task routing to OpenCode
|
|
||||||
- Consistent Context: Shared cache and session management
|
|
||||||
- Unified Logging: All agent activity flows through Hermes
|
|
||||||
## Verification
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check version
|
git rebase --onto main wrong-base my-branch
|
||||||
hermes --version
|
git push --force-with-lease origin my-branch
|
||||||
|
|
||||||
# List configuration
|
|
||||||
hermes config list
|
|
||||||
|
|
||||||
# Test Gitea connection
|
|
||||||
hermes doctor
|
|
||||||
|
|
||||||
# Run a test task
|
|
||||||
hermes task status
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## 5. Workflow Summary
|
||||||
|
|
||||||
### Config not loading
|
```
|
||||||
|
1. Setup Hermes
|
||||||
|
curl -fsSL .../install.sh | bash -s -- --skip-setup
|
||||||
|
hermes config set OPENROUTER_API_KEY ...
|
||||||
|
hermes config set model.provider openrouter
|
||||||
|
|
||||||
```bash
|
2. For Each Issue: Create Isolated Worktree
|
||||||
hermes --config ~/.hermes/config.yaml config list
|
git worktree add -b docs/issue-{N}-title ../kugetsu-issue-{N} main
|
||||||
|
|
||||||
|
3. Agent Works in Worktree
|
||||||
|
cd ../kugetsu-issue-{N}
|
||||||
|
opencode run "Research/fix issue #{N}"
|
||||||
|
|
||||||
|
4. Agent Posts to Gitea
|
||||||
|
curl -X POST .../issues/{N}/comments -d @/tmp/findings-{N}.md
|
||||||
|
|
||||||
|
5. User Reviews on Gitea
|
||||||
|
Comments on issues/PRs
|
||||||
|
|
||||||
|
6. Cleanup After Merge
|
||||||
|
git worktree remove ../kugetsu-issue-{N}
|
||||||
|
git branch -D docs/issue-{N}-title
|
||||||
```
|
```
|
||||||
|
|
||||||
### API key not found
|
## References
|
||||||
|
|
||||||
```bash
|
- [Hermes Agent GitHub](https://github.com/nousresearch/hermes-agent)
|
||||||
export $(cat ~/.hermes/.env | xargs)
|
- [Hermes Agent Docs](https://hermes-agent.nousresearch.com)
|
||||||
hermes config list
|
- [Kugetsu Architecture](./kugetsu-architecture.md)
|
||||||
```
|
- [OpenCode Usage](./opencode-usage.md)
|
||||||
|
- [Subagent Workflow](./SUBAGENT_WORKFLOW.md)
|
||||||
|
|
||||||
### Gitea connection failed
|
## Status History
|
||||||
|
|
||||||
```bash
|
- 2026-03-27: Initial draft from issue #1 research
|
||||||
curl -H "Authorization: token $GITEA_TOKEN" https://git.example.com/api/v1/user
|
|
||||||
```
|
|
||||||
|
|||||||
Reference in New Issue
Block a user