hydra-nano 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +193 -2
- package/package.json +51 -4
- package/skills/hydra/SKILL.md +51 -0
- package/skills/hydra/scripts/hooks/route-tests.mjs +22 -0
- package/skills/hydra/scripts/hooks/session-guide.mjs +13 -0
- package/skills/hydra/scripts/hydra.mjs +291 -0
- package/skills/hydra/scripts/install.mjs +46 -0
- package/skills/hydra/scripts/lib/answer.mjs +127 -0
- package/skills/hydra/scripts/lib/bootstrap.mjs +77 -0
- package/skills/hydra/scripts/lib/claude_hooks.mjs +97 -0
- package/skills/hydra/scripts/lib/exec.mjs +37 -0
- package/skills/hydra/scripts/lib/files.mjs +192 -0
- package/skills/hydra/scripts/lib/git.mjs +278 -0
- package/skills/hydra/scripts/lib/ledger.mjs +34 -0
- package/skills/hydra/scripts/lib/local.mjs +92 -0
- package/skills/hydra/scripts/lib/ollama.mjs +2 -0
- package/skills/hydra/scripts/lib/os.mjs +243 -0
- package/skills/hydra/scripts/lib/read.mjs +294 -0
- package/skills/hydra/scripts/lib/route.mjs +19 -0
- package/skills/hydra/scripts/lib/runtime.mjs +100 -0
- package/skills/hydra/scripts/lib/test_logs.mjs +239 -0
- package/skills/hydra/scripts/runtime-manifest.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rahul05ranjan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,194 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Hydra
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Small local models that a frontier coding agent (Claude Code, Codex) hands routine repo work to, so the raw output of that work never enters the frontier model's context.
|
|
4
|
+
|
|
5
|
+
Hydra version 0.1 provides five specialist heads powered by the local **Hydra Nano** model family (`hydra-nano:git`, `hydra-nano:os`, `hydra-nano:test`, `hydra-nano:read`, `hydra-nano:files`), also hosted on Hugging Face at [`rahul05ranjan/hydra-nano-git`](https://huggingface.co/rahul05ranjan/hydra-nano-git):
|
|
6
|
+
1. **git head** (`hydra-nano:git`): inspects repository history, branch sync, diffs, blame, and status.
|
|
7
|
+
2. **files head** (`hydra-nano:files`): fast definition-ranked code search without cluttering context.
|
|
8
|
+
3. **read head** (`hydra-nano:read`): extracts symbol definitions (functions, classes, methods), line ranges, or structural definition outlines across TypeScript, JavaScript, Python, Rust, and Go without dumping whole multi-thousand-line files into context.
|
|
9
|
+
4. **test & logs head** (`hydra-nano:test`): runs test and compiler suites (`npm test`, `pytest`, `cargo test`, `tsc`), strips framework noise and `node_modules` stacks, and returns verbatim failure diffs and source lines with the command's exit code.
|
|
10
|
+
5. **os head** (`hydra-nano:os`): read-only system inspection (ports, processes, disk, system info) with strict secret-blocking guardrails.
|
|
11
|
+
|
|
12
|
+
## How a call works
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
agent ── hydra ask --head git "<question>" ──────▶ git head model picks probes from a menu, code runs them
|
|
16
|
+
agent ── hydra ask --head files "<question>" ────▶ files head model picks search terms, code searches
|
|
17
|
+
agent ── hydra read <file> [symbol|--lines] ─────▶ read head pinpoints symbol/lines, extracts outline
|
|
18
|
+
agent ── hydra run -- <test/build-command> ──────▶ test head runs locally, digests failures & diffs
|
|
19
|
+
agent ◀── verbatim evidence lines ──────────────── model picks lines; the agent interprets them
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- **Read-only and safe**: The model never writes an arbitrary command. It picks from fixed menus or digests command output.
|
|
23
|
+
- **Verbatim evidence**: Results are the command's own text lines, never a paraphrase.
|
|
24
|
+
- **Complete lists**: Git status, history, branches, remotes, stashes, tags and worktrees retain every returned record. Explicit commit counts override the model's count (maximum 50).
|
|
25
|
+
- **Pass-through**: Output under 800 characters is handed over whole with zero model calls.
|
|
26
|
+
- **Preserved exit codes**: `hydra run -- <cmd>` preserves `<cmd>`'s exit code, so agents know immediately if a build or test failed.
|
|
27
|
+
|
|
28
|
+
On Windows, OS inspection uses fixed read-only netstat, tasklist and PowerShell CIM commands, plus Node system/memory APIs. Process output is capped at 30 records and is not sorted by CPU usage. Failed probes are marked in the returned evidence. Code search ranks current source ahead of archived evaluation results while keeping those results searchable.
|
|
29
|
+
|
|
30
|
+
## Try it
|
|
31
|
+
|
|
32
|
+
Needs Node 18 or later and [llama.cpp](https://github.com/ggml-org/llama.cpp) (the default backend). [Ollama](https://ollama.com/download) is optional; select it with `HYDRA_BACKEND=ollama`.
|
|
33
|
+
|
|
34
|
+
### Run without Ollama
|
|
35
|
+
|
|
36
|
+
**Hydra Nano v2 (2026-10-14):** the installer pins the Q8_0 GGUF of a full-parameter Git fine-tune at Hub revision `8129125f` (SHA-256 `6d6542c8…`). With the current code it solves **963/1,000 sealed Git tasks (96.3%; 96.17% usage-weighted)** (927/1,000 with the code validated on Kaggle) and, on 1,000-task held-out sets, Files 98.0%, Read 96.1%, Test 94.4% and OS 100% (synthetic probe outputs). See the [model card](https://huggingface.co/rahul05ranjan/hydra-nano-git) and the receipts in [`evals/results/suite/v2-6d6542c8`](evals/results/suite/v2-6d6542c8) and [`final-git-validation`](evals/results/suite/final-git-validation/SUMMARY.json). The previous v1 artifact (87.4% sealed) stays at Hub revision `ff1c723f`.
|
|
37
|
+
|
|
38
|
+
`train/publish_release.py` publishes a validated release: it checks the checkpoint and GGUF against the frozen validation receipt, uploads them with the model cards in [`hub/`](hub), and pins `runtime-manifest.json` to the new revision. The GGUF is reproducible with llama.cpp `convert_hf_to_gguf.py` at commit `a05e58c` (`--outtype q8_0`). Safetensors files cannot be passed directly to `llama-server`.
|
|
39
|
+
|
|
40
|
+
Start the server in one terminal:
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
llama-server -m C:\models\hydra-nano-git.gguf --alias hydra-nano:git --host 127.0.0.1 --port 8080 -c 8192
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
In another PowerShell terminal:
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
$env:HYDRA_BACKEND = 'llamacpp'
|
|
50
|
+
$env:HYDRA_LLAMA_URL = 'http://127.0.0.1:8080'
|
|
51
|
+
$env:HYDRA_MODEL = 'hydra-nano:git'
|
|
52
|
+
node skills/hydra/scripts/hydra.mjs doctor
|
|
53
|
+
node skills/hydra/scripts/hydra.mjs ask --head git "which branch am I on?"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
On macOS/Linux, set the same variables with `export HYDRA_BACKEND=llamacpp`, `export HYDRA_LLAMA_URL=http://127.0.0.1:8080` and `export HYDRA_MODEL=hydra-nano:git`.
|
|
57
|
+
|
|
58
|
+
The URL is the server root, without `/v1`. `HYDRA_MODEL` must match the server alias; setting it sends all model-backed heads to that one model and does not create specialist weights. Without this override, Hydra requests its existing per-head model names; your server must serve those aliases. `hydra doctor` verifies the effective configured names. `hydra setup` with this backend prints instructions without installing or starting anything.
|
|
59
|
+
|
|
60
|
+
Hydra uses llama.cpp's [schema-constrained chat API](https://github.com/ggml-org/llama.cpp/tree/master/tools/server#post-v1chatcompletions-openai-compatible-chat-completions-api), disables thinking, and limits replies to 512 tokens. The model still chooses fixed read-only probes. HTTP fixture tests and native Windows Q8 inference/bootstrap checks pass; sealed accuracy on the converted runtime is tracked separately.
|
|
61
|
+
|
|
62
|
+
### Run with Ollama
|
|
63
|
+
|
|
64
|
+
Set `HYDRA_BACKEND=ollama` first (`$env:HYDRA_BACKEND = 'ollama'` in PowerShell; `export HYDRA_BACKEND=ollama` in Bash).
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 1. Download the small local model (1.2 GB)
|
|
68
|
+
node skills/hydra/scripts/hydra.mjs setup
|
|
69
|
+
|
|
70
|
+
# 2. Ask questions about any repo
|
|
71
|
+
cd <any git repository>
|
|
72
|
+
node <path>/skills/hydra/scripts/hydra.mjs ask "who changed package.json most recently and why?"
|
|
73
|
+
|
|
74
|
+
# 3. Slice files, symbols, or show structural outlines
|
|
75
|
+
node <path>/skills/hydra/scripts/hydra.mjs read src/index.ts handleRequest
|
|
76
|
+
node <path>/skills/hydra/scripts/hydra.mjs read src/server.ts --lines 20-50
|
|
77
|
+
node <path>/skills/hydra/scripts/hydra.mjs read src/config.py --outline
|
|
78
|
+
|
|
79
|
+
# 4. Run test and build commands through hydra
|
|
80
|
+
node <path>/skills/hydra/scripts/hydra.mjs run -- npm test
|
|
81
|
+
node <path>/skills/hydra/scripts/hydra.mjs run -- pytest
|
|
82
|
+
|
|
83
|
+
# 5. View token savings
|
|
84
|
+
node <path>/skills/hydra/scripts/hydra.mjs stats
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Install as a skill
|
|
88
|
+
|
|
89
|
+
Everything an agent needs is inside `skills/hydra`:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx skills add rahul05ranjan/hydra --skill hydra
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This installs the skill instructions and bundled Node CLI. It does **not** install `llama-server`, download weights or start inference: the [skills installer](https://github.com/vercel-labs/skills) copies/links skill files, and [install lifecycle hooks](https://github.com/vercel-labs/skills/issues/1155) remain a feature request. The bundled CLI can run `read` and `search` immediately; model-backed calls need the runtime described above.
|
|
96
|
+
|
|
97
|
+
A complete bootstrap is provided separately:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx github:rahul05ranjan/hydra
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
It installs the skill globally for every agent it finds (Claude Code if `~/.claude` exists, Codex if `~/.codex` exists; name others with `--agent <id>`), downloads a pinned llama.cpp runtime and the approximately 812 MB Hydra Nano Git Q8 GGUF, verifies SHA-256 hashes, and writes configuration under `~/.hydra`. Node 18+ with npm is required. Windows x64/arm64 CPU, macOS x64/arm64, and Ubuntu-compatible Linux x64/arm64 runtime artifacts are supported. Windows has live verification; other platform packages have not been exercised here.
|
|
104
|
+
|
|
105
|
+
For Claude Code the bootstrap also registers two Claude Code hooks in `~/.claude/settings.json`, because an agent that merely has the skill rarely uses it. A `PreToolUse` hook turns a direct test or build run (npm/pnpm/yarn test or build, jest, vitest, pytest, unittest, `node --test`, cargo, go, gradle, mvn, dotnet, make test) back with the `hydra run --` command to use instead; prefixing a command with `HYDRA_RAW=1` lets the raw log through. A `SessionStart` hook tells each new session to ask Hydra about git history and to keep Read and Grep for source files, where Hydra does not save tokens. Other settings are kept, the original file is saved as `settings.json.before-hydra`, and an invalid settings file is left untouched. Skip the hooks with `--no-hooks`; manage them later with `hydra hooks install|remove|status`.
|
|
106
|
+
|
|
107
|
+
The first bootstrap shares the Git model across all model-backed heads; it does not download five specialist weights. Runtime downloads and configuration stay outside agent skill folders, so skill updates retain them. Hydra starts its managed server on `127.0.0.1:11435` when needed; it stays running until `hydra stop` or a reboot. Run the installed `scripts/hydra.mjs doctor` to check readiness. `HYDRA_HOME` changes the data/config directory; explicit backend, URL and model environment variables override managed defaults.
|
|
108
|
+
|
|
109
|
+
From a local checkout, run `node skills/hydra/scripts/install.mjs`. After skill-only installation, run the installed `scripts/install.mjs --runtime-only`. The code and immutable GGUF are published. The remote bootstrap was verified on Windows on 2026-10-12, including installed-skill readiness and model hash verification; see [the receipt](evals/results/remote-bootstrap-windows.json).
|
|
110
|
+
|
|
111
|
+
For Kaggle evaluation, put `KAGGLE_USERNAME` and `KAGGLE_API_TOKEN` in root `.env` using [`.env.example`](.env.example). `train/kaggle/control.py` loads that file, prepares private frozen inputs, and separates upload from GPU execution. `run --approved` is only for an explicitly approved 30-minute evaluation; the kernel trains nothing, verifies source/model hashes, and rejects CPU fallback. Tokens are never embedded in the uploaded source bundle.
|
|
112
|
+
|
|
113
|
+
Or copy `skills/hydra` directly to your agent's skills directory:
|
|
114
|
+
- Claude Code: `~/.claude/skills/hydra`
|
|
115
|
+
- Antigravity: `~/.gemini/config/skills/hydra`
|
|
116
|
+
|
|
117
|
+
## Evaluations & Benchmarks
|
|
118
|
+
|
|
119
|
+
### Strict comparison against targeted commands
|
|
120
|
+
|
|
121
|
+
`npm run eval:strict` creates an isolated development repository, executes 12 tasks through concise direct commands and Hydra, and checks complete source slices, file sets, ordered commit records, failure/pass facts and exit codes. It uses no sealed `git1` inputs. The latest run passed **12/12 on both routes**, but Hydra returned **866 estimated tokens versus 460** for targeted commands (**88.3% more output**). These are character-count estimates and do not measure actual frontier-agent usage.
|
|
122
|
+
|
|
123
|
+
The older whole-file trial is retained as a historical result; its weak substring score is not answer accuracy. See `TRACKER.md` for the audit.
|
|
124
|
+
|
|
125
|
+
The first actual Claude Code A/B run used `claude-opus-5-5`, with **6/6 correct in each arm**. Direct tools consumed **118,215** reported input-plus-output tokens and Hydra **112,431** (**4.89% fewer**). Trace review found that the harness denied a legitimate direct `git diff-tree` attempt; permission-denial-free pairs instead consumed **2.63% more tokens with Hydra**. This six-task single-run fixture does not establish general savings. The whitelist and workspace isolation have been corrected for future runs. The [frontier report](evals/results/frontier/2026-10-10T11-08-52-051Z/SUMMARY.md) includes the limitations and links to full traces.
|
|
126
|
+
|
|
127
|
+
`npm run eval:frontier:prepare` prepares a six-task Claude Code A/B trial without model calls. `npm run eval:frontier` launches 12 fresh sessions after user approval, with direct tools versus explicit Hydra delegation. It records exact structured-answer checks, actual reported input/output tokens including cached input, cost, tool errors, tool calls, turns and elapsed time. Sessions use isolated copies of the fixture, the same configured frontier model, a frozen Hydra runtime, a $0.50 budget setting per session and a 10-minute overall time limit. This measures repository-inspection tasks in a controlled fixture; spontaneous skill adoption and full software-development workloads require further trials.
|
|
128
|
+
|
|
129
|
+
`node evals/trial/analyze_frontier.mjs <run-directory>` independently checks saved answers against gold and reports overall and permission-denial-free pairs without new model calls. Fixture workspaces live under `~/.hydra/trials/frontier`, outside this project.
|
|
130
|
+
|
|
131
|
+
### Repeated real-source and natural-adoption trial
|
|
132
|
+
|
|
133
|
+
`npm run eval:real:prepare` freezes four function-extraction tasks from Vasuki and Dhruv CLI, independent parser gold, source hashes and the production skill. The 69-file source corpus has 9,375 lines. Three fresh sessions per task compare native tools, Hydra available without a usage instruction, and explicit Hydra delegation: **36 sessions** with a **20-minute** deadline and **$18** total configured API-cost-equivalent budget. This tests source inspection and complete function extraction.
|
|
134
|
+
|
|
135
|
+
After explicit run approval, use `npm run eval:real -- --prepared <directory>`. The runner checks startup skill discovery, unchanged sources and models, and permission errors; it preserves every factual failure. `node evals/trial/analyze_real_repo.mjs <directory>` audits saved traces without model calls. See the [predeclared protocol](evals/trial/REAL_REPO_PROTOCOL.md) for arm ordering, exact correctness and exploratory task-cluster intervals.
|
|
136
|
+
|
|
137
|
+
The approved run completed **36/36 sessions**, with **12/12 correct in every arm** and no protocol violations. Native tools used **387,115** total reported tokens, skill availability **391,296 (+1.08%)**, and explicit Hydra delegation **667,303 (+72.38%)**. Claude chose Hydra in **0/12** available sessions and **12/12** forced sessions. Runtime was **513.9 seconds** and reported API-cost equivalent **$2.7095**. Token savings were absent on these four tasks. Trace audit found Python symbol slices that included unrelated code or omitted part of the function; native fallback restored complete answers. See the [full report](evals/results/real-repo/2026-10-10T11-57-49-798Z/SUMMARY.md) and [evidence audit](evals/results/real-repo/2026-10-10T11-57-49-798Z/AUDIT.md).
|
|
138
|
+
|
|
139
|
+
### 1. `evals/git1` (1000 tasks, sealed git test set)
|
|
140
|
+
|
|
141
|
+
50 generated repositories, 20 kinds of question, 10 phrasings each. Verified by git gold facts and usage weighting.
|
|
142
|
+
|
|
143
|
+
- **Baseline (`qwen3.5:0.8b`)**: 70% solved (69% weighted by real usage), plan accuracy 74%, 10 errors.
|
|
144
|
+
- **Improved with JSON prompt grounding**: **77% solved (76% weighted)**, plan accuracy **80%**, **0 errors**, runtime dropped from 21.2 min to **3.5 min**.
|
|
145
|
+
- `staged_files`: 0% ➔ 100% (+100 points)
|
|
146
|
+
- `message_search`: 4% ➔ 72% (+68 points)
|
|
147
|
+
- `commit_files`: 46% ➔ 72% (+26 points)
|
|
148
|
+
|
|
149
|
+
Full results in `evals/results/git1.qwen3.5-0.8b.json`.
|
|
150
|
+
|
|
151
|
+
### 2. `evals/test_logs` (20 cross-language tasks)
|
|
152
|
+
|
|
153
|
+
Benchmarks failure extraction and noise reduction across Vitest, Jest, Pytest, Cargo, TSC, Go, node:test, and Mocha.
|
|
154
|
+
|
|
155
|
+
- **Solved**: **100% (20/20)**
|
|
156
|
+
- **Test Name Recall**: **100%**
|
|
157
|
+
- **File / Line Location Recall**: **100%**
|
|
158
|
+
- **Assertion Diff Recall**: **100%**
|
|
159
|
+
- **Cleanliness**: **100%** (zero framework or `node_modules` stack frame pollution)
|
|
160
|
+
- **Token Savings**: **49.6% net token reduction** overall, and **96.4% to 96.7%** on verbose test suites.
|
|
161
|
+
- **Runtime**: **3.2s** across all 20 tasks.
|
|
162
|
+
|
|
163
|
+
Full results in `evals/results/test_logs.qwen3.5-0.8b.json`.
|
|
164
|
+
|
|
165
|
+
### 3. `evals/read` (20 cross-language tasks)
|
|
166
|
+
|
|
167
|
+
Benchmarks targeted symbol extraction, line range slicing, and file outlines across TypeScript, JavaScript, Python, Rust, and Go to address the #1 token sink (75.5% of tool tokens).
|
|
168
|
+
|
|
169
|
+
- **Solved**: **100% (20/20)**
|
|
170
|
+
- **Target Line Recall**: **100%**
|
|
171
|
+
- **Cleanliness**: **100%** (zero unrelated function/code leak)
|
|
172
|
+
- **Token Savings**: **48.1% net token reduction** overall, and **77% to 92%** on targeted line and symbol slices.
|
|
173
|
+
- **Runtime**: **0.01s** (instantaneous local extraction).
|
|
174
|
+
|
|
175
|
+
Full results in `evals/results/read.json`.
|
|
176
|
+
|
|
177
|
+
## Layout
|
|
178
|
+
|
|
179
|
+
- `skills/hydra/SKILL.md`: tells an agent when to delegate and how to read the result.
|
|
180
|
+
- `skills/hydra/scripts/hydra.mjs`: the CLI.
|
|
181
|
+
- `skills/hydra/scripts/lib/`:
|
|
182
|
+
- `runtime.mjs`: selectable Ollama/llama.cpp API client and per-head model configuration.
|
|
183
|
+
- `route.mjs`: route questions between heads.
|
|
184
|
+
- `git.mjs`: git head probes and plan step.
|
|
185
|
+
- `files.mjs`: search and walk head.
|
|
186
|
+
- `read.mjs`: file slice and symbol reader head.
|
|
187
|
+
- `test_logs.mjs`: test runner and build log reader head.
|
|
188
|
+
- `answer.mjs`: verbatim line selection and lead generation.
|
|
189
|
+
- `ollama.mjs`: compatibility exports for existing evaluation callers.
|
|
190
|
+
- `ledger.mjs`: local token accounting ledger.
|
|
191
|
+
- `test/`: unit test suite (`npm test`).
|
|
192
|
+
- `evals/git1/`: 1000-task sealed test set for git head.
|
|
193
|
+
- `evals/test_logs/`: 20-task cross-language benchmark for test and build logs.
|
|
194
|
+
- `evals/read/`: 20-task cross-language benchmark for file slice reading.
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hydra-nano",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Small local models that Claude Code and Codex hand routine read-only repo work to: git questions, test and build digests, file slicing, code search and OS inspection",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude-code",
|
|
7
|
+
"codex",
|
|
8
|
+
"agent-skill",
|
|
9
|
+
"local-llm",
|
|
10
|
+
"llama.cpp",
|
|
11
|
+
"git",
|
|
12
|
+
"test-runner",
|
|
13
|
+
"token-saving"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "rahul05ranjan",
|
|
17
|
+
"homepage": "https://github.com/rahul05ranjan/hydra#readme",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/rahul05ranjan/hydra.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/rahul05ranjan/hydra/issues"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"bin": {
|
|
27
|
+
"hydra-nano": "skills/hydra/scripts/install.mjs",
|
|
28
|
+
"hydra": "skills/hydra/scripts/hydra.mjs",
|
|
29
|
+
"hydra-install": "skills/hydra/scripts/install.mjs"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "node --test",
|
|
33
|
+
"eval": "node evals/run.mjs",
|
|
34
|
+
"eval:build": "node evals/git1/build.mjs",
|
|
35
|
+
"eval:test": "node evals/test_logs/run.mjs",
|
|
36
|
+
"eval:test:build": "node evals/test_logs/build.mjs",
|
|
37
|
+
"eval:read": "node evals/read/run.mjs",
|
|
38
|
+
"eval:read:build": "node evals/read/build.mjs",
|
|
39
|
+
"eval:files": "node evals/files/run.mjs",
|
|
40
|
+
"eval:strict": "node evals/trial/strict_trial.mjs",
|
|
41
|
+
"eval:frontier:prepare": "node evals/trial/frontier_trial.mjs",
|
|
42
|
+
"eval:frontier": "node evals/trial/frontier_trial.mjs --run",
|
|
43
|
+
"eval:real:prepare": "node evals/trial/real_repo_trial.mjs",
|
|
44
|
+
"eval:real": "node evals/trial/real_repo_trial.mjs --run",
|
|
45
|
+
"dashboard": "node dashboard/server.mjs"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"skills/hydra"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hydra
|
|
3
|
+
description: Hand a read-only git question (repo state, history, blame), a where-is-it code search, targeted file slicing instead of whole-file reads, test/build failure digests, or system/OS inspections (ports, processes, disk) to hydra locally. Use before running git status, log, diff, show, blame, broad searches, whole file reads, ps/lsof dumps, or test/build commands where noisy output would flood your context.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hydra
|
|
7
|
+
|
|
8
|
+
`hydra` runs read-only commands for repo questions, file slicing, test/build runs, and system inspections on a small local model and prints the lines that answer it. The raw output stays on this machine instead of entering your context.
|
|
9
|
+
|
|
10
|
+
## Call it
|
|
11
|
+
|
|
12
|
+
From the repository the question is about, naming the head that fits:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
node scripts/hydra.mjs ask --head git "<question>"
|
|
16
|
+
node scripts/hydra.mjs ask --head files "<question>"
|
|
17
|
+
node scripts/hydra.mjs ask --head read "<question>"
|
|
18
|
+
node scripts/hydra.mjs ask --head test "<question>"
|
|
19
|
+
node scripts/hydra.mjs ask --head os "<question>"
|
|
20
|
+
node scripts/hydra.mjs search <term...>
|
|
21
|
+
node scripts/hydra.mjs read <file> [symbol|--lines <start-end>|--outline]
|
|
22
|
+
node scripts/hydra.mjs run -- <command...>
|
|
23
|
+
node scripts/hydra.mjs os [question...]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`scripts/` is in this skill's directory. Ask one full question per call and name the file, branch, commit or author when you know it: the model may only use a path, revision or name that appears in your question.
|
|
27
|
+
- For finding definitions & files: use `hydra search <term>` to get definition-ranked matches without noise or raw grep dumps.
|
|
28
|
+
- For reading code: use `hydra read <file> [symbol|--lines]` instead of reading multi-thousand-line files. It returns the exact symbol or slice, or a structural outline of symbols.
|
|
29
|
+
- For tests and builds: run `hydra run -- <command...>` to execute the command locally and get the failure evidence with its exit code.
|
|
30
|
+
- For system and environment: use `hydra os` or `--head os` to inspect listening ports, top processes, disk space, and system info without dumping 500 lines of terminal output into context.
|
|
31
|
+
|
|
32
|
+
## What it answers
|
|
33
|
+
|
|
34
|
+
- **git**: current branch and sync state, uncommitted and staged changes, commit history, what this branch adds over a base branch, one commit's patch, blame, branches, worktrees, remotes, stashes, tags.
|
|
35
|
+
- **files**: where a name is defined or used, and which files are named like it.
|
|
36
|
+
- **read**: extracts symbol definitions (functions, classes, methods), line ranges (`--lines 10-50`), or structural definition outlines across TypeScript, JavaScript, Python, Rust, and Go without dumping whole files into context.
|
|
37
|
+
- **test**: runs and parses test and build outputs (`npm test`, `pytest`, `cargo test`, `tsc`). If tests fail, extracts the failing test name, assertion diff, and exact user file:line location, stripping node_modules and framework traces.
|
|
38
|
+
- **os**: inspects listening ports (`lsof`), running processes / CPU consumers (`ps`), disk space (`df -h`), and system info (`uptime`, `uname`) while strictly guarding against printing secrets.
|
|
39
|
+
|
|
40
|
+
Changes to the repository, and questions that need reasoning about what code does, stay with you.
|
|
41
|
+
|
|
42
|
+
## Read the result
|
|
43
|
+
|
|
44
|
+
- Lines under each `$ command` are the command's own output, copied verbatim. Build on these.
|
|
45
|
+
- `Selected evidence:` introduces verbatim lines chosen by the local model. Interpret these lines yourself; Hydra does not generate a factual lead.
|
|
46
|
+
- Git lists (status, commits, branches, stashes, tags, remotes, worktrees) are returned whole. Put an explicit count in commit-history questions; the supported maximum is 50.
|
|
47
|
+
- `(N more lines not shown)` means output was withheld. When the lines shown do not settle the question, run that one command yourself.
|
|
48
|
+
|
|
49
|
+
## When it cannot run
|
|
50
|
+
|
|
51
|
+
Exit code 2 with `hydra unavailable` means the configured model is not ready. Run `node scripts/hydra.mjs doctor` to check it. For the default llama.cpp backend, run the installed `scripts/install.mjs --runtime-only` to download the pinned runtime and GGUF after telling the user the download size and that a background server will stay running. The managed config is in `~/.hydra`; Hydra starts its server when needed and `node scripts/hydra.mjs stop` stops it. The initial bootstrap shares one Git model across heads. For an external server, set `HYDRA_LLAMA_URL` to its root (without `/v1`) and `HYDRA_MODEL` to its alias. For Ollama, set `HYDRA_BACKEND=ollama`; its `setup` downloads models, so tell the user before starting it. `npx skills add` installs skill/CLI files only; `npx github:rahul05ranjan/hydra` performs the full bootstrap. If the runtime cannot be made available, do the task directly and report the limitation.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Claude Code PreToolUse hook (Bash): a test or build run goes through `hydra run --`, whose digest
|
|
3
|
+
// keeps failing test names, assertion diffs and source locations and drops the rest of the log.
|
|
4
|
+
// Prefix a command with HYDRA_RAW=1 when the raw log is really needed.
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { testRun } from '../lib/claude_hooks.mjs';
|
|
8
|
+
|
|
9
|
+
const hydra = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'hydra.mjs');
|
|
10
|
+
let input = '';
|
|
11
|
+
process.stdin.on('data', chunk => { input += chunk; }).on('end', () => {
|
|
12
|
+
let command = '';
|
|
13
|
+
try { command = JSON.parse(input).tool_input?.command ?? ''; } catch { return; }
|
|
14
|
+
const run = testRun(command);
|
|
15
|
+
if (!run) return;
|
|
16
|
+
process.stdout.write(JSON.stringify({ hookSpecificOutput: {
|
|
17
|
+
hookEventName: 'PreToolUse', permissionDecision: 'deny',
|
|
18
|
+
permissionDecisionReason: `Test/build runs go through Hydra so the full log stays out of context. Run it as:\n` +
|
|
19
|
+
` node "${hydra}" run -- ${run}\n(keep any cd or env prefix before it). Hydra returns the failing tests, ` +
|
|
20
|
+
`assertion diffs and source locations verbatim, or a short pass summary. If you truly need the raw log, ` +
|
|
21
|
+
`prefix the original command with HYDRA_RAW=1.` } }));
|
|
22
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Claude Code SessionStart hook: tells the agent where Hydra pays off, so it uses it without being asked.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const hydra = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'hydra.mjs');
|
|
7
|
+
process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext:
|
|
8
|
+
`Hydra is installed: it runs noisy read-only commands on a small local model and returns only the lines that matter.\n` +
|
|
9
|
+
`- For git history, diff, blame or "what changed" questions, first run: node "${hydra}" ask --head git "<question>" ` +
|
|
10
|
+
`from the repository, instead of reading git log, git diff or git show output yourself. Use plain git for writes ` +
|
|
11
|
+
`and for short checks such as git status --short.\n` +
|
|
12
|
+
`- A hook sends test and build runs through: node "${hydra}" run -- <command>\n` +
|
|
13
|
+
`- Keep using Read and Grep for source files; Hydra does not save tokens there.` } }));
|