fix(gateway): use profile-aware Hermes paths in runtime hints

This commit is contained in:
Xowiek 2026-04-15 22:27:36 +03:00 committed by Teknium
parent 5ef0fe1665
commit 77435c4f13
5 changed files with 34 additions and 3 deletions

View file

@ -4990,6 +4990,7 @@ class GatewayRunner:
async def _handle_personality_command(self, event: MessageEvent) -> str: async def _handle_personality_command(self, event: MessageEvent) -> str:
"""Handle /personality command - list or set a personality.""" """Handle /personality command - list or set a personality."""
import yaml import yaml
from hermes_constants import display_hermes_home
args = event.get_command_args().strip().lower() args = event.get_command_args().strip().lower()
config_path = _hermes_home / 'config.yaml' config_path = _hermes_home / 'config.yaml'
@ -5007,7 +5008,7 @@ class GatewayRunner:
personalities = {} personalities = {}
if not personalities: if not personalities:
return "No personalities configured in `~/.hermes/config.yaml`" return f"No personalities configured in `{display_hermes_home()}/config.yaml`"
if not args: if not args:
lines = ["🎭 **Available Personalities**\n"] lines = ["🎭 **Available Personalities**\n"]

View file

@ -301,6 +301,8 @@ def build_session_context_prompt(
lines.append("") lines.append("")
lines.append("**Delivery options for scheduled tasks:**") lines.append("**Delivery options for scheduled tasks:**")
from hermes_constants import display_hermes_home
# Origin delivery # Origin delivery
if context.source.platform == Platform.LOCAL: if context.source.platform == Platform.LOCAL:
lines.append("- `\"origin\"` → Local output (saved to files)") lines.append("- `\"origin\"` → Local output (saved to files)")
@ -309,9 +311,11 @@ def build_session_context_prompt(
_hash_chat_id(context.source.chat_id) if redact_pii else context.source.chat_id _hash_chat_id(context.source.chat_id) if redact_pii else context.source.chat_id
) )
lines.append(f"- `\"origin\"` → Back to this chat ({_origin_label})") lines.append(f"- `\"origin\"` → Back to this chat ({_origin_label})")
# Local always available # Local always available
lines.append("- `\"local\"` → Save to local files only (~/.hermes/cron/output/)") lines.append(
f"- `\"local\"` → Save to local files only ({display_hermes_home()}/cron/output/)"
)
# Platform home channels # Platform home channels
for platform, home in context.home_channels.items(): for platform, home in context.home_channels.items():

View file

@ -125,6 +125,7 @@ AUTHOR_MAP = {
"balyan.sid@gmail.com": "balyansid", "balyan.sid@gmail.com": "balyansid",
"oluwadareab12@gmail.com": "bennytimz", "oluwadareab12@gmail.com": "bennytimz",
"simon@simonmarcus.org": "simon-marcus", "simon@simonmarcus.org": "simon-marcus",
"xowiekk@gmail.com": "Xowiek",
"1243352777@qq.com": "zons-zhaozhy", "1243352777@qq.com": "zons-zhaozhy",
# ── bulk addition: 75 emails resolved via API, PR salvage bodies, noreply # ── bulk addition: 75 emails resolved via API, PR salvage bodies, noreply
# crossref, and GH contributor list matching (April 2026 audit) ── # crossref, and GH contributor list matching (April 2026 audit) ──

View file

@ -144,6 +144,18 @@ class TestGatewayPersonalityNone:
assert "none" in result.lower() assert "none" in result.lower()
@pytest.mark.asyncio
async def test_empty_personality_list_uses_profile_display_path(self, tmp_path):
runner = self._make_runner(personalities={})
(tmp_path / "config.yaml").write_text(yaml.dump({"agent": {"personalities": {}}}))
with patch("gateway.run._hermes_home", tmp_path), \
patch("hermes_constants.display_hermes_home", return_value="~/.hermes/profiles/coder"):
event = self._make_event("")
result = await runner._handle_personality_command(event)
assert result == "No personalities configured in `~/.hermes/profiles/coder/config.yaml`"
class TestPersonalityDictFormat: class TestPersonalityDictFormat:
"""Test dict-format custom personalities with description, tone, style.""" """Test dict-format custom personalities with description, tone, style."""

View file

@ -283,6 +283,19 @@ class TestBuildSessionContextPrompt:
assert "Local" in prompt assert "Local" in prompt
assert "machine running this agent" in prompt assert "machine running this agent" in prompt
def test_local_delivery_path_uses_display_hermes_home(self):
config = GatewayConfig()
source = SessionSource(
platform=Platform.LOCAL, chat_id="cli",
chat_name="CLI terminal", chat_type="dm",
)
ctx = build_session_context(source, config)
with patch("hermes_constants.display_hermes_home", return_value="~/.hermes/profiles/coder"):
prompt = build_session_context_prompt(ctx)
assert "~/.hermes/profiles/coder/cron/output/" in prompt
def test_whatsapp_prompt(self): def test_whatsapp_prompt(self):
config = GatewayConfig( config = GatewayConfig(
platforms={ platforms={