Skip to content

fix: minor cleanup fixes for new tools - #8

Merged
peteretelej merged 4 commits into
mainfrom
fix/api-clarity
Mar 6, 2026
Merged

fix: minor cleanup fixes for new tools#8
peteretelej merged 4 commits into
mainfrom
fix/api-clarity

Conversation

@peteretelej

@peteretelej peteretelej commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added directory listing functionality with configurable recursion depth, maximum entry limits, and hidden file control.
  • Improvements

    • Enhanced search with file-level pattern filtering and hidden file inclusion options.
    • Improved error handling and resilience for file access issues and inaccessible files.
    • Better Java file structure detection with expanded language support.

Only skip entries matching ignored_dir_patterns when they are actually
directories, surface PermissionError at root depth instead of returning
silent empty results, and narrow an overly broad except clause in
search_directory to catch only FileAccessError.

- Added minimum: 1 to max_depth and max_entries in the list_directory
  JSON schema
Corrected the "Java-specific nodes" comment to include TypeScript, replaced low-signal Java search hints (void, public, private) with structural tokens (enum, import, @interface), and removed a dead _make_tree helper from list_directory tests.
Added the missing list_directory detailed section to API.md. Fixed
several inaccuracies in search_directory docs: `directory` key renamed
to `path`, added `include_pattern` to return keys, removed non-existent
`match_count` from per-file results.

- Fixed double-pipe typo in API.md overview table
- Added trailing newline to configuration.md
@codecov

codecov Bot commented Mar 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.03%. Comparing base (8f30b39) to head (af90bfe).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   89.02%   89.03%   +0.01%     
==========================================
  Files          12       12              
  Lines        1476     1478       +2     
==========================================
+ Hits         1314     1316       +2     
  Misses        162      162              
Files with missing lines Coverage Δ
src/mcp_schemas.py 34.48% <ø> (ø)
src/tools.py 97.91% <100.00%> (+0.01%) ⬆️
src/tree_parser.py 86.71% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@peteretelej

Copy link
Copy Markdown
Owner Author

@coderabbitai you asleep?

@coderabbitai

coderabbitai Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

@peteretelej: Never! Wide awake and ready to review! 🐇 Let me take a look at your PR right away!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR introduces documentation for a new list_directory API function with depth and entry filtering, updates search_directory signature with glob-pattern and hidden-file controls, refines ignore-pattern logic to affect directories only, improves error handling for top-level permission issues, and expands test coverage for edge cases. Version bumped from 0.1.5 to 0.1.6.

Changes

Cohort / File(s) Summary
API Documentation
docs/API.md, docs/configuration.md
Added list_directory public API with max_depth, max_entries, and include_hidden parameters; updated search_directory signature to include include_pattern and include_hidden; documented revised return value structure with path and len-based match counting.
Schema & Tools Implementation
src/mcp_schemas.py, src/tools.py
Added minimum constraints (value 1) for max_depth and max_entries schema fields; refined ignore-pattern filtering to skip directories only (not files with matching names); improved FileAccessError handling for root-level permission issues; updated Java file analysis hints to include enum, import, and @interface markers.
Code Comments
src/tree_parser.py
Updated inline comment documentation to reflect Java and TypeScript declaration nodes instead of Java-specific nodes.
Test Coverage
tests/unit/test_tools_list_directory.py, tests/unit/test_tools_search_directory.py
Expanded test coverage for ignored-pattern naming interactions; updated error handling tests to verify PermissionError returns error dict with message; changed mocked exception type from OSError to FileAccessError in search tests; removed internal helper and added child_count validation tests.
Version Bump
pyproject.toml
Incremented project version from 0.1.5 to 0.1.6.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through directories deep,
Where hidden files and patterns sleep,
Permission walls now clearly caught,
Depths and limits finely wrought,
The search continues, errors tame,
Version bump—a gentler name! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: minor cleanup fixes for new tools' accurately describes the primary changes: multiple targeted bug fixes and refinements across documentation, error handling, and testing.
Docstring Coverage ✅ Passed Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/api-clarity

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unit/test_tools_list_directory.py (1)

309-313: Make nested PermissionError injection path-based instead of call-order-based.

Using call_count["n"] == 3 is fragile and can break with harmless internal traversal changes.

♻️ Suggested deterministic test tweak
-        call_count = {"n": 0}
-
         def patched_scandir(path: str) -> object:
-            call_count["n"] += 1
-            if call_count["n"] == 3:  # third call: recursing into restricted/
+            if Path(path).name == "restricted":
                 raise PermissionError("access denied")
             return real_scandir(path)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/test_tools_list_directory.py` around lines 309 - 313, The
patched_scandir stub currently raises PermissionError based on call_count["n"]
== 3 which is brittle; change it to inspect the incoming path instead (e.g.,
check Path(path).name or whether "restricted" is in the path) and raise
PermissionError only when the stub is asked to list that nested restricted
directory, while still delegating to real_scandir(path) for other paths and
optionally incrementing call_count for diagnostics. Locate the patched_scandir
definition and replace the call-order condition with a deterministic path-based
check (referencing patched_scandir, call_count, and real_scandir).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/API.md`:
- Line 415: Update the sentence to explicitly state that the ignore patterns
(LARGEFILE_IGNORED_DIR_PATTERNS) apply only to directory names (not files);
reword the line about ignored defaults to something like “__pycache__,
node_modules, and .git are ignored by default from directory traversal
(configurable via LARGEFILE_IGNORED_DIR_PATTERNS)” to match runtime behavior
where the code only skips names after confirming they are directories (the check
uses Path.is_dir / is_dir logic in the traversal implementation).

---

Nitpick comments:
In `@tests/unit/test_tools_list_directory.py`:
- Around line 309-313: The patched_scandir stub currently raises PermissionError
based on call_count["n"] == 3 which is brittle; change it to inspect the
incoming path instead (e.g., check Path(path).name or whether "restricted" is in
the path) and raise PermissionError only when the stub is asked to list that
nested restricted directory, while still delegating to real_scandir(path) for
other paths and optionally incrementing call_count for diagnostics. Locate the
patched_scandir definition and replace the call-order condition with a
deterministic path-based check (referencing patched_scandir, call_count, and
real_scandir).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21356dab-eee8-4ae6-aa55-591c2af03b04

📥 Commits

Reviewing files that changed from the base of the PR and between 8f30b39 and af90bfe.

📒 Files selected for processing (8)
  • docs/API.md
  • docs/configuration.md
  • pyproject.toml
  • src/mcp_schemas.py
  • src/tools.py
  • src/tree_parser.py
  • tests/unit/test_tools_list_directory.py
  • tests/unit/test_tools_search_directory.py

Comment thread docs/API.md
@peteretelej
peteretelej merged commit 2ebd7a5 into main Mar 6, 2026
6 checks passed
@peteretelej
peteretelej deleted the fix/api-clarity branch March 6, 2026 10:26
@coderabbitai coderabbitai Bot mentioned this pull request Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant