feat: seed a default global SOUL.md

Seed ~/.hermes/SOUL.md when missing, load SOUL only from HERMES_HOME, and inject raw SOUL content without wrapper text. If the file exists but is empty, nothing is added to the system prompt.
This commit is contained in:
teknium1
2026-03-14 08:05:30 -07:00
parent 67e80def53
commit 906e25f299
5 changed files with 141 additions and 24 deletions

View File

@@ -349,14 +349,15 @@ class TestBuildSkillsSystemPrompt:
class TestBuildContextFilesPrompt:
def test_empty_dir_returns_empty(self, tmp_path):
def test_empty_dir_loads_seeded_global_soul(self, tmp_path):
from unittest.mock import patch
fake_home = tmp_path / "fake_home"
fake_home.mkdir()
with patch("pathlib.Path.home", return_value=fake_home):
result = build_context_files_prompt(cwd=str(tmp_path))
assert result == ""
assert "Project Context" in result
assert "# Hermes ☤" in result
def test_loads_agents_md(self, tmp_path):
(tmp_path / "AGENTS.md").write_text("Use Ruff for linting.")
@@ -369,11 +370,33 @@ class TestBuildContextFilesPrompt:
result = build_context_files_prompt(cwd=str(tmp_path))
assert "type hints" in result
def test_loads_soul_md(self, tmp_path):
(tmp_path / "SOUL.md").write_text("Be concise and friendly.")
def test_loads_soul_md_from_hermes_home_only(self, tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hermes_home"))
hermes_home = tmp_path / "hermes_home"
hermes_home.mkdir()
(hermes_home / "SOUL.md").write_text("Be concise and friendly.", encoding="utf-8")
(tmp_path / "SOUL.md").write_text("cwd soul should be ignored", encoding="utf-8")
result = build_context_files_prompt(cwd=str(tmp_path))
assert "concise and friendly" in result
assert "SOUL.md" in result
assert "Be concise and friendly." in result
assert "cwd soul should be ignored" not in result
def test_soul_md_has_no_wrapper_text(self, tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hermes_home"))
hermes_home = tmp_path / "hermes_home"
hermes_home.mkdir()
(hermes_home / "SOUL.md").write_text("Be concise and friendly.", encoding="utf-8")
result = build_context_files_prompt(cwd=str(tmp_path))
assert "Be concise and friendly." in result
assert "If SOUL.md is present" not in result
assert "## SOUL.md" not in result
def test_empty_soul_md_adds_nothing(self, tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hermes_home"))
hermes_home = tmp_path / "hermes_home"
hermes_home.mkdir()
(hermes_home / "SOUL.md").write_text("\n\n", encoding="utf-8")
result = build_context_files_prompt(cwd=str(tmp_path))
assert result == ""
def test_blocks_injection_in_agents_md(self, tmp_path):
(tmp_path / "AGENTS.md").write_text(