Blacklist image/binary files from list_vault by default

Excludes .webp, .png, .jpg, .gif, .svg, .pdf, .mp4, .mp3, .mov,
.excalidraw, .bmp, .ico, .tiff, .heic, .avif — the model can't
read these anyway and they were the remaining bulk of the 53K
payload after the .obsidian purge.

New exclude_extensions param with sensible default blacklist.
Pass exclude_extensions=[] to see everything.
This commit is contained in:
helm 2026-07-07 02:52:02 -04:00
parent 517a79deea
commit 5c0ee23350

View file

@ -41,6 +41,9 @@ def resolve_vaults_root(cli_arg: str | None = None) -> Path:
VAULTS_ROOT: Path = Path(".") # set on startup
OBSIDIAN_HIDDEN = {".obsidian", ".trash", ".git", ".DS_Store", "node_modules"}
MARKDOWN_EXT = {".md", ".markdown"}
DEFAULT_EXCLUDE_EXT = {".webp", ".png", ".jpg", ".jpeg", ".gif", ".svg",
".pdf", ".mp4", ".mp3", ".mov", ".excalidraw", ".bmp",
".ico", ".tiff", ".heic", ".avif"}
# ── Helpers ───────────────────────────────────────────────────────────────
@ -187,14 +190,17 @@ def list_vault(
recursive: bool = False,
include_files: bool = True,
include_directories: bool = True,
file_extensions: list[str] | None = None,
file_extensions: list[str] | None = None, # None = all; pass ['.md'] for notes only
exclude_extensions: list[str] | None = None, # None = default image blacklist (see below)
include_hidden: bool = False,
) -> dict[str, Any]:
"""FILESYSTEM TOOL (not memory) — Index files and folders in vault on disk. Use to see structure before reading docs.
Returns a lean listing (name + path + type only). Use get_file_info for
size/date/counts on a specific file. Hidden dirs (.obsidian, .git, .trash)
are excluded by default.
Returns a lean listing (name + path + type only). Image/binary files (.webp,
.png, .jpg, .gif, .svg, .pdf, .mp4, .mp3, .mov, .excalidraw) are excluded by
default the model can't read them anyway. Pass exclude_extensions=[] to see
everything. Use get_file_info for size/date/counts on a specific file.
Hidden dirs are excluded by default.
Args:
vault_name: Name of the vault (subdirectory name under vaults root)
@ -204,14 +210,18 @@ def list_vault(
recursive: If True, list all nested contents recursively.
include_files: Include files in results (default True).
include_directories: Include directories in results (default True).
file_extensions: Optional filter only return files with these extensions
(e.g. ['.md', '.canvas']). Case-insensitive.
file_extensions: Filter files by extension. Pass ['.md'] for notes only,
['.md', '.canvas'] for notes + canvases, or omit/None for all files.
exclude_extensions: Extensions to EXCLUDE. Defaults to binary/image types
(webp, png, jpg, gif, svg, pdf, mp4, mp3, mov, excalidraw).
Pass [] to disable the blacklist.
include_hidden: If True, include .obsidian config directory (default False).
Usage:
list_vault("obsidian-skt") root index
list_vault("obsidian-skt", "", True) recursive index
list_vault("obsidian-skt", "NPCs") subfolder
list_vault("obsidian-skt") all files (images excluded) at root
list_vault("obsidian-skt", file_extensions=['.md']) notes only
list_vault("obsidian-skt", "", True, file_extensions=['.md']) all notes recursively
list_vault("obsidian-skt", exclude_extensions=[]) everything including images
Returns:
directories: [{name, path, type}]
@ -229,6 +239,12 @@ def list_vault(
if not target.exists():
return {"error": f"Path not found: {path or '/'}", "vault": vault_name}
# Resolve exclude list: explicit arg > default image blacklist
if exclude_extensions is None:
exclude_set = DEFAULT_EXCLUDE_EXT
else:
exclude_set = {e.lower() for e in exclude_extensions}
directories = []
files = []
@ -256,6 +272,8 @@ def list_vault(
ext_lower = entry.suffix.lower()
if not any(ext_lower == fe.lower() for fe in file_extensions):
continue
if entry.suffix.lower() in exclude_set:
continue
files.append(info)
return {