Files
ar9av__obsidian-wiki/tests/test_inline_vault_targeting_docs.py
Arnav 77d74e0261 feat(config): XDG-style config location, with legacy fallback (#172) (#173)
* feat(config): resolve global config from an XDG-style location (#172)

The global config lived at ~/.obsidian-wiki, which isn't XDG-compliant.
It now resolves to $XDG_CONFIG_HOME/obsidian-wiki (default
~/.config/obsidian-wiki).

Existing installs are unaffected: if ~/.obsidian-wiki is present and the
XDG path is not, the legacy directory is used as-is. No migration is
required, and nothing moves on upgrade. Once the XDG path exists it wins,
so `mv ~/.obsidian-wiki ~/.config/obsidian-wiki` is all a migration takes.

Resolution is implemented identically in Python (cli.py), bash (setup.sh,
scripts/daily-update.sh, scripts/wiki-notify.sh), and the Config
Resolution Protocol that every skill defers to, so vault-scoped state and
named `config.<name>` profiles stay in one place.

* fix(config): stop setup from wiping user-added config keys

`write_config` rewrote the global config with only the three setup-managed
keys, so every `obsidian-wiki setup` — including the one a pip upgrade
prompts for — silently destroyed anything else in the file:
OBSIDIAN_LINK_FORMAT, QMD_WIKI_COLLECTION, WIKI_SKIP_PROJECTS, sync
settings, and comments.

Setup now owns only OBSIDIAN_VAULT_PATH, OBSIDIAN_WIKI_REPO and
OBSIDIAN_WIKI_VERSION, updating those in place and carrying every other
line over untouched. Duplicate definitions of a managed key collapse to
one.

Predates the XDG change (same behavior on main) but is fixed here because
this branch already touches config writing, and the XDG work makes
re-running setup more likely.

Also pins PYTHONPATH in both new test files so they exercise this
checkout rather than whatever obsidian_wiki happens to be installed.
2026-08-16 20:40:09 -07:00

74 lines
2.9 KiB
Python

from __future__ import annotations
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[1]
class InlineVaultTargetingDocsTest(unittest.TestCase):
def read(self, relpath: str) -> str:
return (ROOT / relpath).read_text()
def test_central_protocol_documents_inline_override_before_fallbacks(self) -> None:
llm_wiki = self.read(".skills/llm-wiki/SKILL.md")
agents = self.read("AGENTS.md")
self.assertIn("0. **Inline vault override (`@name`)", llm_wiki)
self.assertIn("0. **Inline vault override (`@name`)", agents)
self.assertIn("resolve `<global config dir>/config.<name>` directly", llm_wiki)
self.assertIn("do **not** silently fall back to the default", agents)
def test_skill_resolution_summaries_include_inline_override(self) -> None:
stale = []
for skill_file in sorted((ROOT / ".skills").glob("*/SKILL.md")):
text = skill_file.read_text()
if "follow the Config Resolution Protocol" not in text:
continue
if "walk up CWD for `.env`" in text and "inline `@name` override" not in text:
stale.append(skill_file.relative_to(ROOT).as_posix())
self.assertEqual(stale, [])
def test_agent_bootstrap_files_mention_named_vault_routing(self) -> None:
for relpath in [
"AGENTS.md",
".agent/rules/obsidian-wiki.md",
".cursor/rules/obsidian-wiki.mdc",
".github/copilot-instructions.md",
".kiro/steering/obsidian-wiki.md",
".windsurf/rules/obsidian-wiki.md",
"docs/installation.md",
"SETUP.md",
]:
with self.subTest(relpath=relpath):
self.assertIn("@name", self.read(relpath))
def test_install_docs_say_all_supported_agents_inherit_named_vault_routing(self) -> None:
install = self.read("docs/installation.md")
self.assertIn("All supported agents can use this syntax", install)
self.assertIn("Claude Code, Cursor, Windsurf, Codex, Gemini", install)
def test_core_skill_descriptions_include_named_vault_examples(self) -> None:
examples = {
".skills/wiki-query/SKILL.md": "wiki-query @work",
".skills/wiki-update/SKILL.md": "@work update wiki",
".skills/wiki-capture/SKILL.md": "@research save this",
}
for relpath, expected in examples.items():
with self.subTest(relpath=relpath):
self.assertIn(expected, self.read(relpath))
def test_wiki_query_does_not_prefer_default_over_inline_override(self) -> None:
wiki_query = self.read(".skills/wiki-query/SKILL.md")
self.assertIn("For cross-project queries without `@name`", wiki_query)
self.assertNotIn("Prefer `~/.obsidian-wiki/config` for cross-project queries", wiki_query)
if __name__ == "__main__":
unittest.main()