@@ -308,8 +308,9 @@ class TestDataDirHelpers:
308308 """Module-level helpers that resolve the Basic Memory data directory."""
309309
310310 def test_resolve_data_dir_defaults_to_home_dot_basic_memory (self , config_home , monkeypatch ):
311- """Without BASIC_MEMORY_CONFIG_DIR, resolver returns ~/.basic-memory."""
311+ """Without BASIC_MEMORY_CONFIG_DIR and XDG_CONFIG_HOME , resolver returns ~/.basic-memory."""
312312 monkeypatch .delenv ("BASIC_MEMORY_CONFIG_DIR" , raising = False )
313+ monkeypatch .delenv ("XDG_CONFIG_HOME" , raising = False )
313314
314315 assert resolve_data_dir () == config_home / ".basic-memory"
315316
@@ -320,6 +321,23 @@ def test_resolve_data_dir_honors_config_dir_env(self, tmp_path, monkeypatch):
320321
321322 assert resolve_data_dir () == custom
322323
324+ def test_resolve_data_dir_honors_xdg_config_home (self , tmp_path , monkeypatch ):
325+ """XDG_CONFIG_HOME is honored when BASIC_MEMORY_CONFIG_DIR is not set."""
326+ monkeypatch .delenv ("BASIC_MEMORY_CONFIG_DIR" , raising = False )
327+ xdg_config = tmp_path / "xdg-config"
328+ monkeypatch .setenv ("XDG_CONFIG_HOME" , str (xdg_config ))
329+
330+ assert resolve_data_dir () == xdg_config / "basic-memory"
331+
332+ def test_basic_memory_config_dir_takes_precedence_over_xdg (self , tmp_path , monkeypatch ):
333+ """BASIC_MEMORY_CONFIG_DIR takes precedence over XDG_CONFIG_HOME."""
334+ xdg_config = tmp_path / "xdg-config"
335+ custom = tmp_path / "custom-config"
336+ monkeypatch .setenv ("XDG_CONFIG_HOME" , str (xdg_config ))
337+ monkeypatch .setenv ("BASIC_MEMORY_CONFIG_DIR" , str (custom ))
338+
339+ assert resolve_data_dir () == custom
340+
323341 def test_default_fastembed_cache_dir_uses_data_dir (self , config_home , monkeypatch ):
324342 """Default cache path is a subdir of the Basic Memory data dir."""
325343 monkeypatch .delenv ("BASIC_MEMORY_CONFIG_DIR" , raising = False )
0 commit comments