You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor: Improve file_index structure to prevent KeyError
This commit refactors the internal `file_index` data structure to be more explicit and robust, preventing a `KeyError` crash in the `find_files` tool.
Previously, the `file_index` was inconsistent: file entries were marked with "type": "file", but directory entries were implicitly represented by a plain dictionary, lacking a `type` key. This led to errors in functions like `_get_all_files` that incorrectly assumed the `type` key would always be present.
This has been resolved by:
- Modifying `_index_project` to explicitly add {"type": "directory", "children": {}} for all directory entries.
- Updating the helper functions (`_get_all_files`, `_count_files`) to correctly parse this new, consistent structure.
- Adding backward-compatibility in `set_project_path` to handle old-format index files by gracefully triggering a re-index if loading fails.
This change makes the indexing logic more maintainable and less prone to errors.
Fixes the first part of #10.
0 commit comments