mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 19:32:45 +03:00
e1a10b0bc2
Main made the strict ruff config the default (`ruff check .`, blocking), and
the branch's code carried 278 findings under it (main itself is clean). Fixed:
- PLW1510 (86): `check=False` on each subprocess.run, preserving behaviour,
as main's own sweep (0006a5e229) did.
- ASYNC220 (9, test fixtures only): `noqa` with the reason, main's convention
for a Popen that returns at once and whose handle the test drives.
- ruff's safe autofixes plus the narrow unsafe ones (UP006/UP037/RUF100/RUF013/
PLR0402/RUF059 underscore renames/UP031/UP041/UP017/FURB167/PIE807/RUF007/
RUF015/RUF022/FURB162), and by hand: four %-formats to f-strings, three
unused unpacked names, one fixture loop over `.items()`.
No behaviour change. `ruff check .` passes; scripts/check passes; the 412 test
files mirroring every edited file pass (3 tests/pm files that fail only under
that batch's uv lookup pass solo, before and after this commit).
58 lines
2.7 KiB
Python
58 lines
2.7 KiB
Python
"""Launch metadata reads cannot create or migrate canonical storage."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize("populated", [False, True])
|
|
def test_resume_and_exit_read_without_writing(tmp_path, populated):
|
|
repo = Path(__file__).resolve().parents[2]
|
|
home = tmp_path / "profile"
|
|
home.mkdir()
|
|
env = {k: os.environ[k] for k in ("PATH", "SYSTEMROOT", "LANG", "TZ") if k in os.environ}
|
|
env.update(HOME=str(tmp_path), USERPROFILE=str(tmp_path), HERMES_HOME=str(home), PYTHONPATH=str(repo))
|
|
code = '''
|
|
from pathlib import Path
|
|
from hermes_state import SessionDB
|
|
from hermes_cli.main import _resolve_last_session, _resolve_session_by_name_or_id
|
|
from hermes_cli.main_tui_launch import _print_tui_exit_summary
|
|
import os
|
|
path = Path(os.environ['HERMES_HOME']) / 'state.db'
|
|
populated = POPULATED
|
|
if populated:
|
|
with SessionDB(db_path=path) as db:
|
|
db.create_session('reader-fixture', source='tui')
|
|
db.append_message('reader-fixture', role='user', content='hello')
|
|
db.set_session_title('reader-fixture', 'Reader fixture')
|
|
before = path.read_bytes() if path.exists() else None
|
|
from hermes_cli.terminal_breadcrumbs import write_breadcrumb, resolve_breadcrumb_session
|
|
os.environ['TMUX_PANE'] = 'reader-fixture'
|
|
write_breadcrumb('reader-fixture')
|
|
assert resolve_breadcrumb_session() == ('reader-fixture' if populated else None)
|
|
assert _resolve_last_session(source='tui') == ('reader-fixture' if populated else None)
|
|
assert _resolve_session_by_name_or_id('reader-fixture') == ('reader-fixture' if populated else None)
|
|
_print_tui_exit_summary('reader-fixture')
|
|
from hermes_cli.main_agent_cmds import cmd_insights
|
|
from types import SimpleNamespace
|
|
cmd_insights(SimpleNamespace(days=30, source='tui'))
|
|
from hermes_cli.cli_info_mixin import CLIInfoMixin
|
|
CLIInfoMixin._show_insights(object(), '/insights --days 30 --source tui')
|
|
after = path.read_bytes() if path.exists() else None
|
|
assert after == before, 'launch reader created or mutated state.db'
|
|
'''.replace('POPULATED', repr(populated))
|
|
result = subprocess.run([sys.executable, "-c", code], cwd=repo, env=env,
|
|
stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=30, check=False)
|
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
assert 'Error generating insights:' not in result.stdout
|
|
if populated:
|
|
assert 'Hermes Insights' in result.stdout
|
|
assert 'Resume this session with:' in result.stdout
|
|
assert 'Reader fixture' in result.stdout
|
|
else:
|
|
# No store yet: both entry points print main's localized empty notice and create nothing.
|
|
assert result.stdout.count('No session data yet.') == 2
|