mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Update SKILL.md
This commit is contained in:
parent
068b224887
commit
aeecf06dee
1 changed files with 109 additions and 259 deletions
|
|
@ -1,306 +1,156 @@
|
|||
---
|
||||
name: disk-guardian
|
||||
description: >
|
||||
Keeps Hermes's disk footprint clean. Tracks temp files, test outputs, research
|
||||
artifacts, and large downloads created during sessions, then removes stale ones
|
||||
safely. Especially useful on WSL2 where disk fills up fast during long agent runs.
|
||||
version: 1.0.0
|
||||
Cleans up ephemeral files Hermes creates during sessions — temp outputs,
|
||||
test scripts, test artifacts, cron logs, and stale chrome profiles.
|
||||
Auto-deletes test files at the end of every task. Runs automatically when
|
||||
disk usage is high or sessions are long. Scoped strictly to HERMES_HOME.
|
||||
Triggers: "clean up", "free disk space", "disk is full", "remove test files",
|
||||
"what temp files exist", "show disk usage", "run cleanup".
|
||||
version: 1.2.0
|
||||
platforms: [linux]
|
||||
requires_toolsets: [terminal]
|
||||
metadata:
|
||||
hermes:
|
||||
tags: [devops, maintenance, disk, cleanup, WSL2]
|
||||
tags: [devops, maintenance, cleanup, ephemeral, WSL2, auto]
|
||||
category: devops
|
||||
---
|
||||
|
||||
# Disk Guardian
|
||||
|
||||
Autonomous disk cleanup for Hermes Agent. Tracks files created during sessions and safely removes stale ones to prevent disk space exhaustion, especially on WSL2 where disk fills up fast during long agent runs.
|
||||
Tracks and removes **ephemeral files Hermes creates** during sessions:
|
||||
temp outputs, test scripts/artifacts, cron logs, stale chrome profiles,
|
||||
and large downloads. Scope is strictly `HERMES_HOME` and `/tmp/hermes-*`.
|
||||
Never touches `~/.hermes/logs/` or any system directory.
|
||||
|
||||
## When to Use
|
||||
|
||||
- User reports disk space issues or slow performance
|
||||
- Long-running sessions have accumulated temp files
|
||||
- Research artifacts from deep-research need cleanup
|
||||
- Chrome debug profiles from NotebookLM authentication are growing
|
||||
- User wants to see disk usage breakdown by category
|
||||
- User wants to clean up old test outputs and logs
|
||||
**Auto-trigger (no user prompt needed):**
|
||||
- End of every task that created test files → run `quick` silently
|
||||
- Session context window exceeds 60% → run `quick` silently
|
||||
- Any tool call creates a file matching `test_*`, `*.test.*`, `tmp_*` → track it immediately
|
||||
- User says "done", "finished", "task complete" after a multi-step task
|
||||
|
||||
## Core Behaviors
|
||||
**User-triggered:**
|
||||
- User says "disk is full", "clean up", "free space", "remove temp files"
|
||||
- User says "what's taking disk space", "show disk usage"
|
||||
- User asks for dry-run preview before committing to deletion
|
||||
|
||||
1. **Silent Tracking** - Log every path Hermes writes to tracked.json with timestamp + category
|
||||
2. **Safe Auto-Cleanup** - Delete stale files by age/size rules with appropriate safety checks
|
||||
3. **Status Reporting** - Show disk usage breakdown and largest files
|
||||
## Auto-Run Behavior
|
||||
|
||||
## First-Time Setup
|
||||
This skill runs **silently in the background**. When auto-running:
|
||||
- Never ask for confirmation for safe categories (temp, test, empty dirs)
|
||||
- Print one line after: `[disk-guardian] Cleaned 12 files, freed 234 MB`
|
||||
- Only surface to the user if something needs confirmation (research folders, large files >500 MB)
|
||||
|
||||
On first run, create the disk-guardian directory and state files:
|
||||
## Memory — Install Once, Active Forever
|
||||
|
||||
On first install, run this to write persistent memory rules so the behavior
|
||||
carries across all future sessions automatically:
|
||||
|
||||
```bash
|
||||
# Create directory
|
||||
mkdir -p "$(get_hermes_home)/disk-guardian"
|
||||
|
||||
# Initialize tracking file
|
||||
echo '[]' > "$(get_hermes_home)/disk-guardian/tracked.json"
|
||||
|
||||
# Initialize log file
|
||||
touch "$(get_hermes_home)/disk-guardian/cleanup.log"
|
||||
|
||||
# Optional: Register weekly cronjob (Sunday 3 AM)
|
||||
# This is optional - skill works without cron
|
||||
python3 ~/.hermes/optional-skills/devops/disk-guardian/scripts/disk_guardian.py install-memory
|
||||
```
|
||||
|
||||
The skill uses `get_hermes_home()` to resolve the actual path. Never hardcode `~/.hermes` - the path is resolved by the agent, not hardcoded.
|
||||
This adds to Hermes memory:
|
||||
- Auto-track every file created under HERMES_HOME during tasks
|
||||
- Auto-run quick cleanup at end of every task that created test files
|
||||
- Auto-run quick cleanup if HERMES_HOME disk usage exceeds 5 GB
|
||||
- Never ask permission for temp/test cleanup — clean silently and report one line
|
||||
|
||||
## Silent Tracking Protocol
|
||||
|
||||
Track files when Hermes creates them via write_file or terminal:
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
# Track a temp file
|
||||
python disk_guardian.py track "/tmp/hermes-abc123/output.json" "temp"
|
||||
SCRIPT=~/.hermes/optional-skills/devops/disk-guardian/scripts/disk_guardian.py
|
||||
|
||||
# Track a research artifact
|
||||
python disk_guardian.py track "$(get_hermes_home)/research/ai-safety/paper.pdf" "research"
|
||||
|
||||
# Track a test output
|
||||
python disk_guardian.py track "$(get_hermes_home)/test_results/test_001.log" "test"
|
||||
|
||||
# Track a download
|
||||
python disk_guardian.py track "$(get_hermes_home)/downloads/model.gguf" "download"
|
||||
|
||||
# Track a chrome profile
|
||||
python disk_guardian.py track "$(get_hermes_home)/.local/share/notebooklm-mcp/chrome_profile_abc" "chrome-profile"
|
||||
python3 $SCRIPT install-memory # write persistent memory (run once after install)
|
||||
python3 $SCRIPT status # show breakdown by category + top 10 largest
|
||||
python3 $SCRIPT dry-run # preview deletions, touch nothing
|
||||
python3 $SCRIPT quick # auto-delete safe files (no prompts)
|
||||
python3 $SCRIPT deep # full cleanup, prompt for risky items
|
||||
python3 $SCRIPT track <path> <category> # register a file
|
||||
python3 $SCRIPT forget <path> # stop tracking a path
|
||||
```
|
||||
|
||||
Categories: `temp`, `test`, `research`, `download`, `chrome-profile`, `cron-output`, `other`
|
||||
## Procedure
|
||||
|
||||
Always use `shlex.quote()` when interpolating user input into shell commands.
|
||||
### Step 1 — Track files as Hermes creates them
|
||||
|
||||
## Cleanup Rules
|
||||
|
||||
### Rule 1: Temp Files (> 7 days)
|
||||
Whenever Hermes creates a file via `write_file` or `terminal`, immediately track it:
|
||||
|
||||
```bash
|
||||
find "$(get_hermes_home)/cache/hermes" -type f -mtime +7 -delete
|
||||
find "/tmp/hermes-*" -type f -mtime +7 -delete
|
||||
# Test script created during a task
|
||||
python3 $SCRIPT track "/home/user/.hermes/test_output.py" "test"
|
||||
|
||||
# Temp output
|
||||
python3 $SCRIPT track "/home/user/.hermes/cache/run_abc.json" "temp"
|
||||
|
||||
# Cron output
|
||||
python3 $SCRIPT track "/home/user/.hermes/cron/report_2026.md" "cron-output"
|
||||
|
||||
# Chrome profile
|
||||
python3 $SCRIPT track "/home/user/.local/share/notebooklm-mcp/chrome_profile_x" "chrome-profile"
|
||||
```
|
||||
|
||||
Auto-delete without confirmation.
|
||||
Categories: `temp` | `test` | `research` | `download` | `chrome-profile` | `cron-output` | `other`
|
||||
|
||||
### Rule 2: Test Outputs (> 3 days)
|
||||
Always wrap user-supplied paths with `shlex.quote()`.
|
||||
|
||||
### Step 2 — Auto-delete test files at end of every task
|
||||
|
||||
At the end of **every task** that involved creating or running test files, silently run:
|
||||
|
||||
```bash
|
||||
find "$(get_hermes_home)" -type f \( -name "test_*.py" -o -name "*.test.log" -o -name "tmp_*.json" \) -mtime +3 -delete
|
||||
python3 $SCRIPT quick
|
||||
```
|
||||
|
||||
Auto-delete without confirmation.
|
||||
Output: `[disk-guardian] Cleaned 3 test files, freed 45 KB`
|
||||
|
||||
### Rule 3: Empty Directories
|
||||
Do not ask the user — just clean and report one line.
|
||||
|
||||
### Step 3 — Respond to user cleanup requests
|
||||
|
||||
```bash
|
||||
find "$(get_hermes_home)" -type d -empty -delete
|
||||
# Safe, no prompts
|
||||
python3 $SCRIPT quick
|
||||
|
||||
# Full cleanup with confirmation for research/large files
|
||||
python3 $SCRIPT deep
|
||||
|
||||
# Preview only
|
||||
python3 $SCRIPT dry-run
|
||||
```
|
||||
|
||||
Auto-delete without confirmation.
|
||||
## Cleanup Rules (Deterministic)
|
||||
|
||||
### Rule 4: Research Folders (keep last 10)
|
||||
| Category | Threshold | Confirmation |
|
||||
|---|---|---|
|
||||
| `test` | >0 days — delete at task end | Never |
|
||||
| `temp` | >7 days since tracked | Never |
|
||||
| empty dirs under HERMES_HOME | always | Never |
|
||||
| `cron-output` | >14 days since tracked | Never |
|
||||
| `research` | >30 days, beyond 10 newest | Always |
|
||||
| `chrome-profile` | >14 days since tracked | Always |
|
||||
| `download` / `other` | never auto | Always (deep only) |
|
||||
| any file >500 MB | never auto | Always (deep only) |
|
||||
|
||||
## Pitfalls
|
||||
|
||||
- **Never hardcode `~/.hermes`** — always use `HERMES_HOME` env var or `get_hermes_home()`
|
||||
- **Never touch `~/.hermes/logs/`** — agent debug logs are not ephemeral artifacts
|
||||
- **Backup/restore scoped to `tracked.json` only** — never agent logs or other Hermes state
|
||||
- **WSL2: reject Windows mounts** — `/mnt/c/` and all `/mnt/` paths rejected by `_is_safe_path()`
|
||||
- **Test files are always ephemeral** — delete aggressively, never prompt
|
||||
- **Silent by default** — only interrupt the user when confirmation is genuinely required
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
# List research folders sorted by modification time
|
||||
ls -td "$(get_hermes_home)/research"/* 2>/dev/null | tail -n +11 | while read dir; do
|
||||
echo "Delete old research folder: $dir? [y/N]"
|
||||
# Prompt user for confirmation
|
||||
done
|
||||
```
|
||||
|
||||
Prompt before deleting older than last 10.
|
||||
|
||||
### Rule 5: Chrome Debug Profiles (> 14 days)
|
||||
|
||||
```bash
|
||||
find "$(get_hermes_home)/.local/share/notebooklm-mcp" -type d -name "chrome_profile*" -mtime +14
|
||||
```
|
||||
|
||||
Warn + offer to trim.
|
||||
|
||||
### Rule 6: Large Files (> 500 MB)
|
||||
|
||||
```bash
|
||||
find "$(get_hermes_home)" -type f -size +500M -exec ls -lh {} \;
|
||||
```
|
||||
|
||||
Warn + offer to delete if looks like temp download.
|
||||
|
||||
## Sub-Command Implementations
|
||||
|
||||
### /cleanup dry-run
|
||||
|
||||
Preview what would be deleted without touching anything:
|
||||
|
||||
```bash
|
||||
python disk_guardian.py dry-run
|
||||
```
|
||||
|
||||
Returns list of files that would be deleted by each rule, with total size.
|
||||
|
||||
### /cleanup quick
|
||||
|
||||
Safe fast clean, no confirmation needed:
|
||||
|
||||
```bash
|
||||
python disk_guardian.py quick
|
||||
```
|
||||
|
||||
Applies Rules 1-3 (temp, test, empty dirs). Returns summary: "Deleted 15 files, freed 234 MB"
|
||||
|
||||
### /cleanup deep
|
||||
|
||||
Full scan, confirm before anything > 100 MB or research folders:
|
||||
|
||||
```bash
|
||||
python disk_guardian.py deep
|
||||
```
|
||||
|
||||
Applies all rules. For risky items (research folders, large files, chrome profiles), prompts user for confirmation. Returns detailed breakdown by category.
|
||||
|
||||
### /cleanup status
|
||||
|
||||
Disk usage breakdown by category + top 10 largest Hermes files:
|
||||
|
||||
```bash
|
||||
python disk_guardian.py status
|
||||
```
|
||||
|
||||
Returns table with categories (temp, test, research, download, chrome-profile, other) and disk usage, plus top 10 largest files.
|
||||
|
||||
### /cleanup forget <path>
|
||||
|
||||
Remove a path from tracking permanently:
|
||||
|
||||
```bash
|
||||
python disk_guardian.py forget "$(shlex.quote "$path")"
|
||||
```
|
||||
|
||||
Removes entry from tracked.json and logs action.
|
||||
|
||||
## Integration with deep-research-monitor
|
||||
|
||||
If deep-research-monitor skill is present, offer to clean/archive the research folder after `/deep-research stop <topic>`:
|
||||
|
||||
```bash
|
||||
# After deep-research stops, prompt user:
|
||||
echo "Research complete. Clean up old research folders? [y/N]"
|
||||
# If yes, run: python disk_guardian.py deep --category research
|
||||
```
|
||||
|
||||
## Pitfalls to Avoid
|
||||
|
||||
1. **Never hardcode `~/.hermes`** - Always use `get_hermes_home()` for path resolution
|
||||
2. **Always use `shlex.quote()`** - When interpolating user input into shell commands
|
||||
3. **Don't delete outside Hermes home** - Validate all paths are under Hermes home directory
|
||||
4. **Don't delete research artifacts without confirmation** - These are valuable user data
|
||||
5. **Don't delete large files without warning** - User may need them
|
||||
6. **Don't assume WSL2** - Check `/proc/version` for "microsoft" marker
|
||||
7. **Don't delete Windows drives in WSL2** - Skip `/mnt/c/` and other Windows mounts
|
||||
8. **Don't corrupt tracked.json** - Use file locking and atomic writes
|
||||
9. **Don't ignore errors** - Log all errors and provide user feedback
|
||||
10. **Don't require cron** - Skill works perfectly without cron integration
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error Scenario | Detection | Recovery | User Message |
|
||||
|----------------|-----------|----------|--------------|
|
||||
| tracked.json corrupted | JSON parse fails | Backup file restoration | "Tracking file corrupted, restored from backup" |
|
||||
| Permission denied | OSError on delete | Skip file, log error | "Cannot delete <path>: permission denied" |
|
||||
| Path doesn't exist | FileNotFoundError | Remove from tracking | "Path <path> no longer exists, removed from tracking" |
|
||||
| Disk full | OSError on write | Abort operation, report | "Disk full, cannot write to tracking file" |
|
||||
| Invalid category | Category not in allowed list | Default to "other" | "Unknown category, using 'other'" |
|
||||
| WSL detection fails | /proc/version unreadable | Assume non-WSL | "Cannot detect WSL, using default paths" |
|
||||
| Cron registration fails | crontab command fails | Continue without cron | "Cron registration failed, skill works without it" |
|
||||
| Concurrent cleanup | File lock fails | Wait and retry | "Another cleanup in progress, waiting..." |
|
||||
|
||||
## Example Interactions
|
||||
|
||||
**User:** "My disk is full, help me clean up"
|
||||
|
||||
**Agent:** "I'll run a quick cleanup to remove temp files and test outputs. This won't delete any research artifacts or large files without asking."
|
||||
|
||||
```bash
|
||||
python disk_guardian.py quick
|
||||
```
|
||||
|
||||
**Output:** "Deleted 23 temp files, freed 456 MB. Run `/cleanup deep` for more thorough cleanup including research folders and large files."
|
||||
|
||||
---
|
||||
|
||||
**User:** "Show me what's taking up space"
|
||||
|
||||
**Agent:** "Here's your disk usage breakdown:"
|
||||
|
||||
```bash
|
||||
python disk_guardian.py status
|
||||
```
|
||||
|
||||
**Output:**
|
||||
```
|
||||
Category | Files | Size
|
||||
----------------|-------|--------
|
||||
temp | 156 | 2.3 GB
|
||||
test | 45 | 890 MB
|
||||
research | 12 | 15.6 GB
|
||||
download | 3 | 4.2 GB
|
||||
chrome-profile | 2 | 1.1 GB
|
||||
other | 89 | 3.4 GB
|
||||
|
||||
Top 10 largest files:
|
||||
1. /home/user/.hermes/research/llm-training/model.gguf (4.2 GB)
|
||||
2. /home/user/.hermes/cache/hermes/trajectory_cache.db (2.1 GB)
|
||||
3. /home/user/.hermes/downloads/dataset.zip (1.8 GB)
|
||||
...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**User:** "Clean up everything, including research folders"
|
||||
|
||||
**Agent:** "I'll run a deep cleanup. This will prompt you before deleting research folders and large files."
|
||||
|
||||
```bash
|
||||
python disk_guardian.py deep
|
||||
```
|
||||
|
||||
**Output:**
|
||||
```
|
||||
Found 12 research folders. Keeping last 10 by modification time.
|
||||
Delete old research folder: /home/user/.hermes/research/old-project? [y/N] y
|
||||
Deleted: /home/user/.hermes/research/old-project (1.2 GB)
|
||||
|
||||
Found 3 files > 500 MB:
|
||||
1. /home/user/.hermes/downloads/model.gguf (4.2 GB) - looks like temp download
|
||||
Delete this file? [y/N] y
|
||||
Deleted: /home/user/.hermes/downloads/model.gguf (4.2 GB)
|
||||
|
||||
Summary: Deleted 2 items, freed 5.4 GB
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**User:** "I want to see what would be deleted without actually deleting anything"
|
||||
|
||||
**Agent:** "Running dry-run to preview cleanup actions:"
|
||||
|
||||
```bash
|
||||
python disk_guardian.py dry-run
|
||||
```
|
||||
|
||||
**Output:**
|
||||
```
|
||||
Would delete 156 temp files (2.3 GB)
|
||||
Would delete 45 test files (890 MB)
|
||||
Would delete 23 empty directories
|
||||
Would prompt for 2 research folders (3.4 GB)
|
||||
Would prompt for 3 large files (6.0 GB)
|
||||
|
||||
Total potential cleanup: 12.5 GB
|
||||
Run `/cleanup quick` for safe auto-cleanup
|
||||
Run `/cleanup deep` for full cleanup with confirmation
|
||||
# After quick cleanup:
|
||||
tail -5 ~/.hermes/disk-guardian/cleanup.log
|
||||
# Should show DELETED entries for test/temp files
|
||||
|
||||
# After install-memory:
|
||||
# Ask Hermes: "what do you remember about disk cleanup?"
|
||||
# Should confirm auto-cleanup rules are in memory
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue