Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/session-start-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ REMEMBER_NOW="$REMEMBER_DIR/now.md"
REMEMBER_TODAY_FILE="$REMEMBER_DIR/today-${TODAY}.md"

# ── Handoff path hint (consumed by the /remember skill) ───────────────────
# Emitted unconditionally so the skill always knows the correct write target.
echo "=== HANDOFF ==="
echo "Write next handoff to: $REMEMBER_HANDOFF"
echo ""
# Emitted only in external mode. In legacy mode REMEMBER_HANDOFF resolves to
# {project}/.remember/remember.md — the exact path the skill defaults to when
# no === HANDOFF === block is present, so the hint would be pure noise.
if [ "$REMEMBER_ROOT" != "$PROJECT_DIR" ]; then
echo "=== HANDOFF ==="
echo "Write next handoff to: $REMEMBER_HANDOFF"
echo ""
fi

# ── Last handoff (injected FIRST so it survives context-preview truncation) ─
# The session-start output can be large; the harness may deliver only a leading
Expand Down
36 changes: 36 additions & 0 deletions tests/test_external_data_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,42 @@ def test_session_start_emits_handoff_block(self, tmp_path):
f"handoff path does not reference external base.\noutput: {output}\nstderr: {result.stderr[:300]}"
)

def test_session_start_suppresses_handoff_block_in_legacy_mode(self, tmp_path):
"""In legacy mode the === HANDOFF === hint is noise — the /remember skill
falls back to {project}/.remember/remember.md, the exact path the hint
would carry. Suppress it. The === LAST HANDOFF === block (file-gated) is
unaffected and not asserted here.
"""
project = tmp_path / "proj"
project.mkdir()
home = tmp_path / "home"
(home / ".remember").mkdir(parents=True)

# Legacy mode: relative data_dir resolves to {project}/.remember,
# so REMEMBER_ROOT == PROJECT_DIR.
(home / ".remember" / "config.json").write_text(
json.dumps({"data_dir": ".remember", "features": {"recovery": False}})
)

slug = _slug(str(project))
sessions_dir = home / ".claude" / "projects" / slug
sessions_dir.mkdir(parents=True)

env = {
**os.environ,
"CLAUDE_PROJECT_DIR": str(project),
"CLAUDE_PLUGIN_ROOT": str(REPO_ROOT),
"HOME": str(home),
}
result = subprocess.run(
["bash", str(SESSION_START_SCRIPT)], env=env, capture_output=True, text=True
)
output = result.stdout

assert "=== HANDOFF ===" not in output, (
f"=== HANDOFF === hint should be suppressed in legacy mode.\noutput: {output}\nstderr: {result.stderr[:300]}"
)


class TestIdentityFallback:

Expand Down
Loading