Skip to content

Commit 8837c4d

Browse files
jpheinclaude
andcommitted
style: ruff format hooks_cli.py — blank lines, line wrapping
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f52e922 commit 8837c4d

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

mempalace/hooks_cli.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def _mempalace_python() -> str:
4343
return str(project_venv)
4444
return sys.executable
4545

46+
4647
_RECENT_MSG_COUNT = 30 # how many recent user messages to summarize
4748

4849
STOP_BLOCK_REASON = (
@@ -287,6 +288,7 @@ def _extract_themes(messages: list[str], max_themes: int = 3) -> list[str]:
287288
Note: stopword list is English-only; non-English corpora will produce noisy themes.
288289
"""
289290
from collections import Counter
291+
290292
words: Counter[str] = Counter()
291293
for msg in messages:
292294
for word in msg.lower().split():
@@ -298,7 +300,9 @@ def _extract_themes(messages: list[str], max_themes: int = 3) -> list[str]:
298300

299301

300302
def _save_diary_direct(
301-
transcript_path: str, session_id: str, toast: bool = False,
303+
transcript_path: str,
304+
session_id: str,
305+
toast: bool = False,
302306
) -> dict:
303307
"""Write a diary checkpoint by calling the tool function directly (no MCP roundtrip).
304308
@@ -321,6 +325,7 @@ def _save_diary_direct(
321325

322326
try:
323327
from .mcp_server import tool_diary_write
328+
324329
result = tool_diary_write(
325330
agent_name="session-hook",
326331
entry=entry,
@@ -366,9 +371,15 @@ def _ingest_transcript(transcript_path: str):
366371
with open(log_path, "a") as log_f:
367372
subprocess.Popen(
368373
[
369-
_mempalace_python(), "-m", "mempalace", "mine",
370-
str(path.parent), "--mode", "convos",
371-
"--wing", "sessions",
374+
_mempalace_python(),
375+
"-m",
376+
"mempalace",
377+
"mine",
378+
str(path.parent),
379+
"--mode",
380+
"convos",
381+
"--wing",
382+
"sessions",
372383
],
373384
stdout=log_f,
374385
stderr=log_f,
@@ -427,6 +438,7 @@ def hook_stop(data: dict, harness: str):
427438

428439
# Read hook settings from config
429440
from .config import MempalaceConfig
441+
430442
try:
431443
config = MempalaceConfig()
432444
silent = config.hook_silent_save
@@ -454,9 +466,11 @@ def hook_stop(data: dict, harness: str):
454466
tag = " \u2014 " + ", ".join(themes)
455467
else:
456468
tag = ""
457-
_output({
458-
"systemMessage": f"\u2726 {count} memories woven into the palace{tag}",
459-
})
469+
_output(
470+
{
471+
"systemMessage": f"\u2726 {count} memories woven into the palace{tag}",
472+
}
473+
)
460474
else:
461475
_output({})
462476
else:

tests/test_hooks_cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import pytest
1010

1111
from mempalace.hooks_cli import (
12-
PRECOMPACT_BLOCK_REASON,
1312
SAVE_INTERVAL,
14-
STOP_BLOCK_REASON,
1513
_count_human_messages,
1614
_extract_recent_messages,
1715
_get_mine_dir,

0 commit comments

Comments
 (0)