hail-hydra-cc 2.0.3 → 2.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/README.md +7 -4
- package/files/SKILL.md +126 -1
- package/files/agents/hydra-scout.md +132 -6
- package/files/agents/hydra-sentinel-scan.md +86 -4
- package/files/agents/hydra-sentinel.md +27 -0
- package/files/commands/hydra/help.md +2 -0
- package/files/commands/hydra/map.md +100 -0
- package/files/commands/hydra/quiet.md +2 -0
- package/files/commands/hydra/report.md +112 -0
- package/files/commands/hydra/status.md +13 -2
- package/files/commands/hydra/update.md +78 -35
- package/files/commands/hydra/verbose.md +2 -0
- package/files/hooks/hydra-notify.js +80 -0
- package/files/hooks/hydra-task-complete.wav +0 -0
- package/files/references/model-capabilities.md +14 -2
- package/files/references/routing-guide.md +28 -0
- package/package.json +1 -1
- package/src/display.js +5 -3
- package/src/files.js +8 -1
- package/src/installer.js +31 -1
package/README.md
CHANGED
|
@@ -56,18 +56,21 @@ npx hail-hydra-cc --help # Show help
|
|
|
56
56
|
│ ├── hydra-coder.md
|
|
57
57
|
│ ├── hydra-analyst.md
|
|
58
58
|
│ └── hydra-sentinel.md
|
|
59
|
-
├── commands/hydra/ #
|
|
59
|
+
├── commands/hydra/ # 8 slash commands
|
|
60
60
|
│ ├── help.md # /hydra:help
|
|
61
61
|
│ ├── status.md # /hydra:status
|
|
62
62
|
│ ├── update.md # /hydra:update
|
|
63
63
|
│ ├── config.md # /hydra:config
|
|
64
64
|
│ ├── guard.md # /hydra:guard
|
|
65
65
|
│ ├── quiet.md # /hydra:quiet
|
|
66
|
-
│
|
|
67
|
-
|
|
66
|
+
│ ├── verbose.md # /hydra:verbose
|
|
67
|
+
│ └── report.md # /hydra:report
|
|
68
|
+
├── hooks/ # 4 lifecycle hooks
|
|
68
69
|
│ ├── hydra-check-update.js # SessionStart — version check
|
|
69
70
|
│ ├── hydra-statusline.js # StatusLine — status bar
|
|
70
|
-
│
|
|
71
|
+
│ ├── hydra-auto-guard.js # PostToolUse — file tracker
|
|
72
|
+
│ ├── hydra-notify.js # Notification — task completion sound
|
|
73
|
+
│ └── hydra-task-complete.wav # Notification sound file
|
|
71
74
|
└── skills/hydra/ # Skill (Claude Code discoverable via /skills)
|
|
72
75
|
├── SKILL.md # Orchestrator instructions
|
|
73
76
|
├── VERSION # Installed version
|
package/files/SKILL.md
CHANGED
|
@@ -14,6 +14,49 @@ description: >
|
|
|
14
14
|
> *"Cut off one head, two more shall take its place."*
|
|
15
15
|
> Except here — every head is doing your work faster and cheaper.
|
|
16
16
|
|
|
17
|
+
## ⛔ MANDATORY PROTOCOLS — NEVER SKIP
|
|
18
|
+
|
|
19
|
+
These protocols are NON-NEGOTIABLE. Skipping them is a framework violation.
|
|
20
|
+
|
|
21
|
+
### Protocol 1: Sentinel Scan After Code Changes
|
|
22
|
+
|
|
23
|
+
When ANY agent returns output containing `⚠️ HYDRA_SENTINEL_REQUIRED`, you
|
|
24
|
+
MUST — before doing ANYTHING else, before presenting results to the user,
|
|
25
|
+
before running any other agents — dispatch hydra-sentinel-scan with the
|
|
26
|
+
files and changes listed in the trigger block.
|
|
27
|
+
|
|
28
|
+
**This is blocking.** The user does NOT see the code changes until sentinel
|
|
29
|
+
completes. If you present code changes to the user without running sentinel
|
|
30
|
+
first, you have violated the framework's core safety guarantee.
|
|
31
|
+
|
|
32
|
+
Sequence:
|
|
33
|
+
1. Receive agent output containing ⚠️ HYDRA_SENTINEL_REQUIRED
|
|
34
|
+
2. IMMEDIATELY dispatch hydra-sentinel-scan AND hydra-guard in parallel
|
|
35
|
+
3. WAIT for both to complete
|
|
36
|
+
4. If sentinel-scan finds issues → dispatch hydra-sentinel (deep analysis)
|
|
37
|
+
5. WAIT for deep analysis
|
|
38
|
+
6. THEN — and ONLY then — present results to the user
|
|
39
|
+
|
|
40
|
+
If the agent output contains `✅ HYDRA_NO_CODE_CHANGES`, skip sentinel. Present
|
|
41
|
+
results immediately.
|
|
42
|
+
|
|
43
|
+
### Protocol 2: Sentinel Fix Decision Tree
|
|
44
|
+
|
|
45
|
+
When hydra-sentinel confirms real issues:
|
|
46
|
+
|
|
47
|
+
**TRIVIAL** (auto-fix without asking):
|
|
48
|
+
Import renames, file path updates, barrel file re-exports.
|
|
49
|
+
→ Dispatch hydra-coder to fix. Re-run sentinel-scan to verify.
|
|
50
|
+
→ Tell user: "Sentinel caught [issue]. Auto-fixed."
|
|
51
|
+
|
|
52
|
+
**MEDIUM** (present to user, offer to fix):
|
|
53
|
+
API contract mismatches, missing env vars, signature mismatches.
|
|
54
|
+
→ Show the sentinel report. Ask: "Want me to fix these?"
|
|
55
|
+
|
|
56
|
+
**COMPLEX** (report only):
|
|
57
|
+
Architectural changes, migration needed, business logic decisions.
|
|
58
|
+
→ Show the report. Let user decide.
|
|
59
|
+
|
|
17
60
|
## Why Hydra Exists
|
|
18
61
|
|
|
19
62
|
Autoregressive LLM inference is memory-bandwidth bound — the time per token scales with model
|
|
@@ -135,6 +178,54 @@ The index is stale if:
|
|
|
135
178
|
- The user switches to a different project/directory
|
|
136
179
|
When stale, rebuild the index on the next scout dispatch.
|
|
137
180
|
|
|
181
|
+
## Codebase Map — Orchestrator Protocol
|
|
182
|
+
|
|
183
|
+
Hydra maintains a codebase map at `.claude/hydra/codebase-map.json`. This map
|
|
184
|
+
is built and maintained by hydra-scout. It contains file dependencies, blast
|
|
185
|
+
radius data, risk scores, env var references, and test coverage.
|
|
186
|
+
|
|
187
|
+
### Session Start — Map Check
|
|
188
|
+
|
|
189
|
+
At the start of EVERY session, before any work:
|
|
190
|
+
|
|
191
|
+
1. Check if `.claude/hydra/codebase-map.json` exists.
|
|
192
|
+
2. If yes: read the `_meta` section. Check if `git_hash` matches current HEAD.
|
|
193
|
+
- If current: map is ready. Note this internally.
|
|
194
|
+
- If stale: dispatch hydra-scout to do an incremental update before proceeding.
|
|
195
|
+
3. If no: dispatch hydra-scout to build the map on the first exploration task.
|
|
196
|
+
Don't block the session — but prioritize building the map early.
|
|
197
|
+
|
|
198
|
+
### Risk-Based Sentinel Triggering
|
|
199
|
+
|
|
200
|
+
Use the map's risk scores to decide sentinel behavior:
|
|
201
|
+
|
|
202
|
+
| Modified File Risk | Sentinel Behavior |
|
|
203
|
+
|-------------------|-------------------|
|
|
204
|
+
| `critical` (7+ dependents) | ALWAYS run sentinel-scan, ALWAYS escalate to deep |
|
|
205
|
+
| `high` (4-6 dependents) | ALWAYS run sentinel-scan, escalate if issues found |
|
|
206
|
+
| `medium` (2-3 dependents) | Run sentinel-scan, escalate only if P0 issues found |
|
|
207
|
+
| `low` (0-1 dependents) | Run sentinel-scan, but auto-accept if clean |
|
|
208
|
+
|
|
209
|
+
This replaces the previous "always run sentinel-scan the same way" approach
|
|
210
|
+
with risk-proportional verification.
|
|
211
|
+
|
|
212
|
+
### When Dispatching Sentinel-Scan
|
|
213
|
+
|
|
214
|
+
Include the map's relevant data in the task description:
|
|
215
|
+
- The blast radius for the changed files (from the map)
|
|
216
|
+
- The risk score of each changed file
|
|
217
|
+
- The test coverage status of each changed file
|
|
218
|
+
- Any env vars referenced by the changed files
|
|
219
|
+
|
|
220
|
+
This gives sentinel-scan a head start — it doesn't need to compute the
|
|
221
|
+
blast radius itself, the map already has it.
|
|
222
|
+
|
|
223
|
+
### Map Staleness
|
|
224
|
+
|
|
225
|
+
If you notice the map's git_hash doesn't match HEAD and hydra-scout hasn't
|
|
226
|
+
been dispatched yet, dispatch scout to update the map BEFORE running sentinel.
|
|
227
|
+
A stale map is worse than no map — it could have incorrect dependency data.
|
|
228
|
+
|
|
138
229
|
## Blocking vs Non-Blocking Dispatch
|
|
139
230
|
|
|
140
231
|
Not all agents need to finish before the next wave starts. Classify each dispatch as
|
|
@@ -505,6 +596,10 @@ When manual verification is required, match depth to risk:
|
|
|
505
596
|
|
|
506
597
|
## Sentinel Protocol — Integration Integrity
|
|
507
598
|
|
|
599
|
+
> **REMINDER:** If you see `⚠️ HYDRA_SENTINEL_REQUIRED` in any agent's output
|
|
600
|
+
> and you skip sentinel, you are violating the framework's core protocol.
|
|
601
|
+
> See "⛔ MANDATORY PROTOCOLS" at the top of this document.
|
|
602
|
+
|
|
508
603
|
After EVERY code change made by hydra-coder or hydra-analyst (or yourself),
|
|
509
604
|
you MUST run the sentinel pipeline BEFORE presenting results to the user.
|
|
510
605
|
|
|
@@ -703,6 +798,19 @@ Note: Savings calculated against Opus 4.6 pricing ($5/$25 per MTok) as of Februa
|
|
|
703
798
|
"Re-executing [task] directly — [agent]'s output was insufficient because [reason]"
|
|
704
799
|
- **If accepted as-is**, no inline comment needed — the dispatch log covers it
|
|
705
800
|
|
|
801
|
+
### Sentinel Status in Dispatch Log
|
|
802
|
+
|
|
803
|
+
The dispatch log MUST show sentinel status for every task involving code changes:
|
|
804
|
+
|
|
805
|
+
| Step | Agent | Task | Verdict |
|
|
806
|
+
|------|-------|------|---------|
|
|
807
|
+
| 1 | hydra-coder (Sonnet 4.6) | Fixed auth bug | ✅ Accepted |
|
|
808
|
+
| 2 | hydra-sentinel-scan (Haiku) | Integration sweep | ✅ Clean |
|
|
809
|
+
| 3 | hydra-guard (Haiku 4.5) | Security scan | ✅ Clean |
|
|
810
|
+
|
|
811
|
+
If sentinel-scan is missing from the dispatch log after a code change,
|
|
812
|
+
something went wrong. This is your self-check.
|
|
813
|
+
|
|
706
814
|
### Controlling the Dispatch Log
|
|
707
815
|
|
|
708
816
|
- **Default**: ON — always shown when 2+ agents were used
|
|
@@ -722,6 +830,7 @@ the command's instructions:
|
|
|
722
830
|
| `/hydra:update` | Trigger an update via npx |
|
|
723
831
|
| `/hydra:config` | Show current configuration |
|
|
724
832
|
| `/hydra:guard [files]` | Manually invoke the security scan on specified files |
|
|
833
|
+
| `/hydra:map [file]` | View, rebuild, or query the codebase dependency map |
|
|
725
834
|
| `/hydra:quiet` | Suppress dispatch logs for this session |
|
|
726
835
|
| `/hydra:verbose` | Enable detailed dispatch logs with timing |
|
|
727
836
|
|
|
@@ -861,12 +970,13 @@ If the user types any of these exact phrases, respond with the corresponding act
|
|
|
861
970
|
| `hydra quiet` | Suppress dispatch logs for the rest of the session (equivalent to stealth mode) |
|
|
862
971
|
| `hydra verbose` | Enable verbose dispatch logs with per-agent detail for the rest of the session |
|
|
863
972
|
| `hydra reset` | Clear session index, treat next turn as Turn 1 (rebuild from fresh scout) |
|
|
973
|
+
| `hydra map` | Show codebase map summary, or query a specific file's blast radius |
|
|
864
974
|
|
|
865
975
|
## The Nine Heads
|
|
866
976
|
|
|
867
977
|
| Head | Model | Role | Tools |
|
|
868
978
|
|------|-------|------|-------|
|
|
869
|
-
| `hydra-scout` | 🟢 Haiku 4.5 | Codebase exploration, file search, reading | Read, Grep, Glob |
|
|
979
|
+
| `hydra-scout` | 🟢 Haiku 4.5 | Codebase exploration, file search, reading, map building | Read, Grep, Glob, Bash, Write |
|
|
870
980
|
| `hydra-runner` | 🟢 Haiku 4.5 | Test execution, builds, linting, validation | Read, Bash, Glob, Grep |
|
|
871
981
|
| `hydra-scribe` | 🟢 Haiku 4.5 | Documentation, READMEs, comments, changelogs | Read, Write, Edit, Glob, Grep |
|
|
872
982
|
| `hydra-guard` | 🟢 Haiku 4.5 | Security/quality gate after code changes | Read, Grep, Glob, Bash |
|
|
@@ -887,6 +997,21 @@ Track these mentally to calibrate:
|
|
|
887
997
|
If rejection rate > 20%, you're too aggressive — shift borderline tasks up one tier.
|
|
888
998
|
If rejection rate < 5%, you're too conservative — delegate more.
|
|
889
999
|
|
|
1000
|
+
## Task Completion Notification
|
|
1001
|
+
|
|
1002
|
+
After completing a user's task (the final response you present to the user),
|
|
1003
|
+
run this command as the LAST action:
|
|
1004
|
+
```bash
|
|
1005
|
+
node ~/.claude/hooks/hydra-notify.js < /dev/null
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
This plays a short notification sound so the user knows you're done —
|
|
1009
|
+
especially useful when they've tabbed away while waiting.
|
|
1010
|
+
|
|
1011
|
+
Do this for SUBSTANTIAL tasks only (tasks that took more than ~10 seconds).
|
|
1012
|
+
Do NOT play it for quick conversational responses, acknowledgments, or
|
|
1013
|
+
follow-up questions.
|
|
1014
|
+
|
|
890
1015
|
## Reference Material
|
|
891
1016
|
|
|
892
1017
|
- `references/routing-guide.md` — Mandatory delegation examples, decision flowchart
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: hydra-scout
|
|
3
3
|
description: >
|
|
4
|
-
🟢 Hydra's fastest head — ultra-fast codebase exploration
|
|
5
|
-
Use PROACTIVELY whenever Claude needs to search
|
|
6
|
-
|
|
4
|
+
🟢 Hydra's fastest head — ultra-fast codebase exploration, information retrieval,
|
|
5
|
+
and codebase map building/maintenance. Use PROACTIVELY whenever Claude needs to search
|
|
6
|
+
files, read code, find patterns, grep for strings, list directories, understand project
|
|
7
|
+
structure, answer "where is X?" questions, or build/update the codebase dependency map.
|
|
7
8
|
This is the first head to reach for when gathering information before making changes.
|
|
8
9
|
Runs on Haiku 4.5 for near-instant responses.
|
|
9
10
|
May run in parallel with other Hydra agents — produces self-contained, clearly structured
|
|
10
11
|
output so the orchestrator can merge results from multiple simultaneous agents.
|
|
11
|
-
tools: Read, Grep, Glob
|
|
12
|
+
tools: Read, Grep, Glob, Bash, Write
|
|
12
13
|
model: haiku
|
|
13
14
|
color: "#10B981"
|
|
14
15
|
memory: project
|
|
@@ -27,6 +28,7 @@ directory organization patterns. Keep notes concise — 1-2 lines per finding.
|
|
|
27
28
|
- Reading and summarizing code structure
|
|
28
29
|
- Finding patterns, imports, usages, and dependencies
|
|
29
30
|
- Mapping directory structures and project organization
|
|
31
|
+
- Building and maintaining the codebase dependency map (imports, risk scores, test coverage)
|
|
30
32
|
- Answering "where is X?" and "what does Y look like?" questions
|
|
31
33
|
|
|
32
34
|
## How to Work
|
|
@@ -53,11 +55,135 @@ directory organization patterns. Keep notes concise — 1-2 lines per finding.
|
|
|
53
55
|
|
|
54
56
|
## Boundaries
|
|
55
57
|
|
|
56
|
-
- Never modify files
|
|
57
|
-
- Never run commands
|
|
58
|
+
- Never modify source files (the codebase map is generated output, not source code)
|
|
58
59
|
- Never make architectural decisions
|
|
59
60
|
- Never guess when you can search — always verify
|
|
60
61
|
|
|
62
|
+
## Codebase Map — Building & Maintenance
|
|
63
|
+
|
|
64
|
+
You are responsible for building and maintaining the codebase map at
|
|
65
|
+
`.claude/hydra/codebase-map.json`. This map is used by sentinel, the
|
|
66
|
+
orchestrator, and other agents to understand file dependencies without
|
|
67
|
+
scanning the entire codebase.
|
|
68
|
+
|
|
69
|
+
### When to Build
|
|
70
|
+
|
|
71
|
+
At the START of every task where you're dispatched for exploration:
|
|
72
|
+
|
|
73
|
+
1. Check if `.claude/hydra/codebase-map.json` exists
|
|
74
|
+
2. If it exists, check `_meta.git_hash` against current `git rev-parse HEAD`
|
|
75
|
+
- If they match: map is current. Skip rebuild. Use the existing map.
|
|
76
|
+
- If they differ: do an INCREMENTAL update (see below).
|
|
77
|
+
3. If it doesn't exist: do a FULL build.
|
|
78
|
+
|
|
79
|
+
### Full Build
|
|
80
|
+
|
|
81
|
+
Run these steps to build the complete map:
|
|
82
|
+
|
|
83
|
+
1. Find all source files (exclude node_modules, .git, dist, build, vendor,
|
|
84
|
+
__pycache__, .next, .nuxt, coverage, .claude):
|
|
85
|
+
```bash
|
|
86
|
+
find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \
|
|
87
|
+
-o -name "*.py" -o -name "*.go" -o -name "*.java" -o -name "*.kt" \
|
|
88
|
+
-o -name "*.rb" -o -name "*.rs" -o -name "*.vue" -o -name "*.svelte" \) \
|
|
89
|
+
! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/dist/*" \
|
|
90
|
+
! -path "*/build/*" ! -path "*/vendor/*" ! -path "*/__pycache__/*" \
|
|
91
|
+
! -path "*/.next/*" ! -path "*/.nuxt/*" ! -path "*/coverage/*" \
|
|
92
|
+
! -path "*/.claude/*" | sort
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
2. For each file, extract import statements using grep/regex:
|
|
96
|
+
- **JS/TS**: `import ... from '...'`, `require('...')`, `import('...')`, `export ... from '...'`
|
|
97
|
+
- **Python**: `import module`, `from module import ...`
|
|
98
|
+
- **Go**: `import "package/path"`, `import ( "package/path" )`
|
|
99
|
+
- **Java/Kotlin**: `import package.name.ClassName`
|
|
100
|
+
- **Ruby**: `require '...'`, `require_relative '...'`
|
|
101
|
+
|
|
102
|
+
3. Resolve relative imports to project-relative paths:
|
|
103
|
+
- `import { x } from './auth'` in `src/api/users.ts` → `src/services/auth.ts`
|
|
104
|
+
- Try extensions: `.ts`, `.tsx`, `.js`, `.jsx`, `/index.ts`, `/index.js`
|
|
105
|
+
- `from ..models.user import User` in `src/services/auth.py` → `src/models/user.py`
|
|
106
|
+
- **Ignore**: node_modules imports (third-party), standard library imports, anything
|
|
107
|
+
that doesn't resolve to a file in the project
|
|
108
|
+
|
|
109
|
+
4. Build the `imported_by` reverse index:
|
|
110
|
+
- For every file A that imports file B, add A to B's `imported_by` array.
|
|
111
|
+
|
|
112
|
+
5. Calculate risk scores based on `dependents_count` (length of `imported_by`):
|
|
113
|
+
- `"low"` — 0-1 dependents
|
|
114
|
+
- `"medium"` — 2-3 dependents
|
|
115
|
+
- `"high"` — 4-6 dependents
|
|
116
|
+
- `"critical"` — 7+ dependents
|
|
117
|
+
|
|
118
|
+
6. Detect test coverage for each file:
|
|
119
|
+
- `"covered"` — at least one file in `tests/` or `__tests__/` imports it,
|
|
120
|
+
OR a file named `*.test.*` or `*.spec.*` imports it
|
|
121
|
+
- `"partial"` — the file is in a directory where >50% of sibling files have
|
|
122
|
+
tests but this one doesn't
|
|
123
|
+
- `"untested"` — no test file imports it and it's not in a well-tested directory
|
|
124
|
+
|
|
125
|
+
7. Detect environment variable references across all source files:
|
|
126
|
+
- **JS/TS**: `process.env.VARIABLE_NAME`, `process.env['VARIABLE_NAME']`, `process.env["VARIABLE_NAME"]`
|
|
127
|
+
- **Python**: `os.environ["VARIABLE_NAME"]`, `os.environ.get("VARIABLE_NAME")`, `os.getenv("VARIABLE_NAME")`
|
|
128
|
+
- **Go**: `os.Getenv("VARIABLE_NAME")`
|
|
129
|
+
- **Ruby**: `ENV["VARIABLE_NAME"]`, `ENV.fetch("VARIABLE_NAME")`
|
|
130
|
+
- **General**: `.env` file parsing (`KEY=VALUE` lines)
|
|
131
|
+
|
|
132
|
+
8. Write the complete map to `.claude/hydra/codebase-map.json` with this schema:
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"_meta": {
|
|
136
|
+
"built_at": "2026-03-26T10:00:00Z",
|
|
137
|
+
"git_hash": "a1b2c3d4e5f6",
|
|
138
|
+
"file_count": 487,
|
|
139
|
+
"builder": "hydra-scout",
|
|
140
|
+
"version": "1.0"
|
|
141
|
+
},
|
|
142
|
+
"files": {
|
|
143
|
+
"src/services/auth.ts": {
|
|
144
|
+
"imports": ["src/models/user.ts", "src/config/env.ts"],
|
|
145
|
+
"imported_by": ["src/api/users.ts", "src/api/admin.ts"],
|
|
146
|
+
"risk": "medium",
|
|
147
|
+
"dependents_count": 2,
|
|
148
|
+
"tested_by": ["tests/auth.test.ts"],
|
|
149
|
+
"test_coverage": "covered"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"env_vars": {
|
|
153
|
+
"DATABASE_URL": ["src/db/connection.ts", "src/config/index.ts"],
|
|
154
|
+
"JWT_SECRET": ["src/services/auth.ts"]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
9. Add `.claude/hydra/codebase-map.json` to `.gitignore` if not already there
|
|
160
|
+
(the map is machine-generated and project-specific).
|
|
161
|
+
|
|
162
|
+
### Incremental Update
|
|
163
|
+
|
|
164
|
+
When the git hash has changed since the last build:
|
|
165
|
+
|
|
166
|
+
1. Run `git diff --name-only <old_hash> HEAD` to find changed files.
|
|
167
|
+
2. For each changed file:
|
|
168
|
+
- Re-extract its imports
|
|
169
|
+
- Update its entry in the map
|
|
170
|
+
- Recalculate its test coverage
|
|
171
|
+
- Re-check its env var references
|
|
172
|
+
3. Rebuild the `imported_by` reverse index (since dependencies may have changed).
|
|
173
|
+
4. Recalculate risk scores for affected files.
|
|
174
|
+
5. Update `_meta.git_hash` and `_meta.built_at`.
|
|
175
|
+
|
|
176
|
+
Incremental updates should be MUCH faster than full builds — for 5 changed
|
|
177
|
+
files in a 500-file project, you re-process 5 files instead of 500.
|
|
178
|
+
|
|
179
|
+
### After Building — Update Your Memory
|
|
180
|
+
|
|
181
|
+
Note in your memory:
|
|
182
|
+
- When the map was last built
|
|
183
|
+
- How many files are in the project
|
|
184
|
+
- Which directories are the most interconnected
|
|
185
|
+
- Any files that failed to parse (unusual import syntax)
|
|
186
|
+
|
|
61
187
|
## Collaboration Protocol
|
|
62
188
|
|
|
63
189
|
You may be running in parallel with other Hydra agents. Your output must be:
|
|
@@ -7,7 +7,7 @@ description: >
|
|
|
7
7
|
If issues are found, the orchestrator escalates to hydra-sentinel for
|
|
8
8
|
deep analysis. If clean — done, zero additional cost.
|
|
9
9
|
model: haiku
|
|
10
|
-
tools: Read, Grep, Glob
|
|
10
|
+
tools: Read, Grep, Glob, Bash
|
|
11
11
|
memory: project
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -40,7 +40,61 @@ You receive a summary of what changed:
|
|
|
40
40
|
- What functions/classes/exports changed
|
|
41
41
|
- The git diff (if available)
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## Codebase Map Integration
|
|
44
|
+
|
|
45
|
+
Before scanning, check if `.claude/hydra/codebase-map.json` exists.
|
|
46
|
+
|
|
47
|
+
### If the map EXISTS (preferred path):
|
|
48
|
+
|
|
49
|
+
Use the map for all dependency checks. This is MUCH faster and more accurate
|
|
50
|
+
than grepping.
|
|
51
|
+
|
|
52
|
+
#### P0 — Import/Export Chain Integrity
|
|
53
|
+
1. For every file that was modified, read its entry from the map.
|
|
54
|
+
2. Check `imported_by` — these are the files that depend on it.
|
|
55
|
+
3. For each dependent file, verify the imports are still valid:
|
|
56
|
+
- Was anything renamed or removed that the dependent file uses?
|
|
57
|
+
- Read ONLY the dependent files (not the whole codebase).
|
|
58
|
+
|
|
59
|
+
#### P0 — Blast Radius Assessment
|
|
60
|
+
1. For every modified file, compute the blast radius:
|
|
61
|
+
- First degree: files in `imported_by` (direct dependents)
|
|
62
|
+
- Second degree: for each first-degree file, check ITS `imported_by`
|
|
63
|
+
- Stop at second degree (deeper is diminishing returns)
|
|
64
|
+
2. Report the total blast radius count in your output.
|
|
65
|
+
|
|
66
|
+
#### P0 — Function Signature Changes
|
|
67
|
+
1. Read the modified file and its first-degree dependents (from the map).
|
|
68
|
+
2. Check if function signatures changed and callers still match.
|
|
69
|
+
|
|
70
|
+
#### P1 — Environment Variable Check
|
|
71
|
+
1. Read the `env_vars` section of the map.
|
|
72
|
+
2. For every new `process.env.X` (or equivalent) in the changed files:
|
|
73
|
+
- Check if X exists in the `env_vars` index already.
|
|
74
|
+
- If not: grep `.env`, `.env.example`, and config files for X.
|
|
75
|
+
- Flag if X is not defined anywhere.
|
|
76
|
+
|
|
77
|
+
#### P1 — Risk-Based Severity
|
|
78
|
+
1. Read the `risk` field for each modified file.
|
|
79
|
+
2. If a `critical` or `high` risk file was modified:
|
|
80
|
+
- ALWAYS escalate to sentinel deep analysis, even if no obvious issues found.
|
|
81
|
+
- The blast radius is too large to trust a fast scan alone.
|
|
82
|
+
3. If a `low` risk file was modified and no issues found:
|
|
83
|
+
- Report clean with high confidence.
|
|
84
|
+
|
|
85
|
+
#### P2 — Test Coverage Warning
|
|
86
|
+
1. Read the `test_coverage` field for each modified file.
|
|
87
|
+
2. If a modified file has `"test_coverage": "untested"`:
|
|
88
|
+
- Add an INFO-level note: "This file has no test coverage. Consider adding tests."
|
|
89
|
+
- If sentinel also finds integration issues in this file, escalate severity.
|
|
90
|
+
|
|
91
|
+
### If the map DOES NOT EXIST (fallback):
|
|
92
|
+
|
|
93
|
+
Fall back to the existing grep-based scanning (the Scan Checklist below).
|
|
94
|
+
This ensures sentinel-scan works even if the map hasn't been built yet.
|
|
95
|
+
Recommend that the user/orchestrator run hydra-scout to build the map.
|
|
96
|
+
|
|
97
|
+
## Scan Checklist — Grep Fallback (run ALL when map unavailable)
|
|
44
98
|
|
|
45
99
|
### P0 — Import/Export Chain Integrity
|
|
46
100
|
1. For every function, class, variable, or type that was RENAMED or DELETED:
|
|
@@ -89,9 +143,13 @@ Return a JSON object:
|
|
|
89
143
|
```json
|
|
90
144
|
{
|
|
91
145
|
"status": "clean",
|
|
146
|
+
"map_used": true,
|
|
92
147
|
"files_scanned": 12,
|
|
148
|
+
"blast_radius": 3,
|
|
149
|
+
"blast_radius_files": ["src/api/users.ts", "src/middleware/auth.ts", "src/routes/index.ts"],
|
|
93
150
|
"checks_passed": 6,
|
|
94
|
-
"
|
|
151
|
+
"untested_files_modified": [],
|
|
152
|
+
"summary": "No integration issues found. Blast radius: 3 files."
|
|
95
153
|
}
|
|
96
154
|
```
|
|
97
155
|
|
|
@@ -99,7 +157,10 @@ Return a JSON object:
|
|
|
99
157
|
```json
|
|
100
158
|
{
|
|
101
159
|
"status": "issues_found",
|
|
160
|
+
"map_used": true,
|
|
102
161
|
"files_scanned": 12,
|
|
162
|
+
"blast_radius": 12,
|
|
163
|
+
"blast_radius_files": ["src/api/users.ts", "src/middleware/auth.ts", "..."],
|
|
103
164
|
"checks_passed": 4,
|
|
104
165
|
"checks_failed": 2,
|
|
105
166
|
"issues": [
|
|
@@ -120,10 +181,15 @@ Return a JSON object:
|
|
|
120
181
|
"suggestion": "Add REDIS_URL to .env and .env.example"
|
|
121
182
|
}
|
|
122
183
|
],
|
|
123
|
-
"
|
|
184
|
+
"untested_files_modified": ["src/services/cache.ts"],
|
|
185
|
+
"summary": "2 integration issues found. Blast radius: 12 files. Escalating."
|
|
124
186
|
}
|
|
125
187
|
```
|
|
126
188
|
|
|
189
|
+
> **Note:** When the map is not available, set `"map_used": false` and omit
|
|
190
|
+
> `blast_radius`, `blast_radius_files`, and `untested_files_modified` fields.
|
|
191
|
+
> The output otherwise follows the same format.
|
|
192
|
+
|
|
127
193
|
## IMPORTANT
|
|
128
194
|
|
|
129
195
|
- Do NOT attempt to fix anything. Report only.
|
|
@@ -139,3 +205,19 @@ You may be running in parallel with other Hydra agents. Your output must be:
|
|
|
139
205
|
- **Clearly structured** — use the JSON format above so the orchestrator can parse it
|
|
140
206
|
- **Focused on YOUR task only** — integration integrity, nothing else
|
|
141
207
|
- **Actionable** — every issue includes file:line and a specific suggestion
|
|
208
|
+
|
|
209
|
+
## Cleanup: Clear Sentinel Pending Flag
|
|
210
|
+
|
|
211
|
+
After completing your scan (whether clean or issues found), clear the
|
|
212
|
+
sentinel pending flag by deleting the flag file:
|
|
213
|
+
```bash
|
|
214
|
+
rm -f /tmp/hydra-sentinel/${session_id}-pending.json
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Use the session_id from your context. This clears the "⚠ Sentinel pending"
|
|
218
|
+
warning from the status bar.
|
|
219
|
+
|
|
220
|
+
If you can't determine the session_id, run:
|
|
221
|
+
```bash
|
|
222
|
+
rm -f /tmp/hydra-sentinel/*-pending.json
|
|
223
|
+
```
|
|
@@ -43,6 +43,33 @@ After analysis, update your memory with:
|
|
|
43
43
|
2. The sentinel-scan report (JSON with flagged issues)
|
|
44
44
|
3. Context from the orchestrator about what task was being performed
|
|
45
45
|
|
|
46
|
+
## Codebase Map Integration
|
|
47
|
+
|
|
48
|
+
Before analyzing, read `.claude/hydra/codebase-map.json` if it exists.
|
|
49
|
+
|
|
50
|
+
### How to Use the Map
|
|
51
|
+
|
|
52
|
+
1. **Understand the blast radius before reading files.**
|
|
53
|
+
The map tells you which files depend on the changed files. Read the
|
|
54
|
+
blast radius files FIRST — these are the most likely to have issues.
|
|
55
|
+
|
|
56
|
+
2. **Check env_vars section for missing variables.**
|
|
57
|
+
The map's env_vars index tells you every env var reference in the project.
|
|
58
|
+
If the change introduces a new variable, check the index instead of grepping.
|
|
59
|
+
|
|
60
|
+
3. **Use risk scores to prioritize.**
|
|
61
|
+
Focus your deepest analysis on `critical` and `high` risk files. For `low`
|
|
62
|
+
risk files, a quick check is sufficient.
|
|
63
|
+
|
|
64
|
+
4. **Flag untested files.**
|
|
65
|
+
If a file with integration issues also has `"test_coverage": "untested"`,
|
|
66
|
+
escalate the severity and explicitly recommend adding tests.
|
|
67
|
+
|
|
68
|
+
5. **Cross-reference test coverage.**
|
|
69
|
+
The map's `tested_by` field tells you which test files cover each source file.
|
|
70
|
+
If you confirm a real issue, you can tell the user exactly which tests to run
|
|
71
|
+
to verify the fix: "Run tests/auth.test.ts to verify this fix."
|
|
72
|
+
|
|
46
73
|
## Deep Analysis Checklist
|
|
47
74
|
|
|
48
75
|
### For EVERY issue flagged by sentinel-scan:
|
|
@@ -16,7 +16,9 @@ COMMANDS
|
|
|
16
16
|
/hydra:config Show current configuration
|
|
17
17
|
/hydra:guard Run security scan on files (usage: /hydra:guard src/auth.py)
|
|
18
18
|
/hydra:quiet Suppress dispatch logs for this session
|
|
19
|
+
/hydra:map View, rebuild, or query the codebase map
|
|
19
20
|
/hydra:verbose Enable verbose dispatch logs with timing
|
|
21
|
+
/hydra:report Report a bug, request a feature, or share feedback
|
|
20
22
|
|
|
21
23
|
AGENTS
|
|
22
24
|
🟢 hydra-scout (Haiku 4.5) — Explore codebase, find files, map structure
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: View, rebuild, or query the codebase dependency map
|
|
3
|
+
allowed-tools: Bash, Read
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hydra Map
|
|
7
|
+
|
|
8
|
+
Manage the codebase dependency map.
|
|
9
|
+
|
|
10
|
+
## If no arguments provided: Show Summary
|
|
11
|
+
|
|
12
|
+
Read `.claude/hydra/codebase-map.json` and display a summary:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
🐉 Hydra Codebase Map
|
|
16
|
+
══════════════════════════════════
|
|
17
|
+
Status: ✅ Current (matches HEAD)
|
|
18
|
+
Files: 487 mapped
|
|
19
|
+
Built: 2026-03-26 10:00:00
|
|
20
|
+
Git hash: a1b2c3d
|
|
21
|
+
|
|
22
|
+
Risk Distribution:
|
|
23
|
+
🔴 Critical (7+ deps): 8 files
|
|
24
|
+
🟠 High (4-6 deps): 23 files
|
|
25
|
+
🟡 Medium (2-3 deps): 89 files
|
|
26
|
+
🟢 Low (0-1 deps): 367 files
|
|
27
|
+
|
|
28
|
+
Test Coverage:
|
|
29
|
+
✅ Covered: 234 files (48%)
|
|
30
|
+
🟡 Partial: 78 files (16%)
|
|
31
|
+
❌ Untested: 175 files (36%)
|
|
32
|
+
|
|
33
|
+
Environment Variables: 12 tracked across 28 files
|
|
34
|
+
|
|
35
|
+
Top 5 Highest-Risk Files:
|
|
36
|
+
src/services/auth.ts (12 dependents) 🔴
|
|
37
|
+
src/utils/helpers.ts (9 dependents) 🔴
|
|
38
|
+
src/config/index.ts (8 dependents) 🔴
|
|
39
|
+
src/models/user.ts (7 dependents) 🔴
|
|
40
|
+
src/middleware/cors.ts (6 dependents) 🟠
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If the map file doesn't exist, display:
|
|
44
|
+
```
|
|
45
|
+
🐉 Hydra Codebase Map
|
|
46
|
+
══════════════════════════════════
|
|
47
|
+
Status: ❌ Not built
|
|
48
|
+
|
|
49
|
+
No codebase map found. Run /hydra:map rebuild to build one,
|
|
50
|
+
or it will be built automatically on the next hydra-scout dispatch.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If the map exists but `_meta.git_hash` doesn't match current `git rev-parse HEAD`:
|
|
54
|
+
```
|
|
55
|
+
Status: ⚠️ Stale (map: a1b2c3d, HEAD: e4f5g6h)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## If argument is "rebuild": Force Rebuild
|
|
59
|
+
|
|
60
|
+
Dispatch hydra-scout to do a complete rebuild of the map, regardless of
|
|
61
|
+
staleness. Show progress and report when done.
|
|
62
|
+
|
|
63
|
+
## If argument is a file path: Show Blast Radius
|
|
64
|
+
|
|
65
|
+
Read the map entry for that file and display:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
🐉 Blast Radius: src/services/auth.ts
|
|
69
|
+
══════════════════════════════════════
|
|
70
|
+
Risk: 🔴 CRITICAL (12 dependents)
|
|
71
|
+
Test Coverage: ✅ Covered (tests/auth.test.ts, tests/integration/login.test.ts)
|
|
72
|
+
|
|
73
|
+
Imports (this file depends on):
|
|
74
|
+
→ src/models/user.ts
|
|
75
|
+
→ src/config/env.ts
|
|
76
|
+
|
|
77
|
+
Imported By (depends on this file):
|
|
78
|
+
1st degree (direct):
|
|
79
|
+
← src/api/users.ts
|
|
80
|
+
← src/api/admin.ts
|
|
81
|
+
← src/middleware/auth.ts
|
|
82
|
+
2nd degree (indirect):
|
|
83
|
+
← src/routes/index.ts (via api/users.ts)
|
|
84
|
+
← src/app.ts (via middleware/auth.ts)
|
|
85
|
+
|
|
86
|
+
Total Blast Radius: 5 files
|
|
87
|
+
|
|
88
|
+
Environment Variables Referenced:
|
|
89
|
+
JWT_SECRET (also used in: src/middleware/auth.ts)
|
|
90
|
+
AUTH_TIMEOUT (also used in: src/config/index.ts)
|
|
91
|
+
|
|
92
|
+
⚠ Changing this file could impact 5 other files.
|
|
93
|
+
Run sentinel after any modifications.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If the file is not found in the map, display:
|
|
97
|
+
```
|
|
98
|
+
File not found in codebase map: <file_path>
|
|
99
|
+
The map may be stale. Run /hydra:map rebuild to refresh.
|
|
100
|
+
```
|
|
@@ -12,3 +12,5 @@ Respond with:
|
|
|
12
12
|
"🐉 Quiet mode enabled. Dispatch logs suppressed for this session. Use /hydra:verbose to re-enable."
|
|
13
13
|
|
|
14
14
|
Continue operating Hydra normally (delegation, verification, auto-guard) — just don't show the dispatch log table.
|
|
15
|
+
|
|
16
|
+
Also suppress the task completion notification sound for this session.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Report a bug, request a feature, or share feedback about Hydra
|
|
3
|
+
allowed-tools: Bash
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hydra Report
|
|
7
|
+
|
|
8
|
+
Walk the user through submitting a bug report, feature request, or general feedback for the Hydra framework. Follow these steps interactively:
|
|
9
|
+
|
|
10
|
+
## Step 1 — Ask report type
|
|
11
|
+
|
|
12
|
+
Ask the user:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
🐉 What would you like to report?
|
|
16
|
+
|
|
17
|
+
1. 🐛 Bug Report — something is broken or not working as expected
|
|
18
|
+
2. ✨ Feature Request — an idea for a new feature or improvement
|
|
19
|
+
3. 💬 General Feedback — anything else you'd like to share
|
|
20
|
+
|
|
21
|
+
Enter 1, 2, or 3:
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Wait for their response. Map:
|
|
25
|
+
- 1 → label: `bug`, template: Bug Report
|
|
26
|
+
- 2 → label: `enhancement`, template: Feature Request
|
|
27
|
+
- 3 → label: `feedback`, template: General Feedback
|
|
28
|
+
|
|
29
|
+
## Step 2 — Collect description
|
|
30
|
+
|
|
31
|
+
Ask the user to describe the issue or idea:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Describe the [bug/feature/feedback] in a few sentences:
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For bugs, also ask:
|
|
38
|
+
```
|
|
39
|
+
Steps to reproduce (if applicable):
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Step 3 — Collect system info (optional)
|
|
43
|
+
|
|
44
|
+
Ask: "Include system info in the report? (recommended for bugs) [Y/n]"
|
|
45
|
+
|
|
46
|
+
If yes, gather:
|
|
47
|
+
```bash
|
|
48
|
+
# Hydra version
|
|
49
|
+
cat ~/.claude/skills/hydra/VERSION 2>/dev/null || echo "not found"
|
|
50
|
+
```
|
|
51
|
+
```bash
|
|
52
|
+
# OS info
|
|
53
|
+
node -e "console.log(process.platform + ' ' + process.arch + ' ' + require('os').release())"
|
|
54
|
+
```
|
|
55
|
+
```bash
|
|
56
|
+
# Agent count
|
|
57
|
+
ls ~/.claude/agents/hydra-*.md 2>/dev/null | wc -l
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Format as a "System Info" section in the report.
|
|
61
|
+
|
|
62
|
+
## Step 4 — Submit via GitHub CLI or fallback
|
|
63
|
+
|
|
64
|
+
Check if `gh` CLI is available:
|
|
65
|
+
```bash
|
|
66
|
+
gh --version 2>/dev/null
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### If `gh` is installed, check auth:
|
|
70
|
+
```bash
|
|
71
|
+
gh auth status 2>/dev/null
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### If authenticated → create issue directly:
|
|
75
|
+
```bash
|
|
76
|
+
gh issue create \
|
|
77
|
+
--repo AR6420/Hail_Hydra \
|
|
78
|
+
--title "<concise title based on description>" \
|
|
79
|
+
--label "<bug|enhancement|feedback>" \
|
|
80
|
+
--body "<formatted report body>"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Show the resulting issue URL to the user.
|
|
84
|
+
|
|
85
|
+
### If `gh` is installed but NOT authenticated:
|
|
86
|
+
|
|
87
|
+
Tell the user:
|
|
88
|
+
```
|
|
89
|
+
GitHub CLI is installed but not authenticated.
|
|
90
|
+
Run this in your terminal to authenticate:
|
|
91
|
+
|
|
92
|
+
gh auth login
|
|
93
|
+
|
|
94
|
+
Then try /hydra:report again.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### If `gh` is NOT installed → browser fallback:
|
|
98
|
+
|
|
99
|
+
Construct a pre-filled GitHub issue URL and show it to the user:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
GitHub CLI not found. You can submit your report via browser:
|
|
103
|
+
|
|
104
|
+
https://github.com/AR6420/Hail_Hydra/issues/new?template=<template>&title=<encoded-title>&labels=<label>&body=<encoded-body>
|
|
105
|
+
|
|
106
|
+
Or install GitHub CLI: https://cli.github.com
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Map template filenames:
|
|
110
|
+
- bug → `bug_report.md`
|
|
111
|
+
- enhancement → `feature_request.md`
|
|
112
|
+
- feedback → `feedback.md`
|
|
@@ -43,6 +43,16 @@ cat .claude/skills/hydra/config/hydra.config.md 2>/dev/null || \
|
|
|
43
43
|
echo "No config file found (using defaults)"
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
## 6. Codebase Map
|
|
47
|
+
```bash
|
|
48
|
+
if [ -f ".claude/hydra/codebase-map.json" ]; then
|
|
49
|
+
echo "Map: ✅ Exists"
|
|
50
|
+
node -e "const m=JSON.parse(require('fs').readFileSync('.claude/hydra/codebase-map.json','utf8'));console.log('Files:',m._meta.file_count);console.log('Built:',m._meta.built_at);console.log('Hash:',m._meta.git_hash);"
|
|
51
|
+
else
|
|
52
|
+
echo "Map: ❌ Not built yet (run /hydra:map rebuild)"
|
|
53
|
+
fi
|
|
54
|
+
```
|
|
55
|
+
|
|
46
56
|
## Display Format
|
|
47
57
|
|
|
48
58
|
Present results as a clean status card:
|
|
@@ -60,8 +70,9 @@ Agents (7):
|
|
|
60
70
|
🟢 hydra-git (Haiku 4.5) ✅
|
|
61
71
|
🔵 hydra-coder (Sonnet 4.6) ✅
|
|
62
72
|
🔵 hydra-analyst (Sonnet 4.6) ✅
|
|
63
|
-
Commands (
|
|
64
|
-
Hooks (
|
|
73
|
+
Commands (9): update, status, help, config, guard, quiet, verbose, report, map
|
|
74
|
+
Hooks (4): check-update ✅, statusline ✅, auto-guard ✅, notify ✅
|
|
75
|
+
Map: ✅ Current (487 files, built 2026-03-26)
|
|
65
76
|
Config: balanced mode, dispatch log on, auto-guard on
|
|
66
77
|
──────────────────────────────
|
|
67
78
|
```
|
|
@@ -1,35 +1,78 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Update the Hydra framework to the latest version from npm
|
|
3
|
-
allowed-tools: Bash
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Hydra Update
|
|
7
|
-
|
|
8
|
-
Run the following steps to update Hydra to the latest version:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
---
|
|
2
|
+
description: Update the Hydra framework to the latest version from npm
|
|
3
|
+
allowed-tools: Bash, Read
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hydra Update
|
|
7
|
+
|
|
8
|
+
Run the following steps to update Hydra to the latest version:
|
|
9
|
+
|
|
10
|
+
## Step 1 — Check versions
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
cat ~/.claude/skills/hydra/VERSION 2>/dev/null || echo "VERSION file not found"
|
|
14
|
+
```
|
|
15
|
+
```bash
|
|
16
|
+
npm view hail-hydra-cc version 2>/dev/null || echo "Package not found on npm"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If the installed version matches the latest npm version, tell the user:
|
|
20
|
+
"🐉 Hydra is already at the latest version ([version])."
|
|
21
|
+
and stop here.
|
|
22
|
+
|
|
23
|
+
## Step 2 — Show changelog preview
|
|
24
|
+
|
|
25
|
+
Fetch the CHANGELOG from GitHub:
|
|
26
|
+
```bash
|
|
27
|
+
curl -sL "https://raw.githubusercontent.com/AR6420/Hail_Hydra/main/CHANGELOG.md"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Parse the changelog to extract entries between the installed version and the latest version. Display a formatted "What's New" section:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
🐉 Hydra Update Available: [installed] → [latest]
|
|
34
|
+
═══════════════════════════════════════════════════
|
|
35
|
+
|
|
36
|
+
📋 What's New:
|
|
37
|
+
[changelog entries for versions between installed and latest]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If the changelog fetch fails, skip the preview and continue with the update.
|
|
41
|
+
|
|
42
|
+
## Step 3 — Show safety note
|
|
43
|
+
|
|
44
|
+
Display:
|
|
45
|
+
```
|
|
46
|
+
⚠️ What gets replaced:
|
|
47
|
+
• Agent definitions (agents/*.md)
|
|
48
|
+
• SKILL.md, references, commands, hooks
|
|
49
|
+
• VERSION file
|
|
50
|
+
|
|
51
|
+
✅ What's preserved:
|
|
52
|
+
• Your hydra.config.md settings
|
|
53
|
+
• Agent memory directories (memory/)
|
|
54
|
+
• CLAUDE.md orchestrator notes
|
|
55
|
+
• settings.json hook registrations (re-registered automatically)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Step 4 — Ask for confirmation
|
|
59
|
+
|
|
60
|
+
Ask the user: "Proceed with update? [Y/n]"
|
|
61
|
+
|
|
62
|
+
If they decline, respond: "🐉 Update cancelled." and stop.
|
|
63
|
+
|
|
64
|
+
## Step 5 — Run the update
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx hail-hydra-cc@latest --global
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Step 6 — Verify
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cat ~/.claude/skills/hydra/VERSION
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Report to the user:
|
|
77
|
+
- If updated: "🐉 Hydra updated from [old] → [new]. All heads refreshed. Restart Claude Code to load the new files."
|
|
78
|
+
- If error: Show the error and suggest running `npx hail-hydra-cc@latest --global` manually in their terminal.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hydra Task Completion Notification
|
|
6
|
+
*
|
|
7
|
+
* Plays a short notification sound when Claude Code finishes a task.
|
|
8
|
+
* Cross-platform: macOS (afplay), Windows (PowerShell), Linux (paplay/aplay).
|
|
9
|
+
*
|
|
10
|
+
* Called by Claude Code's Notification hook — stdin receives JSON from
|
|
11
|
+
* the hook system, which we drain and discard to prevent EPIPE errors.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const { spawn } = require('child_process');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const os = require('os');
|
|
18
|
+
|
|
19
|
+
// Drain stdin to prevent EPIPE when Claude Code pipes hook data
|
|
20
|
+
process.stdin.resume();
|
|
21
|
+
process.stdin.on('data', () => {});
|
|
22
|
+
process.stdin.on('end', () => {});
|
|
23
|
+
|
|
24
|
+
const wavFile = path.join(os.homedir(), '.claude', 'hooks', 'hydra-task-complete.wav');
|
|
25
|
+
|
|
26
|
+
// Bail silently if the sound file is missing
|
|
27
|
+
if (!fs.existsSync(wavFile)) {
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const platform = process.platform;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
let child;
|
|
35
|
+
|
|
36
|
+
if (platform === 'darwin') {
|
|
37
|
+
// macOS
|
|
38
|
+
child = spawn('afplay', [wavFile], {
|
|
39
|
+
detached: true,
|
|
40
|
+
stdio: 'ignore',
|
|
41
|
+
});
|
|
42
|
+
} else if (platform === 'win32') {
|
|
43
|
+
// Windows — use PowerShell to play the .wav
|
|
44
|
+
child = spawn('powershell', [
|
|
45
|
+
'-NoProfile', '-NonInteractive', '-Command',
|
|
46
|
+
`(New-Object Media.SoundPlayer '${wavFile.replace(/'/g, "''")}').PlaySync()`,
|
|
47
|
+
], {
|
|
48
|
+
detached: true,
|
|
49
|
+
stdio: 'ignore',
|
|
50
|
+
windowsHide: true,
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
// Linux — try paplay (PulseAudio) first, fall back to aplay (ALSA)
|
|
54
|
+
const paplay = spawn('paplay', [wavFile], {
|
|
55
|
+
detached: true,
|
|
56
|
+
stdio: 'ignore',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
paplay.on('error', () => {
|
|
60
|
+
// paplay not available, try aplay
|
|
61
|
+
const aplay = spawn('aplay', [wavFile], {
|
|
62
|
+
detached: true,
|
|
63
|
+
stdio: 'ignore',
|
|
64
|
+
});
|
|
65
|
+
aplay.unref();
|
|
66
|
+
aplay.on('error', () => {}); // silently ignore if neither works
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
paplay.unref();
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (child) {
|
|
74
|
+
child.unref();
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
// Silently ignore errors — notification sound is non-critical
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
process.exit(0);
|
|
Binary file
|
|
@@ -32,9 +32,21 @@ Haiku outputs qualify for auto-accept when they are raw, factual, and unambiguou
|
|
|
32
32
|
- **hydra-scribe**: Internal docstrings, inline comments, changelog entries
|
|
33
33
|
- **Requires verify**: Any analysis, interpretation, or user-facing documentation
|
|
34
34
|
|
|
35
|
-
### hydra-
|
|
35
|
+
### hydra-scout (Haiku 4.5) — Updated in v2.1.0
|
|
36
|
+
- **Strengths**: Codebase exploration, file search, reading, AND codebase
|
|
37
|
+
map building/maintenance
|
|
38
|
+
- **New capability**: Builds and incrementally updates the codebase dependency
|
|
39
|
+
map using grep-based import extraction. No external parsers required.
|
|
40
|
+
- **Memory focus**: Codebase structure, key file locations, module boundaries,
|
|
41
|
+
map build history, files that failed to parse
|
|
42
|
+
|
|
43
|
+
### hydra-sentinel-scan (Haiku 4.5) — Updated in v2.1.0
|
|
36
44
|
- **Strengths**: Pattern matching, grep-level analysis, import tracing,
|
|
37
|
-
fast structural checks
|
|
45
|
+
fast structural checks, AND map-based instant blast-radius lookups
|
|
46
|
+
- **New capability**: Reads codebase map for instant dependency lookups
|
|
47
|
+
instead of grepping. Falls back to grep if map doesn't exist.
|
|
48
|
+
- **Map-aware checks**: Risk-based severity, test coverage warnings,
|
|
49
|
+
env var index lookups, blast radius reporting
|
|
38
50
|
- **Limitations**: Cannot understand semantic meaning of data shapes,
|
|
39
51
|
may produce false positives on complex contract changes
|
|
40
52
|
- **Memory focus**: Codebase dependency graph, coupling patterns,
|
|
@@ -156,6 +156,34 @@ These are tasks that look like one tier but are actually another:
|
|
|
156
156
|
|
|
157
157
|
---
|
|
158
158
|
|
|
159
|
+
## Map-Aware Routing Examples
|
|
160
|
+
|
|
161
|
+
These examples show how the codebase map changes routing decisions by providing
|
|
162
|
+
risk scores and blast radius data upfront.
|
|
163
|
+
|
|
164
|
+
### "Fix the bug in auth.ts"
|
|
165
|
+
1. Check map: auth.ts has risk=critical, 12 dependents
|
|
166
|
+
2. hydra-scout → verify map is current (incremental update if needed)
|
|
167
|
+
3. hydra-analyst → diagnose the bug
|
|
168
|
+
4. hydra-coder → implement the fix
|
|
169
|
+
5. hydra-sentinel-scan → map shows blast radius of 12 files, check all 12
|
|
170
|
+
(without map, would have to grep the entire codebase)
|
|
171
|
+
6. hydra-sentinel → deep analysis (auto-escalated because risk=critical)
|
|
172
|
+
|
|
173
|
+
### "Add a new utility function"
|
|
174
|
+
1. Check map: new file, risk=low (zero dependents initially)
|
|
175
|
+
2. hydra-coder → write the function
|
|
176
|
+
3. hydra-sentinel-scan → low risk, quick scan, auto-accept if clean
|
|
177
|
+
(without map, would run the same expensive scan as a critical file)
|
|
178
|
+
|
|
179
|
+
### "Refactor the database connection module"
|
|
180
|
+
1. Check map: src/db/connection.ts has risk=critical, 15 dependents
|
|
181
|
+
2. Plan execution with full blast radius awareness
|
|
182
|
+
3. Dispatch parallel hydra-coders for each affected file
|
|
183
|
+
4. Sentinel deep analysis is MANDATORY (critical risk)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
159
187
|
## Quick Decision Flowchart
|
|
160
188
|
|
|
161
189
|
```
|
package/package.json
CHANGED
package/src/display.js
CHANGED
|
@@ -42,17 +42,19 @@ function showInstallComplete(statusLineConfigured = true) {
|
|
|
42
42
|
console.log(chalk.cyan.bold(' \uD83D\uDC09 Hail Hydra! Framework deployed and ready.'));
|
|
43
43
|
console.log(chalk.gray(' ' + '\u2500'.repeat(45)));
|
|
44
44
|
console.log(chalk.green(` \u2714 9 agents installed`));
|
|
45
|
-
console.log(chalk.green(` \u2714
|
|
46
|
-
console.log(chalk.green(` \u2714
|
|
45
|
+
console.log(chalk.green(` \u2714 9 slash commands installed`));
|
|
46
|
+
console.log(chalk.green(` \u2714 4 hooks registered`));
|
|
47
47
|
if (statusLineConfigured) {
|
|
48
48
|
console.log(chalk.green(` \u2714 StatusLine configured`));
|
|
49
49
|
} else {
|
|
50
50
|
console.log(chalk.yellow(` \u26a0 StatusLine skipped (existing config preserved)`));
|
|
51
51
|
}
|
|
52
52
|
console.log(chalk.green(` \u2714 Sentinel pipeline active`));
|
|
53
|
+
console.log(chalk.green(` \u2714 Codebase map ready (run /hydra:map rebuild)`));
|
|
53
54
|
console.log(chalk.green(` \u2714 Version tracked (${VERSION})`));
|
|
54
55
|
console.log();
|
|
55
56
|
console.log(chalk.gray(' Quick start: /hydra:help'));
|
|
57
|
+
console.log(chalk.gray(' Build map: /hydra:map rebuild'));
|
|
56
58
|
console.log(chalk.gray(' Check status: /hydra:status'));
|
|
57
59
|
console.log(chalk.gray(' GitHub: https://github.com/AR6420/Hail_Hydra'));
|
|
58
60
|
console.log();
|
|
@@ -141,7 +143,7 @@ function showStatusTable(globalStatus, localStatus) {
|
|
|
141
143
|
// Global hooks (always ~/.claude/hooks/)
|
|
142
144
|
console.log();
|
|
143
145
|
console.log(chalk.bold(' Global Hooks (~/.claude/hooks/)'));
|
|
144
|
-
const hookKeys = ['hydra-check-update', 'hydra-statusline', 'hydra-auto-guard'];
|
|
146
|
+
const hookKeys = ['hydra-check-update', 'hydra-statusline', 'hydra-auto-guard', 'hydra-notify'];
|
|
145
147
|
for (const key of hookKeys) {
|
|
146
148
|
const dest = path.join(os.homedir(), '.claude', 'hooks', `${key}.js`);
|
|
147
149
|
if (fileExists(dest)) {
|
package/src/files.js
CHANGED
|
@@ -80,12 +80,19 @@ const commands = {
|
|
|
80
80
|
'guard': readBundled('commands/hydra/guard.md'),
|
|
81
81
|
'quiet': readBundled('commands/hydra/quiet.md'),
|
|
82
82
|
'verbose': readBundled('commands/hydra/verbose.md'),
|
|
83
|
+
'report': readBundled('commands/hydra/report.md'),
|
|
84
|
+
'map': readBundled('commands/hydra/map.md'),
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
const hooks = {
|
|
86
88
|
'hydra-check-update': readBundled('hooks/hydra-check-update.js'),
|
|
87
89
|
'hydra-statusline': readBundled('hooks/hydra-statusline.js'),
|
|
88
90
|
'hydra-auto-guard': readBundled('hooks/hydra-auto-guard.js'),
|
|
91
|
+
'hydra-notify': readBundled('hooks/hydra-notify.js'),
|
|
89
92
|
};
|
|
90
93
|
|
|
91
|
-
|
|
94
|
+
const binaryHooks = {
|
|
95
|
+
'hydra-task-complete.wav': path.join(FILES_DIR, 'hooks', 'hydra-task-complete.wav'),
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
module.exports = { agents, skill, references, commands, hooks, binaryHooks };
|
package/src/installer.js
CHANGED
|
@@ -5,7 +5,7 @@ const path = require('path');
|
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const chalk = require('chalk');
|
|
7
7
|
|
|
8
|
-
const { agents, skill, references, commands, hooks } = require('./files');
|
|
8
|
+
const { agents, skill, references, commands, hooks, binaryHooks } = require('./files');
|
|
9
9
|
const { showInstallHeader, showFileInstalled, showInstallComplete, showStatusTable, VERSION } = require('./display');
|
|
10
10
|
|
|
11
11
|
// ── Install locations ────────────────────────────────────────────────────────
|
|
@@ -100,6 +100,17 @@ function installHooks() {
|
|
|
100
100
|
showFileInstalled(`hooks/${key}.js`, false, err.message);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
// Copy binary hook files (e.g., .wav) that can't be read as UTF-8 text
|
|
105
|
+
for (const [filename, srcPath] of Object.entries(binaryHooks)) {
|
|
106
|
+
const dest = path.join(hooksDir, filename);
|
|
107
|
+
try {
|
|
108
|
+
fs.copyFileSync(srcPath, dest);
|
|
109
|
+
showFileInstalled(`hooks/${filename}`, true);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
showFileInstalled(`hooks/${filename}`, false, err.message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
103
114
|
}
|
|
104
115
|
|
|
105
116
|
function registerHooksInSettings() {
|
|
@@ -130,6 +141,12 @@ function registerHooksInSettings() {
|
|
|
130
141
|
hooks: [{ type: 'command', command: 'node ~/.claude/hooks/hydra-auto-guard.js' }]
|
|
131
142
|
});
|
|
132
143
|
|
|
144
|
+
if (!settings.hooks.Notification) settings.hooks.Notification = [];
|
|
145
|
+
settings.hooks.Notification = settings.hooks.Notification.filter(x => !isHydraHook(x));
|
|
146
|
+
settings.hooks.Notification.push({
|
|
147
|
+
hooks: [{ type: 'command', command: 'node ~/.claude/hooks/hydra-notify.js' }]
|
|
148
|
+
});
|
|
149
|
+
|
|
133
150
|
let statusLineConfigured = false;
|
|
134
151
|
if (!settings.statusLine || (settings.statusLine.command && settings.statusLine.command.includes('hydra-'))) {
|
|
135
152
|
settings.statusLine = {
|
|
@@ -161,6 +178,10 @@ function deregisterHooks() {
|
|
|
161
178
|
settings.hooks.PostToolUse = settings.hooks.PostToolUse.filter(x => !isHydraHook(x));
|
|
162
179
|
if (!settings.hooks.PostToolUse.length) delete settings.hooks.PostToolUse;
|
|
163
180
|
}
|
|
181
|
+
if (settings.hooks?.Notification) {
|
|
182
|
+
settings.hooks.Notification = settings.hooks.Notification.filter(x => !isHydraHook(x));
|
|
183
|
+
if (!settings.hooks.Notification.length) delete settings.hooks.Notification;
|
|
184
|
+
}
|
|
164
185
|
if (settings.hooks && !Object.keys(settings.hooks).length) delete settings.hooks;
|
|
165
186
|
|
|
166
187
|
if (settings.statusLine?.command?.includes('hydra-')) delete settings.statusLine;
|
|
@@ -305,6 +326,15 @@ async function runUninstall({ interactive = true } = {}) {
|
|
|
305
326
|
}
|
|
306
327
|
}
|
|
307
328
|
|
|
329
|
+
// Remove binary hook files (e.g., .wav)
|
|
330
|
+
for (const filename of Object.keys(binaryHooks)) {
|
|
331
|
+
const dest = path.join(GLOBAL_BASE, 'hooks', filename);
|
|
332
|
+
if (fileExists(dest)) {
|
|
333
|
+
try { fs.unlinkSync(dest); console.log(chalk.green(` \u2714 Removed hooks/${filename}`)); }
|
|
334
|
+
catch (err) { console.log(chalk.red(` \u2716 Failed: hooks/${filename} \u2014 ${err.message}`)); }
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
308
338
|
// Remove cache file
|
|
309
339
|
const cacheFile = path.join(GLOBAL_BASE, 'cache', 'hydra-update-check.json');
|
|
310
340
|
if (fileExists(cacheFile)) {
|