fix(cli): report unsupported-language projects instead of finishing silently (#1502) - #1605
Open
maxmilian wants to merge 1 commit into
Open
fix(cli): report unsupported-language projects instead of finishing silently (#1502)#1605maxmilian wants to merge 1 commit into
maxmilian wants to merge 1 commit into
Conversation
…ilently A project CodeGraph has no grammar for was indistinguishable from an empty one: unsupported extensions are filtered out at discovery, so filesDiscovered was 0, the reconciliation in index.ts found no shortfall and recorded index_state as complete, and the CLI printed the same 'No files found to index' it prints for an empty repo. That silence is what makes it costly over MCP: an empty result reads identically to 'no match', and the agent has been told to trust the graph rather than grep. The scan already visits every file, so the tally of what it declined to index costs no extra I/O and no second pass. index_state itself is left alone: changing its values would change the status --json contract, which is a call for the maintainer to make. Co-authored-by: netbrah <netbrah@users.noreply.github.com>
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.
Fixes #1502.
A project written in a language CodeGraph has no grammar for is currently indistinguishable from an empty one. Unsupported extensions are filtered out during discovery, so
filesDiscoveredis 0; the reconciliation insrc/index.ts:704-724computesdiscovered - accounted = 0, finds no shortfall, and recordsindex_state: complete; and the CLI prints the sameNo files found to indexit prints for a genuinely empty repo. Exit 0 throughout.That reconciliation already carries the right intent in its own comment — "don't let the index pass as complete" — it just can't see this case, because its denominator is files it recognised.
The silence is worst over MCP, where an empty result is byte-identical to "no match" and the agent has been told to trust the graph rather than grep. @netbrah's follow-up is the sharp version: 24k Perl files, every one classified
unknown, and nothing anywhere saying so.What changed
The scan already walks every file, so the tally of what it declined to index rides along on the walk it was doing anyway — no second pass, no extra I/O. That matters at 24k files.
init/indexnow ends with:instead of
No files found to index.What I deliberately did not change
index_statekeeps its existing values. Adding aninactiveoremptystate would change thegetIndexState()union and thestatus --jsoncontract, and would ripple into the CLI's warn branches. That's a call for you to make, not something to slip into a bug fix — so this reports the condition without redefining the state.MCP is left for a follow-up.
src/mcp/tools.ts:3354returns the sameNo relevant code found for "<query>"string whether the index is empty-because-unsupported or simply has no match, andsrc/mcp/session.ts:251picks instructions on whether.codegraph/exists, so a 0-file index still receives the full "trust codegraph, don't grep" playbook. The vocabulary for this already exists —SERVER_INSTRUCTIONS_NO_ROOT_INDEXfrom #769 says almost exactly the right thing — so the fix is likely to point that judgement at "indexed but empty" as well as "not indexed". I'd rather land the CLI half and hear how you want the MCP half worded than guess at instruction text, since that file is the SSOT for it.Testing
Three cases in
__tests__/extraction.test.ts, covering both discovery paths, because they filter in different places: the git path (git ls-filesthen extension filter) and the filesystem-walk fallback. The third asserts the tally stays empty when everything was indexable, so the counter can't silently fire on healthy projects.Verified end to end on a real run rather than only in unit tests — the block above is the actual output of
codegraph initin a directory holdinga.move,b.move,c.pl.Full suite is 3011 passed / 0 failed on Node 22.
One small correction to the report, since it's the kind of thing that wastes a reviewer's time: the CLI was not entirely silent — it did print
No files found to index. The substantive part of the complaint stands, though: that message is the empty-repo message,index_statestill saidcomplete, the exit code was still 0, and MCP had nothing at all.