fix: replace macOS-incompatible ls -I with cross-platform find command#56
Open
Ashwinhegde19 wants to merge 1 commit intogemini-cli-extensions:mainfrom
Open
Conversation
The ls -lR -I flag is not supported on macOS/BSD systems, causing setup to scan node_modules and hit token limits. Replace with cross-platform find command that works on all systems. Also added __pycache__ to the exclusion list. Fixes gemini-cli-extensions#11
sherzat3
requested changes
Jan 7, 2026
| 1. **Respect Ignore Files:** Before scanning any files, you MUST check for the existence of `.geminiignore` and `.gitignore` files. If either or both exist, you MUST use their combined patterns to exclude files and directories from your analysis. The patterns in `.geminiignore` should take precedence over `.gitignore` if there are conflicts. This is the primary mechanism for avoiding token-heavy, irrelevant files like `node_modules`. | ||
| 2. **Efficiently List Relevant Files:** To list the files for analysis, you MUST use a command that respects the ignore files. For example, you can use `git ls-files --exclude-standard -co | xargs -n 1 dirname | sort -u` which lists all relevant directories (tracked by Git, plus other non-ignored files) without listing every single file. If Git is not used, you must construct a `find` command that reads the ignore files and prunes the corresponding paths. | ||
| 3. **Fallback to Manual Ignores:** ONLY if neither `.geminiignore` nor `.gitignore` exist, you should fall back to manually ignoring common directories. Example command: `ls -lR -I 'node_modules' -I '.m2' -I 'build' -I 'dist' -I 'bin' -I 'target' -I '.git' -I '.idea' -I '.vscode'`. | ||
| 3. **Fallback to Manual Ignores:** ONLY if neither `.geminiignore` nor `.gitignore` exist, you should fall back to manually ignoring common directories. Example command: `find . -type d \\( -name 'node_modules' -o -name '.m2' -o -name 'build' -o -name 'dist' -o -name 'bin' -o -name 'target' -o -name '.git' -o -name '.idea' -o -name '.vscode' -o -name '__pycache__' \\) -prune -o -type f -print | head -200`. |
Collaborator
There was a problem hiding this comment.
Actually, you should be able to take advantage of shell command templates: !{find . -type ... head -200}
See Gemini CLI docs for more details: https://geminicli.com/docs/cli/custom-commands/#3-executing-shell-commands-with
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix macOS/BSD compatibility in setup command.
Problem
The
ls -lR -I 'node_modules'command fails on macOS/BSD because the-Iflag is not supported. This causesnode_modulesto be scanned, leading to API token limit errors.Solution
Replace with cross-platform
findcommand that works on all systems.Also added
__pycache__to exclusion list.Fixes #11