|
| 1 | +# sourcevault-code-tools |
| 2 | + |
| 3 | +A [Hermes Agent](https://github.com/nousresearch/hermes-agent) plugin that |
| 4 | +gives Hermes **persistent, private memory of your codebases** — semantic code |
| 5 | +search, exact file reads, and grounded repo Q&A with file-and-line citations. |
| 6 | +Everything runs on your machine over localhost; no source code leaves it. |
| 7 | + |
| 8 | +Works in Hermes CLI, Telegram, and Hermes Desktop. |
| 9 | + |
| 10 | +```text |
| 11 | +/code_ask my-api "auth middleware" "Where do we validate JWTs, and what happens on expiry?" |
| 12 | +→ grounded answer with [S1]-style citations into real files and lines |
| 13 | +``` |
| 14 | + |
| 15 | +## What it adds |
| 16 | + |
| 17 | +**Slash commands** (deterministic — work reliably with any local model): |
| 18 | + |
| 19 | +| Command | What it does | |
| 20 | +|---|---| |
| 21 | +| `/code-help` | Command reference | |
| 22 | +| `/code-status` | Integration health check | |
| 23 | +| `/code-repos` | List indexed repos | |
| 24 | +| `/code-sync <repo>` | Fast-forward the repo mirror | |
| 25 | +| `/code-read <repo> <path>` | Read an exact file | |
| 26 | +| `/code-search <repo> "query"` | Hybrid semantic + literal search | |
| 27 | +| `/code-context <repo> "query"` | Retrieve a compact context pack | |
| 28 | +| `/code-ask <repo> "query" "question"` | Retrieve + answer with citations | |
| 29 | + |
| 30 | +Telegram uses underscore forms (`/code_ask`, …). |
| 31 | + |
| 32 | +> **Repo names are case-sensitive.** `repo_name` is the literal directory name |
| 33 | +> under `REPO_ROOT` (Linux filesystem semantics): if the folder is `My-Repo`, |
| 34 | +> then `/code-read my-repo …` fails and `/code-read My-Repo …` works. Run |
| 35 | +> `/code-repos` to see the exact names. |
| 36 | +
|
| 37 | +**LLM-callable tools** (for models that handle structured tool use): |
| 38 | +`code_search`, `code_read_file`, plus `sourcevault_search` / `sourcevault_read` |
| 39 | +aliases for Hermes Tool Search discoverability. |
| 40 | + |
| 41 | +## Requires a SourceVault backend |
| 42 | + |
| 43 | +This plugin is the Hermes-side client. Indexing, embeddings (Ollama + |
| 44 | +nomic-embed-text), the vector store (ChromaDB), hybrid retrieval, and the |
| 45 | +signed API are provided by **SourceVault**, a local-first private code-memory |
| 46 | +server. The plugin is useless without it. |
| 47 | + |
| 48 | +Get SourceVault (done-for-you private install, no per-seat fees): |
| 49 | +**<https://trysourcevault.com>** |
| 50 | + |
| 51 | +## Install |
| 52 | + |
| 53 | +Clone (or download) this plugin, then copy the plugin folder into |
| 54 | +`~/.hermes/plugins/` — note the source path is the plugin directory, wherever |
| 55 | +you cloned it, not `.`: |
| 56 | + |
| 57 | +```bash |
| 58 | +git clone https://github.com/Ocasio-Perez/sourcevault-code-tools /tmp/sourcevault-code-tools |
| 59 | +mkdir -p ~/.hermes/plugins |
| 60 | +cp -R /tmp/sourcevault-code-tools ~/.hermes/plugins/sourcevault-code-tools |
| 61 | +``` |
| 62 | + |
| 63 | +If you have the SourceVault server repo, use its installer instead — it also |
| 64 | +configures Hermes and validates the env: |
| 65 | + |
| 66 | +```bash |
| 67 | +cd ~/Development/sourcevault |
| 68 | +./scripts/install-hermes-integration.sh --configure-sourcevault --restart-hermes |
| 69 | +``` |
| 70 | + |
| 71 | +Enable in `~/.hermes/config.yaml`: |
| 72 | + |
| 73 | +```yaml |
| 74 | +plugins: |
| 75 | + enabled: |
| 76 | + - sourcevault-code-tools |
| 77 | + |
| 78 | +platform_toolsets: |
| 79 | + cli: |
| 80 | + - sourcevault_code_tools |
| 81 | + telegram: |
| 82 | + - sourcevault_code_tools |
| 83 | +``` |
| 84 | +
|
| 85 | +Point the gateway at your SourceVault instance |
| 86 | +(`~/.config/systemd/user/hermes-gateway.env` or equivalent): |
| 87 | + |
| 88 | +```env |
| 89 | +CODE_SEARCH_URL=http://127.0.0.1:9000/api/search-codebase |
| 90 | +CODE_READ_FILE_URL=http://127.0.0.1:9000/api/read-file |
| 91 | +CODE_SEARCH_HMAC_SECRET=<same value as the SourceVault server> |
| 92 | +``` |
| 93 | + |
| 94 | +Restart Hermes (`systemctl --user restart hermes-gateway` or relaunch the |
| 95 | +Desktop app) and run `/code-status`. |
| 96 | + |
| 97 | +## Try it |
| 98 | + |
| 99 | +Replace `hello-world` below with one of your indexed repo names — copied |
| 100 | +exactly as `/code-repos` prints it (case-sensitive). |
| 101 | + |
| 102 | +```text |
| 103 | +# 1. Health and inventory |
| 104 | +/code-status |
| 105 | +/code-repos |
| 106 | +
|
| 107 | +# 2. Read an exact file (path is repo-relative) |
| 108 | +/code-read hello-world README.md |
| 109 | +/code-read hello-world src/index.js 20000 |
| 110 | +
|
| 111 | +# 3. Search — semantic or literal, your choice of phrasing |
| 112 | +/code-search hello-world "where errors get logged" 5 |
| 113 | +/code-search hello-world "config.js" 3 |
| 114 | +
|
| 115 | +# 4. Context pack — retrieve snippets, then ask follow-ups in plain chat |
| 116 | +/code-context hello-world "startup and initialization flow" 6 |
| 117 | +
|
| 118 | +# 5. Grounded Q&A — first string is the SEARCH query, second is the QUESTION |
| 119 | +/code-ask hello-world "input validation" "How are user inputs validated, and where could that fail?" |
| 120 | +/code-ask hello-world "database connection setup" "Walk me through how a connection is opened, reused, and closed." 8 |
| 121 | +``` |
| 122 | + |
| 123 | +Usage notes: |
| 124 | + |
| 125 | +- Quote any multi-word argument; arguments are shell-split, so an unbalanced |
| 126 | + quote returns a usage error. |
| 127 | +- The optional trailing number is `n_results` (default 5). Raise it to 8–10 |
| 128 | + for architecture-wide questions; keep it low for pinpoint lookups. |
| 129 | +- `/code-ask` answers only from retrieved chunks and says what's missing |
| 130 | + rather than guessing. If it reports missing context, retry with a broader |
| 131 | + search query or higher `n_results`. |
| 132 | +- After `/code-sync`, reindex from the SourceVault side before searching |
| 133 | + again, or results will cite stale code. |
| 134 | + |
| 135 | +## Configuration reference |
| 136 | + |
| 137 | +| Env var | Default | Purpose | |
| 138 | +|---|---|---| |
| 139 | +| `CODE_SEARCH_URL` | `http://127.0.0.1:9000/api/search-codebase` | SourceVault search endpoint | |
| 140 | +| `CODE_READ_FILE_URL` | `http://127.0.0.1:9000/api/read-file` | SourceVault file-read endpoint | |
| 141 | +| `CODE_SEARCH_HMAC_SECRET` | — | Request-signing secret (required) | |
| 142 | +| `REPO_ROOT` | `~/.hermes/repos` | Local repo mirrors for `/code-repos`, `/code-sync` | |
| 143 | +| `SOURCEVAULT_CODE_TOOLS_DEBUG` | off | Log argument shapes (no secrets) | |
| 144 | + |
| 145 | +## Security notes |
| 146 | + |
| 147 | +- All requests are HMAC-signed and travel over localhost only. |
| 148 | +- The plugin never executes retrieved code; `/code-sync` runs only |
| 149 | + `git pull --ff-only` inside the configured repo root. |
| 150 | +- Repo paths are confined to `REPO_ROOT`; traversal attempts are rejected. |
| 151 | +- No telemetry, no external network calls. |
| 152 | + |
| 153 | +## License |
| 154 | + |
| 155 | +MIT — see [LICENSE](LICENSE). The SourceVault server is a separate, |
| 156 | +commercially licensed product. |
0 commit comments