Skip to content

Spoken permission text never says "a note in your vault" on Windows: the in_vault check compares a forward-slash path to a backslash extra_dirs entry #26

Description

@techmik

The spoken permission ask is meant to describe a vault edit in plain words ("I want to edit a note in your vault called Recipes"). On Windows it never does; every vault edit is spoken as "edit a file called Recipes.md". The gate still fires, so this is the plain-words layer failing, not a bypass, but the plain-words layer is the whole point of that design.

Observed on: 84b3a6c, Windows 11, Python 3.12.10, extra_dirs set to a vault path with backslashes (C:\Users\...\MyJarvisVault).

What happens

_human_what() in backtalk/main.py normalises the tool's file path to forward slashes at line 153-154, then at line 159 tests it against each extra_dirs entry with path.startswith(str(h).rstrip("/") + "/"). The entries are never normalised, so on Windows h still holds backslashes, the prefix never matches, and in_vault is always False. The name.endswith(".md") branch at line 162 is unreachable on this platform.

Reproduction

from backtalk.main import _human_what
print(_human_what("Edit", {"file_path": r"C:\Users\me\MyVault\Recipes.md"}, None))
# with extra_dirs = ["C:\\Users\\me\\MyVault"] in backtalk.json:
#   actual:   edit a file called Recipes.md
#   expected: edit a note in your vault called Recipes

Writing the entry with forward slashes in the JSON ("C:/Users/me/MyVault") happens to work, because it then matches the normalised path; the backslash form, which is what every Windows tool hands you, does not. config._expand() only expands ~ and does not normalise separators, so the config layer does not save it either.

Fix

Normalise the entry the same way the path was normalised, one line at main.py:159:

in_vault = any(h and path.startswith(str(h).replace("\\", "/").rstrip("/") + "/")
               for h in (CFG.get("extra_dirs") or []))

Checked here: with that change the same call returns the vault wording. Two small cleanups in the same function if you want them while you are there: homes (line 157-158) is built and never used, and import os as _os (line 156) is unused.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions