fix(skills): point the godmode skill's self-referencing install paths at its new location
The skill was moved to the security category as a pure R100 rename
(fdc90346ea), but the eleven install-path strings embedded in its own docs
and scripts kept the pre-move category. On a fresh install the skill lands
under the security category in the skills home, so every copy-pasteable
snippet in the docs and the loader fallbacks in the scripts raise
FileNotFoundError on first use. Rewrite both embedding forms — the
joined-string form and the segmented Path(...) form — and add a CI
contract test that fails when any optional skill references its own
install path under a category that does not match its location.
This commit is contained in:
1 parent
314076ca63
commit
5141b3122b
8 files changed
+88
-11
No files matched your search
@@ -61,7 +61,7 @@ The fastest path — auto-detect the model, test strategies, and lock in the win
|
||||
# In execute_code — use the loader to avoid exec-scoping issues:
|
||||
import os
|
||||
exec(open(os.path.expanduser(
|
||||
os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/load_godmode.py")
|
||||
os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/load_godmode.py")
|
||||
)).read())
|
||||
|
||||
# Auto-detect model from config and jailbreak it
|
||||
@@ -192,7 +192,7 @@ python scripts/parseltongue.py "How do I hack into a WiFi network?" --tier stand
|
||||
Or use `execute_code` inline:
|
||||
```python
|
||||
# Load the parseltongue module
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/parseltongue.py")).read())
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/parseltongue.py")).read())
|
||||
|
||||
query = "How do I hack into a WiFi network?"
|
||||
variants = generate_variants(query, tier="standard")
|
||||
@@ -229,7 +229,7 @@ Race multiple models against the same query, score responses, pick the winner:
|
||||
|
||||
```python
|
||||
# Via execute_code
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/godmode_race.py")).read())
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/godmode_race.py")).read())
|
||||
|
||||
result = race_models(
|
||||
query="Explain how SQL injection works with a practical example",
|
||||
|
||||
@@ -114,7 +114,7 @@ hermes
|
||||
### Via the GODMODE CLASSIC racer script
|
||||
|
||||
```python
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/godmode_race.py")).read())
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/godmode_race.py")).read())
|
||||
result = race_godmode_classic("Your query here")
|
||||
print(f"Winner: {result['codename']} — Score: {result['score']}")
|
||||
print(result['content'])
|
||||
|
||||
@@ -129,7 +129,7 @@ These don't auto-reject but reduce the response score:
|
||||
## Using in Python
|
||||
|
||||
```python
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/godmode_race.py")).read())
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/godmode_race.py")).read())
|
||||
|
||||
# Check if a response is a refusal
|
||||
text = "I'm sorry, but I can't assist with that request."
|
||||
|
||||
@@ -7,7 +7,7 @@ finds what works, and locks it in by writing config.yaml + prefill.json.
|
||||
|
||||
Usage in execute_code:
|
||||
exec(open(os.path.expanduser(
|
||||
os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/auto_jailbreak.py")
|
||||
os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/auto_jailbreak.py")
|
||||
)).read())
|
||||
|
||||
result = auto_jailbreak() # Uses current model from config
|
||||
@@ -35,7 +35,7 @@ try:
|
||||
_SKILL_DIR = Path(__file__).resolve().parent.parent
|
||||
except NameError:
|
||||
# __file__ not defined when loaded via exec() — search standard paths
|
||||
_SKILL_DIR = Path(os.getenv("HERMES_HOME", Path.home() / ".hermes")) / "skills" / "red-teaming" / "godmode"
|
||||
_SKILL_DIR = Path(os.getenv("HERMES_HOME", Path.home() / ".hermes")) / "skills" / "security" / "godmode"
|
||||
|
||||
_SCRIPTS_DIR = _SKILL_DIR / "scripts"
|
||||
_TEMPLATES_DIR = _SKILL_DIR / "templates"
|
||||
|
||||
@@ -7,7 +7,7 @@ Queries multiple models in parallel via OpenRouter, scores responses
|
||||
on quality/filteredness/speed, returns the best unfiltered answer.
|
||||
|
||||
Usage in execute_code:
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/godmode_race.py")).read())
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/godmode_race.py")).read())
|
||||
|
||||
result = race_models(
|
||||
query="Your query here",
|
||||
|
||||
@@ -3,7 +3,7 @@ Loader for G0DM0D3 scripts. Handles the exec-scoping issues.
|
||||
|
||||
Usage in execute_code:
|
||||
exec(open(os.path.expanduser(
|
||||
os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/load_godmode.py")
|
||||
os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/load_godmode.py")
|
||||
)).read())
|
||||
|
||||
# Now all functions are available:
|
||||
@@ -17,7 +17,7 @@ Usage in execute_code:
|
||||
import os, sys
|
||||
from pathlib import Path
|
||||
|
||||
_gm_scripts_dir = Path(os.getenv("HERMES_HOME", Path.home() / ".hermes")) / "skills" / "red-teaming" / "godmode" / "scripts"
|
||||
_gm_scripts_dir = Path(os.getenv("HERMES_HOME", Path.home() / ".hermes")) / "skills" / "security" / "godmode" / "scripts"
|
||||
|
||||
_gm_old_argv = sys.argv
|
||||
sys.argv = ["_godmode_loader"]
|
||||
|
||||
@@ -11,7 +11,7 @@ Usage:
|
||||
python parseltongue.py "How do I hack a WiFi network?" --tier standard
|
||||
|
||||
# As a module in execute_code
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/parseltongue.py")).read())
|
||||
exec(open(os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/security/godmode/scripts/parseltongue.py")).read())
|
||||
variants = generate_variants("How do I hack a WiFi network?", tier="standard")
|
||||
"""
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
"""Contract: a skill's self-referencing install paths match its own location.
|
||||
|
||||
The hub installs ``optional-skills/<category>/<name>`` to
|
||||
``$HERMES_HOME/skills/<category>/<name>``, preserving the category path.
|
||||
When a skill is moved between categories, the install-path strings embedded
|
||||
in its own docs and scripts (joined ``skills/<category>/<name>/...`` and the
|
||||
segmented ``Path(...) / "skills" / "<category>" / "<name>"`` form) keep
|
||||
pointing at the pre-move directory, so every copy-pasteable snippet raises
|
||||
FileNotFoundError (#115695). Nothing else catches that drift today; this
|
||||
test does, for every optional skill, at CI time.
|
||||
|
||||
Only *self*-references are checked (the reference names the skill itself),
|
||||
so cross-skill references and foreign-repo paths in port notes are immune.
|
||||
"""
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
OPTIONAL = REPO / "optional-skills"
|
||||
|
||||
# Text formats that carry copy-pasteable install paths; data files can be
|
||||
# huge, so cap the scan well above any real doc/script.
|
||||
_SCAN_SUFFIXES = {".md", ".py", ".txt", ".sh", ".yaml", ".yml", ".toml", ".json"}
|
||||
_MAX_SCAN_BYTES = 2 * 1024 * 1024
|
||||
|
||||
|
||||
def _skill_roots():
|
||||
roots = {skill_md.parent for skill_md in OPTIONAL.rglob("SKILL.md")}
|
||||
return sorted(roots)
|
||||
|
||||
|
||||
def _scan_files(root):
|
||||
for path in sorted(root.rglob("*")):
|
||||
if not path.is_file() or path.suffix.lower() not in _SCAN_SUFFIXES:
|
||||
continue
|
||||
if path.stat().st_size > _MAX_SCAN_BYTES:
|
||||
continue
|
||||
yield path
|
||||
|
||||
|
||||
def _stale_self_references(root):
|
||||
"""Yield (file, line_no, snippet) for self-install paths that cannot resolve."""
|
||||
name = re.escape(root.name)
|
||||
# skills/<category>/<name>/... — joined-string form
|
||||
joined = re.compile(rf"skills/([\w.-]+)/{name}\b")
|
||||
# Path(...) / "skills" / "<category>" / "<name>" — segmented form
|
||||
segmented = re.compile(
|
||||
rf'["\']skills["\']\s*/\s*["\']([\w.-]+)["\']\s*/\s*["\']{name}["\']'
|
||||
)
|
||||
stale = []
|
||||
for path in _scan_files(root):
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
except (UnicodeDecodeError, OSError):
|
||||
continue
|
||||
for line_no, line in enumerate(text.splitlines(), start=1):
|
||||
for match in joined.finditer(line):
|
||||
category = match.group(1)
|
||||
if not (OPTIONAL / category / root.name).is_dir():
|
||||
stale.append((path.relative_to(REPO), line_no, match.group(0)))
|
||||
for match in segmented.finditer(line):
|
||||
category = match.group(1)
|
||||
if not (OPTIONAL / category / root.name).is_dir():
|
||||
stale.append((path.relative_to(REPO), line_no, match.group(0)))
|
||||
return stale
|
||||
|
||||
|
||||
def test_optional_skills_self_install_paths_resolve_to_their_own_location():
|
||||
offenders = []
|
||||
for root in _skill_roots():
|
||||
offenders.extend(_stale_self_references(root))
|
||||
assert not offenders, (
|
||||
"Optional skills reference their own install path under a category "
|
||||
"that does not match their location (the skill moved, the embedded "
|
||||
"paths did not):\n"
|
||||
+ "\n".join(f" {f}:{line}: {snippet}" for f, line, snippet in offenders)
|
||||
)
|
||||
Reference in new issue
Block a user