Skip to content
Open
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
4 changes: 2 additions & 2 deletions hindsight-integrations/claude-code/scripts/lib/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def derive_bank_id(hook_input: dict, config: dict) -> str:
# case-sensitive compare silently misses the map and falls through
# to the default bank. normcase is a no-op on POSIX, preserving
# case-sensitive matching there.
normalized_cwd = os.path.normcase(os.path.normpath(cwd))
normalized_cwd = os.path.normcase(os.path.realpath(cwd))
for dir_path, bank_id in dir_map.items():
if os.path.normcase(os.path.normpath(dir_path)) == normalized_cwd:
if os.path.normcase(os.path.realpath(dir_path)) == normalized_cwd:
return f"{prefix}-{bank_id}" if prefix else bank_id

if not config.get("dynamicBankId", False):
Expand Down
11 changes: 11 additions & 0 deletions hindsight-integrations/claude-code/tests/test_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,14 @@ def test_different_banks_each_set_once(self, state_dir):
ensure_bank_mission(client, "bank-x", cfg)
ensure_bank_mission(client, "bank-y", cfg)
assert client.set_bank_mission.call_count == 2

@pytest.mark.skipif(not hasattr(__import__("os"), "symlink"), reason="symlinks not supported")
def test_directorybankmap_matches_symlinked_cwd(self, tmp_path):
import os
real = os.path.realpath(tmp_path / "proj")
os.makedirs(real)
link = str(tmp_path / "proj-link")
os.symlink(real, link)
cfg = _cfg(directoryBankMap={real: "myproj"}, bankId="fallback")
assert derive_bank_id({"cwd": real, "session_id": "s"}, cfg) == "myproj"
assert derive_bank_id({"cwd": link, "session_id": "s"}, cfg) == "myproj"