Skip to content

Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.

fix(extractor): treat bracketed paths as literals (#162)

Ngo Quoc Viet94125732aa2b
diff --git a/book_to_skill/utils.py b/book_to_skill/utils.py
index cd6e6a2..e750e64 100644
--- a/book_to_skill/utils.py
+++ b/book_to_skill/utils.py
@@ -534,7 +534,9 @@ def resolve_input_files(paths: list[str]) -> list[Path]:
# the file/directory branch below see a real path.
path_str = os.path.expanduser(raw_path)
# Check if it has glob wildcards
- if any(char in path_str for char in ("*", "?", "[")):
+ if not Path(path_str).exists() and any(
+ char in path_str for char in ("*", "?", "[")
+ ):
glob_matches = glob.glob(path_str, recursive=True)
# Sort expanded glob results deterministically
expanded = []
diff --git a/tests/test_book_to_skill.py b/tests/test_book_to_skill.py
index db90eda..739b10f 100644
--- a/tests/test_book_to_skill.py
+++ b/tests/test_book_to_skill.py
@@ -1206,6 +1206,13 @@ class TestDocxExtraction:
class TestResolveInputFiles:
"""Additional edge-case tests for resolve_input_files."""
+ def test_existing_file_with_glob_metacharacters_is_literal(self, tmp_path):
+ target = _make_text_file(tmp_path / "book [2013].pdf")
+
+ result = resolve_input_files([str(target)])
+
+ assert result == [target.resolve()]
+
def test_nonexistent_file_kept_for_error_reporting(self, tmp_path):
"""A nonexistent explicit path is kept so extract_single_file can report it."""
fake = tmp_path / "nonexistent.pdf"