Skip to content

Commit a90862b

Browse files
committed
fix: address Copilot round 4 — home-relative dir resolution + project-local detection
1. _resolve_agent_dir(): expand ~/... via Path.home() + slice instead of expanduser(), so tests that monkeypatch Path.home() properly isolate the home directory (Copilot r3312731595, r3312731729) 2. Add detect_dir field to registrar_config: Hermes declares detect_dir='.hermes/skills' (project-local marker). CommandRegistrar checks detect_dir before resolving the output dir, preventing global dirs like ~/.hermes/skills from causing false detection in every project (Copilot r3312731682) 3. test_update_failure_rolls_back: no additional changes needed — the _resolve_agent_dir fix makes the existing Path.home() monkeypatch effective, so ~/.hermes/skills is not found in the fake home and Hermes is properly skipped. Tests: 2236 passed (2009 integration + 195 extension + 32 hermes)
1 parent b938619 commit a90862b

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/specify_cli/agents.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,10 @@ def _resolve_agent_dir(
669669
"""
670670
dir_str = agent_config["dir"]
671671
if dir_str.startswith("~"):
672-
agent_dir = Path(dir_str).expanduser()
672+
# Use Path.home() + remainder instead of expanduser() so tests
673+
# that monkeypatch Path.home() can properly isolate the home dir.
674+
# expanduser() uses OS env/user lookup and ignores monkeypatches.
675+
agent_dir = Path.home() / dir_str[1:].lstrip("/")
673676
else:
674677
p = Path(dir_str)
675678
agent_dir = p if p.is_absolute() else project_root / p
@@ -714,6 +717,15 @@ def register_commands_for_all_agents(
714717

715718
self._ensure_configs()
716719
for agent_name, agent_config in self.AGENT_CONFIGS.items():
720+
# Check detect_dir first (project-local marker) if configured,
721+
# falling back to the resolved dir for output. This prevents
722+
# global dirs (e.g. ~/.hermes/skills) from causing false
723+
# detection in every project.
724+
detect_dir_str = agent_config.get("detect_dir")
725+
if detect_dir_str:
726+
detect_path = project_root / detect_dir_str
727+
if not detect_path.exists():
728+
continue
717729
agent_dir = self._resolve_agent_dir(
718730
agent_name, agent_config, project_root,
719731
)
@@ -765,6 +777,11 @@ def register_commands_for_non_skill_agents(
765777
for agent_name, agent_config in self.AGENT_CONFIGS.items():
766778
if agent_config.get("extension") == "/SKILL.md":
767779
continue
780+
detect_dir_str = agent_config.get("detect_dir")
781+
if detect_dir_str:
782+
detect_path = project_root / detect_dir_str
783+
if not detect_path.exists():
784+
continue
768785
agent_dir = self._resolve_agent_dir(
769786
agent_name, agent_config, project_root,
770787
)

src/specify_cli/integrations/hermes/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class HermesIntegration(SkillsIntegration):
4545
}
4646
registrar_config = {
4747
"dir": "~/.hermes/skills",
48+
"detect_dir": ".hermes/skills",
4849
"format": "markdown",
4950
"args": "$ARGUMENTS",
5051
"extension": "/SKILL.md",

0 commit comments

Comments
 (0)