Skip to content

fix(cli): report unsupported-language projects instead of finishing silently (#1502) - #1605

Open
maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/1502-inactive-workspace
Open

fix(cli): report unsupported-language projects instead of finishing silently (#1502)#1605
maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/1502-inactive-workspace

Conversation

@maxmilian

Copy link
Copy Markdown
Contributor

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 filesDiscovered is 0; the reconciliation in src/index.ts:704-724 computes discovered - accounted = 0, finds no shortfall, and records index_state: complete; and the CLI prints the same No files found to index it 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/index now ends with:

▲  No supported source files found — 3 file(s) present, none in a language CodeGraph indexes: .move (2), .pl (1)
●  CodeGraph is inactive for this workspace — searches will return nothing. Use your own file tools here.

instead of No files found to index.

What I deliberately did not change

index_state keeps its existing values. Adding an inactive or empty state would change the getIndexState() union and the status --json contract, 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:3354 returns the same No relevant code found for "<query>" string whether the index is empty-because-unsupported or simply has no match, and src/mcp/session.ts:251 picks 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_INDEX from #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-files then 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 init in a directory holding a.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_state still said complete, the exit code was still 0, and MCP had nothing at all.

…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>
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.

init silently reports success on an unsupported-language project (0 files, index_state: complete)

1 participant