Description
The glob tool does not traverse into git submodule directories. When a repository contains git submodules (e.g., .opencode/ as a submodule, or any dependency vendored as a submodule), glob("**/*.md") or similar patterns return zero results from within submodule directories. This makes the glob tool harmful for AI agent use in repos with submodules or subrepos — the agent receives an incomplete file listing and makes incorrect assumptions about the codebase.
Root Cause
The glob tool uses ripgrep under the hood (packages/core/src/ripgrep.ts). The glob() method invokes ripgrep with:
rg --no-config --files --glob=<pattern> --glob=!**/.git/** .
ripgrep by default respects .gitignore patterns. The --no-config flag only disables .ripgreprc config files — it does NOT disable .gitignore respect. There is no --no-ignore or --no-ignore-local flag in the invocation.
This causes two problems for submodules:
-
Submodule paths in parent .gitignore: Many projects list submodule paths in the parent repo's .gitignore (e.g., .opencode/ is commonly gitignored when it's a submodule). ripgrep respects this and skips the entire directory.
-
Submodule's own .gitignore: Even if the submodule directory is not in the parent .gitignore, the submodule has its own .gitignore that ripgrep respects, potentially excluding files the agent needs to find.
The --glob=!**/.git/** exclusion also interacts poorly with submodules — submodules have a .git file (not directory) pointing to the parent's .git/modules/<name>, but the submodule's actual content directories are legitimate files the agent needs to discover.
Steps to reproduce
-
Create a repo with a git submodule:
mkdir /tmp/submod-test && cd /tmp/submod-test
git init
git submodule add https://github.com/example/some-submodule vendor/sub
echo "*.md" > vendor/sub/.gitignore
-
Create a markdown file in the submodule:
echo "# Readme" > vendor/sub/README.md
-
Run glob from the parent repo:
-
Observe: vendor/sub/README.md is NOT returned, even though it exists on disk.
Expected behavior
The glob tool should traverse into git submodule directories and return files within them, since those files are part of the working tree and relevant to AI agent codebase analysis.
Suggested fix
Add --no-ignore (or --no-ignore-local) to the ripgrep invocation in packages/core/src/ripgrep.ts for the glob() method. This makes ripgrep ignore .gitignore rules and report all files on disk. The --glob=!**/.git/** exclusion already prevents .git internals from being listed.
Alternatively, add --no-ignore-parent to prevent parent .gitignore from blocking submodule traversal while still respecting the submodule's own .gitignore.
Environment
- OpenCode: any version using ripgrep-based glob
- OS: all
- Terminal: all
Related
Description
The
globtool does not traverse into git submodule directories. When a repository contains git submodules (e.g.,.opencode/as a submodule, or any dependency vendored as a submodule),glob("**/*.md")or similar patterns return zero results from within submodule directories. This makes the glob tool harmful for AI agent use in repos with submodules or subrepos — the agent receives an incomplete file listing and makes incorrect assumptions about the codebase.Root Cause
The glob tool uses ripgrep under the hood (
packages/core/src/ripgrep.ts). Theglob()method invokes ripgrep with:ripgrep by default respects
.gitignorepatterns. The--no-configflag only disables.ripgreprcconfig files — it does NOT disable.gitignorerespect. There is no--no-ignoreor--no-ignore-localflag in the invocation.This causes two problems for submodules:
Submodule paths in parent
.gitignore: Many projects list submodule paths in the parent repo's.gitignore(e.g.,.opencode/is commonly gitignored when it's a submodule). ripgrep respects this and skips the entire directory.Submodule's own
.gitignore: Even if the submodule directory is not in the parent.gitignore, the submodule has its own.gitignorethat ripgrep respects, potentially excluding files the agent needs to find.The
--glob=!**/.git/**exclusion also interacts poorly with submodules — submodules have a.gitfile (not directory) pointing to the parent's.git/modules/<name>, but the submodule's actual content directories are legitimate files the agent needs to discover.Steps to reproduce
Create a repo with a git submodule:
Create a markdown file in the submodule:
Run glob from the parent repo:
Observe:
vendor/sub/README.mdis NOT returned, even though it exists on disk.Expected behavior
The glob tool should traverse into git submodule directories and return files within them, since those files are part of the working tree and relevant to AI agent codebase analysis.
Suggested fix
Add
--no-ignore(or--no-ignore-local) to the ripgrep invocation inpackages/core/src/ripgrep.tsfor theglob()method. This makes ripgrep ignore.gitignorerules and report all files on disk. The--glob=!**/.git/**exclusion already prevents.gitinternals from being listed.Alternatively, add
--no-ignore-parentto prevent parent.gitignorefrom blocking submodule traversal while still respecting the submodule's own.gitignore.Environment
Related