hail-hydra-cc 2.0.4 → 2.1.1
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/files/SKILL.md +51 -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 +1 -0
- package/files/commands/hydra/map.md +100 -0
- package/files/commands/hydra/status.md +13 -2
- 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 +3 -1
- package/src/files.js +1 -0
package/files/SKILL.md
CHANGED
|
@@ -178,6 +178,54 @@ The index is stale if:
|
|
|
178
178
|
- The user switches to a different project/directory
|
|
179
179
|
When stale, rebuild the index on the next scout dispatch.
|
|
180
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
|
+
|
|
181
229
|
## Blocking vs Non-Blocking Dispatch
|
|
182
230
|
|
|
183
231
|
Not all agents need to finish before the next wave starts. Classify each dispatch as
|
|
@@ -782,6 +830,7 @@ the command's instructions:
|
|
|
782
830
|
| `/hydra:update` | Trigger an update via npx |
|
|
783
831
|
| `/hydra:config` | Show current configuration |
|
|
784
832
|
| `/hydra:guard [files]` | Manually invoke the security scan on specified files |
|
|
833
|
+
| `/hydra:map [file]` | View, rebuild, or query the codebase dependency map |
|
|
785
834
|
| `/hydra:quiet` | Suppress dispatch logs for this session |
|
|
786
835
|
| `/hydra:verbose` | Enable detailed dispatch logs with timing |
|
|
787
836
|
|
|
@@ -921,12 +970,13 @@ If the user types any of these exact phrases, respond with the corresponding act
|
|
|
921
970
|
| `hydra quiet` | Suppress dispatch logs for the rest of the session (equivalent to stealth mode) |
|
|
922
971
|
| `hydra verbose` | Enable verbose dispatch logs with per-agent detail for the rest of the session |
|
|
923
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 |
|
|
924
974
|
|
|
925
975
|
## The Nine Heads
|
|
926
976
|
|
|
927
977
|
| Head | Model | Role | Tools |
|
|
928
978
|
|------|-------|------|-------|
|
|
929
|
-
| `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 |
|
|
930
980
|
| `hydra-runner` | 🟢 Haiku 4.5 | Test execution, builds, linting, validation | Read, Bash, Glob, Grep |
|
|
931
981
|
| `hydra-scribe` | 🟢 Haiku 4.5 | Documentation, READMEs, comments, changelogs | Read, Write, Edit, Glob, Grep |
|
|
932
982
|
| `hydra-guard` | 🟢 Haiku 4.5 | Security/quality gate after code changes | Read, Grep, Glob, Bash |
|
|
@@ -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,6 +16,7 @@ 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
|
|
20
21
|
/hydra:report Report a bug, request a feature, or share feedback
|
|
21
22
|
|
|
@@ -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
|
+
```
|
|
@@ -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
|
```
|
|
@@ -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,7 +42,7 @@ 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
|
|
45
|
+
console.log(chalk.green(` \u2714 9 slash commands installed`));
|
|
46
46
|
console.log(chalk.green(` \u2714 4 hooks registered`));
|
|
47
47
|
if (statusLineConfigured) {
|
|
48
48
|
console.log(chalk.green(` \u2714 StatusLine configured`));
|
|
@@ -50,9 +50,11 @@ function showInstallComplete(statusLineConfigured = true) {
|
|
|
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();
|
package/src/files.js
CHANGED