hail-hydra-cc 2.3.1 → 2.3.2
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 +99 -99
- package/bin/cli.js +105 -105
- package/files/SKILL.md +1217 -1174
- package/files/agents/hydra-analyst.md +159 -145
- package/files/agents/hydra-coder.md +137 -123
- package/files/agents/hydra-git.md +148 -130
- package/files/agents/hydra-guard.md +153 -135
- package/files/agents/hydra-preflight.md +22 -0
- package/files/agents/hydra-runner.md +107 -93
- package/files/agents/hydra-scout.md +241 -227
- package/files/agents/hydra-scribe.md +98 -84
- package/files/agents/hydra-sentinel-scan.md +242 -236
- package/files/agents/hydra-sentinel.md +210 -192
- package/files/commands/hydra/config.md +37 -37
- package/files/commands/hydra/guard.md +71 -71
- package/files/commands/hydra/help.md +47 -46
- package/files/commands/hydra/quiet.md +16 -16
- package/files/commands/hydra/status.md +85 -85
- package/files/commands/hydra/stfu.md +21 -0
- package/files/commands/hydra/verbose.md +29 -29
- package/files/hooks/hydra-auto-guard.js +54 -54
- package/files/hooks/hydra-check-update.js +99 -99
- package/files/hooks/hydra-statusline.js +128 -128
- package/files/hooks/hydra-token-math.js +1 -1
- package/files/references/model-capabilities.md +164 -164
- package/files/references/routing-guide.md +303 -303
- package/files/skills/stfu-agents/SKILL.md +59 -0
- package/package.json +1 -1
- package/src/files.js +106 -106
- package/src/installer.js +393 -393
- package/src/prompts.js +80 -80
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Show all available Hydra commands, agents, and a quick reference guide
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Hydra Help
|
|
6
|
-
|
|
7
|
-
Display the following help reference directly — do NOT search files or run commands:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
🐉 Hydra Framework — Quick Reference
|
|
11
|
-
═══════════════════════════════════════
|
|
12
|
-
COMMANDS
|
|
13
|
-
/hydra:help Show this help screen
|
|
14
|
-
/hydra:status Show installed agents, version, config
|
|
15
|
-
/hydra:update Update Hydra to the latest version
|
|
16
|
-
/hydra:config Show current configuration
|
|
17
|
-
/hydra:guard Run security scan on files (usage: /hydra:guard src/auth.py)
|
|
18
|
-
/hydra:quiet Suppress dispatch logs for this session
|
|
19
|
-
/hydra:map View, rebuild, or query the codebase map
|
|
20
|
-
/hydra:verbose Enable verbose dispatch logs with timing
|
|
21
|
-
/hydra:report Report a bug, request a feature, or share feedback
|
|
22
|
-
/hydra:preflight Two-phase environment & compatibility check before new projects
|
|
23
|
-
/hydra:stats Show real token usage and estimated savings (no AI estimation)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
🟢 hydra-
|
|
28
|
-
🟢 hydra-
|
|
29
|
-
🟢 hydra-
|
|
30
|
-
🟢 hydra-
|
|
31
|
-
🟢 hydra-
|
|
32
|
-
|
|
33
|
-
🔵 hydra-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
---
|
|
2
|
+
description: Show all available Hydra commands, agents, and a quick reference guide
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Hydra Help
|
|
6
|
+
|
|
7
|
+
Display the following help reference directly — do NOT search files or run commands:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
🐉 Hydra Framework — Quick Reference
|
|
11
|
+
═══════════════════════════════════════
|
|
12
|
+
COMMANDS
|
|
13
|
+
/hydra:help Show this help screen
|
|
14
|
+
/hydra:status Show installed agents, version, config
|
|
15
|
+
/hydra:update Update Hydra to the latest version
|
|
16
|
+
/hydra:config Show current configuration
|
|
17
|
+
/hydra:guard Run security scan on files (usage: /hydra:guard src/auth.py)
|
|
18
|
+
/hydra:quiet Suppress dispatch logs for this session
|
|
19
|
+
/hydra:map View, rebuild, or query the codebase map
|
|
20
|
+
/hydra:verbose Enable verbose dispatch logs with timing
|
|
21
|
+
/hydra:report Report a bug, request a feature, or share feedback
|
|
22
|
+
/hydra:preflight Two-phase environment & compatibility check before new projects
|
|
23
|
+
/hydra:stats Show real token usage and estimated savings (no AI estimation)
|
|
24
|
+
/hydra:stfu Silence intermediate prose from every dispatched subagent
|
|
25
|
+
|
|
26
|
+
AGENTS
|
|
27
|
+
🟢 hydra-scout (Haiku 4.5) — Explore codebase, find files, map structure
|
|
28
|
+
🟢 hydra-runner (Haiku 4.5) — Run tests, linters, build commands
|
|
29
|
+
🟢 hydra-scribe (Haiku 4.5) — Write docs, comments, READMEs
|
|
30
|
+
🟢 hydra-guard (Haiku 4.5) — Security scan, quality gate
|
|
31
|
+
🟢 hydra-git (Haiku 4.5) — Git operations, commits, branches
|
|
32
|
+
🟢 hydra-preflight (Haiku 4.5) — Environment detection, version probing, dep inventory
|
|
33
|
+
🔵 hydra-coder (Sonnet 4.6) — Write and edit code
|
|
34
|
+
🔵 hydra-analyst (Sonnet 4.6) — Debug, diagnose, review
|
|
35
|
+
|
|
36
|
+
HOW IT WORKS
|
|
37
|
+
The Opus 4.6 orchestrator automatically delegates tasks to cheaper,
|
|
38
|
+
faster agents (Haiku 4.5 and Sonnet 4.6) — saving ~50% on API costs
|
|
39
|
+
while maintaining Opus-level quality through verification.
|
|
40
|
+
|
|
41
|
+
You don't need to do anything. Just work normally.
|
|
42
|
+
Hydra operates invisibly unless you check the dispatch log.
|
|
43
|
+
|
|
44
|
+
LINKS
|
|
45
|
+
GitHub: https://github.com/AR6420/Hail_Hydra
|
|
46
|
+
npm: https://www.npmjs.com/package/hail-hydra-cc
|
|
47
|
+
```
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Suppress Hydra dispatch logs for the rest of this session
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Hydra Quiet Mode
|
|
6
|
-
|
|
7
|
-
Acknowledge this command and remember for the rest of this session:
|
|
8
|
-
|
|
9
|
-
**Do NOT display the Hydra Dispatch Log footer after tasks.**
|
|
10
|
-
|
|
11
|
-
Respond with:
|
|
12
|
-
"🐉 Quiet mode enabled. Dispatch logs suppressed for this session. Use /hydra:verbose to re-enable."
|
|
13
|
-
|
|
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.
|
|
1
|
+
---
|
|
2
|
+
description: Suppress Hydra dispatch logs for the rest of this session
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Hydra Quiet Mode
|
|
6
|
+
|
|
7
|
+
Acknowledge this command and remember for the rest of this session:
|
|
8
|
+
|
|
9
|
+
**Do NOT display the Hydra Dispatch Log footer after tasks.**
|
|
10
|
+
|
|
11
|
+
Respond with:
|
|
12
|
+
"🐉 Quiet mode enabled. Dispatch logs suppressed for this session. Use /hydra:verbose to re-enable."
|
|
13
|
+
|
|
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.
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Show Hydra framework status — installed agents, version, config, and update availability
|
|
3
|
-
allowed-tools: Bash, Read, Glob
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Hydra Status
|
|
7
|
-
|
|
8
|
-
Show a comprehensive status report for the Hydra framework.
|
|
9
|
-
|
|
10
|
-
## 1. Version Info
|
|
11
|
-
```bash
|
|
12
|
-
INSTALLED=$(cat ~/.claude/skills/hydra/VERSION 2>/dev/null || echo "unknown")
|
|
13
|
-
echo "Installed: $INSTALLED"
|
|
14
|
-
LATEST=$(npm view hail-hydra-cc version 2>/dev/null || echo "unknown")
|
|
15
|
-
echo "Latest: $LATEST"
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## 2. Installed Agents
|
|
19
|
-
```bash
|
|
20
|
-
echo "=== Global Agents ==="
|
|
21
|
-
ls -1 ~/.claude/agents/hydra-*.md 2>/dev/null || echo "None found"
|
|
22
|
-
echo "=== Local Agents ==="
|
|
23
|
-
ls -1 .claude/agents/hydra-*.md 2>/dev/null || echo "None found"
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## 3. Installed Commands
|
|
27
|
-
```bash
|
|
28
|
-
echo "=== Global Commands ==="
|
|
29
|
-
ls -1 ~/.claude/commands/hydra/*.md 2>/dev/null || echo "None found"
|
|
30
|
-
echo "=== Local Commands ==="
|
|
31
|
-
ls -1 .claude/commands/hydra/*.md 2>/dev/null || echo "None found"
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## 4. Hooks
|
|
35
|
-
```bash
|
|
36
|
-
ls -1 ~/.claude/hooks/hydra-*.js 2>/dev/null || echo "None found"
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## 5. Configuration
|
|
40
|
-
```bash
|
|
41
|
-
cat ~/.claude/skills/hydra/config/hydra.config.md 2>/dev/null || \
|
|
42
|
-
cat .claude/skills/hydra/config/hydra.config.md 2>/dev/null || \
|
|
43
|
-
echo "No config file found (using defaults)"
|
|
44
|
-
```
|
|
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
|
-
|
|
56
|
-
## Display Format
|
|
57
|
-
|
|
58
|
-
Present results as a clean status card:
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
🐉 Hydra Framework Status
|
|
62
|
-
──────────────────────────────
|
|
63
|
-
Version: 1.0.0 (latest: 1.0.0 ✅) OR (update available: 1.1.0 ⚡)
|
|
64
|
-
Install: Global (~/.claude/)
|
|
65
|
-
Agents (7):
|
|
66
|
-
🟢 hydra-scout (Haiku 4.5) ✅
|
|
67
|
-
🟢 hydra-runner (Haiku 4.5) ✅
|
|
68
|
-
🟢 hydra-scribe (Haiku 4.5) ✅
|
|
69
|
-
🟢 hydra-guard (Haiku 4.5) ✅
|
|
70
|
-
🟢 hydra-git (Haiku 4.5) ✅
|
|
71
|
-
🔵 hydra-coder (Sonnet 4.6) ✅
|
|
72
|
-
🔵 hydra-analyst (Sonnet 4.6) ✅
|
|
73
|
-
Commands (
|
|
74
|
-
Hooks (4): check-update ✅, statusline ✅, auto-guard ✅, notify ✅
|
|
75
|
-
Map: ✅ Current (487 files, built 2026-03-26)
|
|
76
|
-
Config: balanced mode, dispatch log on, auto-guard on
|
|
77
|
-
──────────────────────────────
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
If an update is available, add:
|
|
81
|
-
```
|
|
82
|
-
⚡ Update available! Run /hydra:update to get the latest version.
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
For detailed token usage and savings, run: `/hydra:stats`
|
|
1
|
+
---
|
|
2
|
+
description: Show Hydra framework status — installed agents, version, config, and update availability
|
|
3
|
+
allowed-tools: Bash, Read, Glob
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hydra Status
|
|
7
|
+
|
|
8
|
+
Show a comprehensive status report for the Hydra framework.
|
|
9
|
+
|
|
10
|
+
## 1. Version Info
|
|
11
|
+
```bash
|
|
12
|
+
INSTALLED=$(cat ~/.claude/skills/hydra/VERSION 2>/dev/null || echo "unknown")
|
|
13
|
+
echo "Installed: $INSTALLED"
|
|
14
|
+
LATEST=$(npm view hail-hydra-cc version 2>/dev/null || echo "unknown")
|
|
15
|
+
echo "Latest: $LATEST"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 2. Installed Agents
|
|
19
|
+
```bash
|
|
20
|
+
echo "=== Global Agents ==="
|
|
21
|
+
ls -1 ~/.claude/agents/hydra-*.md 2>/dev/null || echo "None found"
|
|
22
|
+
echo "=== Local Agents ==="
|
|
23
|
+
ls -1 .claude/agents/hydra-*.md 2>/dev/null || echo "None found"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 3. Installed Commands
|
|
27
|
+
```bash
|
|
28
|
+
echo "=== Global Commands ==="
|
|
29
|
+
ls -1 ~/.claude/commands/hydra/*.md 2>/dev/null || echo "None found"
|
|
30
|
+
echo "=== Local Commands ==="
|
|
31
|
+
ls -1 .claude/commands/hydra/*.md 2>/dev/null || echo "None found"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 4. Hooks
|
|
35
|
+
```bash
|
|
36
|
+
ls -1 ~/.claude/hooks/hydra-*.js 2>/dev/null || echo "None found"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 5. Configuration
|
|
40
|
+
```bash
|
|
41
|
+
cat ~/.claude/skills/hydra/config/hydra.config.md 2>/dev/null || \
|
|
42
|
+
cat .claude/skills/hydra/config/hydra.config.md 2>/dev/null || \
|
|
43
|
+
echo "No config file found (using defaults)"
|
|
44
|
+
```
|
|
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
|
+
|
|
56
|
+
## Display Format
|
|
57
|
+
|
|
58
|
+
Present results as a clean status card:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
🐉 Hydra Framework Status
|
|
62
|
+
──────────────────────────────
|
|
63
|
+
Version: 1.0.0 (latest: 1.0.0 ✅) OR (update available: 1.1.0 ⚡)
|
|
64
|
+
Install: Global (~/.claude/)
|
|
65
|
+
Agents (7):
|
|
66
|
+
🟢 hydra-scout (Haiku 4.5) ✅
|
|
67
|
+
🟢 hydra-runner (Haiku 4.5) ✅
|
|
68
|
+
🟢 hydra-scribe (Haiku 4.5) ✅
|
|
69
|
+
🟢 hydra-guard (Haiku 4.5) ✅
|
|
70
|
+
🟢 hydra-git (Haiku 4.5) ✅
|
|
71
|
+
🔵 hydra-coder (Sonnet 4.6) ✅
|
|
72
|
+
🔵 hydra-analyst (Sonnet 4.6) ✅
|
|
73
|
+
Commands (12): update, status, help, config, guard, quiet, verbose, report, map, preflight, stats, stfu
|
|
74
|
+
Hooks (4): check-update ✅, statusline ✅, auto-guard ✅, notify ✅
|
|
75
|
+
Map: ✅ Current (487 files, built 2026-03-26)
|
|
76
|
+
Config: balanced mode, dispatch log on, auto-guard on
|
|
77
|
+
──────────────────────────────
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If an update is available, add:
|
|
81
|
+
```
|
|
82
|
+
⚡ Update available! Run /hydra:update to get the latest version.
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For detailed token usage and savings, run: `/hydra:stats`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Activate STFU-Agents mode — silence intermediate prose from every dispatched subagent
|
|
3
|
+
allowed-tools: Read
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hydra STFU Mode
|
|
7
|
+
|
|
8
|
+
Activate the STFU-Agents skill for this session.
|
|
9
|
+
|
|
10
|
+
Acknowledge with:
|
|
11
|
+
"🐉 STFU-Agents mode activated. All dispatched subagents will run with compressed internal thinking. Final outputs unchanged. Run `/skills` to deactivate or say 'verbose agents'."
|
|
12
|
+
|
|
13
|
+
From this point in the session, when dispatching ANY subagent via the Task tool, prepend the internal-compression directive defined in `skills/stfu-agents/SKILL.md` to the task description.
|
|
14
|
+
|
|
15
|
+
Applies until:
|
|
16
|
+
- Session ends
|
|
17
|
+
- User says "verbose agents" / "stop STFU"
|
|
18
|
+
- A conflicting skill is invoked
|
|
19
|
+
|
|
20
|
+
## Why
|
|
21
|
+
Subagents generate intermediate prose that's billed by Anthropic but never read. Final summary is the only thing returned to Opus. STFU tells every dispatched subagent to skip narration — same final output, fewer billed tokens. Universal scope: any subagent in the session, regardless of source.
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Enable verbose Hydra dispatch logs with timing and token estimates
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Hydra Verbose Mode
|
|
6
|
-
|
|
7
|
-
Acknowledge this command and remember for the rest of this session:
|
|
8
|
-
|
|
9
|
-
**Display DETAILED Hydra Dispatch Logs after every task that involves delegation.**
|
|
10
|
-
|
|
11
|
-
The verbose log includes extra columns for timing:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
🐉 Hydra Dispatch Log (verbose)
|
|
15
|
-
| Step | Agent | Task | Time | Verdict |
|
|
16
|
-
|------|---------------------|-----------------------|-------|-------------|
|
|
17
|
-
| 1 | hydra-scout (Haiku 4.5) | Explored auth module | 3.2s | ✅ Accepted |
|
|
18
|
-
| 2 | hydra-coder (Sonnet 4.6) | Fixed null check | 8.1s | ✅ Accepted |
|
|
19
|
-
| 3 | hydra-guard (Haiku 4.5) | Security scan | 1.4s | ✅ Passed |
|
|
20
|
-
| 4 | hydra-runner (Haiku 4.5) | Ran test suite | 4.7s | ✅ Accepted |
|
|
21
|
-
|
|
22
|
-
Delegation: 4/4 (100%) | Accepted: 4 | Adjusted: 0 | Rejected: 0
|
|
23
|
-
Total delegation time: 17.4s | Waves: 2
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Respond with:
|
|
27
|
-
"🐉 Verbose mode enabled. Dispatch logs will include timing details. Use /hydra:quiet to suppress."
|
|
28
|
-
|
|
29
|
-
Re-enable the task completion notification sound.
|
|
1
|
+
---
|
|
2
|
+
description: Enable verbose Hydra dispatch logs with timing and token estimates
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Hydra Verbose Mode
|
|
6
|
+
|
|
7
|
+
Acknowledge this command and remember for the rest of this session:
|
|
8
|
+
|
|
9
|
+
**Display DETAILED Hydra Dispatch Logs after every task that involves delegation.**
|
|
10
|
+
|
|
11
|
+
The verbose log includes extra columns for timing:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
🐉 Hydra Dispatch Log (verbose)
|
|
15
|
+
| Step | Agent | Task | Time | Verdict |
|
|
16
|
+
|------|---------------------|-----------------------|-------|-------------|
|
|
17
|
+
| 1 | hydra-scout (Haiku 4.5) | Explored auth module | 3.2s | ✅ Accepted |
|
|
18
|
+
| 2 | hydra-coder (Sonnet 4.6) | Fixed null check | 8.1s | ✅ Accepted |
|
|
19
|
+
| 3 | hydra-guard (Haiku 4.5) | Security scan | 1.4s | ✅ Passed |
|
|
20
|
+
| 4 | hydra-runner (Haiku 4.5) | Ran test suite | 4.7s | ✅ Accepted |
|
|
21
|
+
|
|
22
|
+
Delegation: 4/4 (100%) | Accepted: 4 | Adjusted: 0 | Rejected: 0
|
|
23
|
+
Total delegation time: 17.4s | Waves: 2
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Respond with:
|
|
27
|
+
"🐉 Verbose mode enabled. Dispatch logs will include timing details. Use /hydra:quiet to suppress."
|
|
28
|
+
|
|
29
|
+
Re-enable the task completion notification sound.
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// Hydra Auto-Guard Hook — PostToolUse (matcher: Write|Edit|MultiEdit)
|
|
4
|
-
// Records changed file paths to a temp file for hydra-guard to scan later.
|
|
5
|
-
// Does NOT run the scan itself — that would slow down every edit.
|
|
6
|
-
// Overhead: <1ms per edit. Files deduped by path.
|
|
7
|
-
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const os = require('os');
|
|
11
|
-
|
|
12
|
-
let input = '';
|
|
13
|
-
process.stdin.on('data', (chunk) => (input += chunk));
|
|
14
|
-
process.stdin.on('end', () => {
|
|
15
|
-
try {
|
|
16
|
-
const data = JSON.parse(input);
|
|
17
|
-
|
|
18
|
-
// Extract the file path from the tool input
|
|
19
|
-
const filePath = data.tool_input?.file_path ||
|
|
20
|
-
data.tool_input?.path ||
|
|
21
|
-
null;
|
|
22
|
-
|
|
23
|
-
if (!filePath) {
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Append to session-scoped changed files list
|
|
28
|
-
const sessionId = data.session_id || 'unknown';
|
|
29
|
-
const trackingDir = path.join(os.tmpdir(), 'hydra-guard');
|
|
30
|
-
const trackingFile = path.join(trackingDir, `${sessionId}.txt`);
|
|
31
|
-
|
|
32
|
-
// Ensure directory exists
|
|
33
|
-
if (!fs.existsSync(trackingDir)) {
|
|
34
|
-
fs.mkdirSync(trackingDir, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Read existing tracked files
|
|
38
|
-
let existing = '';
|
|
39
|
-
try {
|
|
40
|
-
existing = fs.readFileSync(trackingFile, 'utf8');
|
|
41
|
-
} catch (e) {
|
|
42
|
-
// File doesn't exist yet — that's fine
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Only append if not already tracked (dedup)
|
|
46
|
-
if (!existing.split('\n').includes(filePath)) {
|
|
47
|
-
fs.appendFileSync(trackingFile, filePath + '\n');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
} catch (e) {
|
|
51
|
-
// Silently fail — NEVER block Claude Code
|
|
52
|
-
}
|
|
53
|
-
process.exit(0);
|
|
54
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Hydra Auto-Guard Hook — PostToolUse (matcher: Write|Edit|MultiEdit)
|
|
4
|
+
// Records changed file paths to a temp file for hydra-guard to scan later.
|
|
5
|
+
// Does NOT run the scan itself — that would slow down every edit.
|
|
6
|
+
// Overhead: <1ms per edit. Files deduped by path.
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
|
|
12
|
+
let input = '';
|
|
13
|
+
process.stdin.on('data', (chunk) => (input += chunk));
|
|
14
|
+
process.stdin.on('end', () => {
|
|
15
|
+
try {
|
|
16
|
+
const data = JSON.parse(input);
|
|
17
|
+
|
|
18
|
+
// Extract the file path from the tool input
|
|
19
|
+
const filePath = data.tool_input?.file_path ||
|
|
20
|
+
data.tool_input?.path ||
|
|
21
|
+
null;
|
|
22
|
+
|
|
23
|
+
if (!filePath) {
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Append to session-scoped changed files list
|
|
28
|
+
const sessionId = data.session_id || 'unknown';
|
|
29
|
+
const trackingDir = path.join(os.tmpdir(), 'hydra-guard');
|
|
30
|
+
const trackingFile = path.join(trackingDir, `${sessionId}.txt`);
|
|
31
|
+
|
|
32
|
+
// Ensure directory exists
|
|
33
|
+
if (!fs.existsSync(trackingDir)) {
|
|
34
|
+
fs.mkdirSync(trackingDir, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Read existing tracked files
|
|
38
|
+
let existing = '';
|
|
39
|
+
try {
|
|
40
|
+
existing = fs.readFileSync(trackingFile, 'utf8');
|
|
41
|
+
} catch (e) {
|
|
42
|
+
// File doesn't exist yet — that's fine
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Only append if not already tracked (dedup)
|
|
46
|
+
if (!existing.split('\n').includes(filePath)) {
|
|
47
|
+
fs.appendFileSync(trackingFile, filePath + '\n');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
} catch (e) {
|
|
51
|
+
// Silently fail — NEVER block Claude Code
|
|
52
|
+
}
|
|
53
|
+
process.exit(0);
|
|
54
|
+
});
|