Skip to content

The agent that grows with you

refactor(context-refs): read HOME_CREDENTIAL_DIRS directly for the @file block

kshitijk4poora606a4f94bbf
diff --git a/agent/context_references.py b/agent/context_references.py
index cd9243b89da..3256924d5e3 100644
--- a/agent/context_references.py
+++ b/agent/context_references.py
@@ -91,7 +91,6 @@ _FILE_VALUE_PATTERN = re.compile(
TRAILING_PUNCTUATION = ",.;!?"
_OPENERS = {")": "(", "]": "[", "}": "{"}
_NEEDS_QUOTING = re.compile(r"""[\s()\[\]{}<>"'`]""")
-_SENSITIVE_HOME_DIRS = HOME_CREDENTIAL_DIRS # one list with the write denylist and profile export
_SENSITIVE_HERMES_DIRS = (Path("skills") / ".hub",)
_SENSITIVE_HOME_FILES = tuple(Path(p) for p in (
".ssh/authorized_keys", ".ssh/id_rsa", ".ssh/id_ed25519", ".ssh/config", ".bashrc", ".zshrc",
@@ -526,7 +525,7 @@ def _ensure_reference_path_allowed(path: Path) -> None:
from hermes_constants import get_hermes_home
home, hermes_home = Path(os.path.expanduser("~")).resolve(), get_hermes_home().resolve()
blocked_exact = {home / rel for rel in _SENSITIVE_HOME_FILES} | {hermes_home / ".env"}
- blocked_dirs = [home / rel for rel in _SENSITIVE_HOME_DIRS] + [hermes_home / rel for rel in _SENSITIVE_HERMES_DIRS]
+ blocked_dirs = [home / rel for rel in HOME_CREDENTIAL_DIRS] + [hermes_home / rel for rel in _SENSITIVE_HERMES_DIRS]
if path in blocked_exact:
raise ValueError("path is a sensitive credential file and cannot be attached")
if any(_is_under(path, blocked_dir) for blocked_dir in blocked_dirs):