Skip to content

feat(cli): files --json marks test files, with --tests and --no-tests filters - #3124

Merged
colbymchenry merged 1 commit into
mainfrom
claude/pr-1960-files-test-classification
Oct 31, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/pr-1960-files-test-classification

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Summary

codegraph files --json now gives each file isTest, --tests and --no-tests filter the list in any output format, and codegraph node --file (the same view as codegraph_node on a file) says "test file" in its header.

Root cause

Nothing on the CLI told a tool whether a file is a test, so downstream tools kept their own naming rules, which drift from the isTestPath predicate CodeGraph uses itself.

What came from the contributor, and what changed

The change is theirs: the field, the filters and the label, all on isTestPath.

Our changes:

  • Rebased over files --format package (feat(files): list a project's files by the package that owns them #3090). The flags sit beside --format, and the keys owning-package.test.ts pins now include isTest.
  • A test that the filter holds in all four output formats, package included, and a test for the "No files found" path.
  • --tests in the README's CLI list, and the CHANGELOG bullet in house format.

The CLI reference on the site waits for the release, so its text isn't in this PR.

Validation

  • Red→green: cli-files-test-classification.test.ts, 4 cases, all fail on main and pass here.
  • Real repos, main against this branch, both arms on one index:
Repo Files Tests Other rows vs main --tests + --no-tests Source views Test views
express 149 92 identical split exactly by isTest 5 of 5 identical 5 of 5 label only
flask 91 48 identical split exactly by isTest 5 of 5 identical 5 of 5 label only
gin 110 42 identical split exactly by isTest 5 of 5 identical 4 of 5 label only
excalidraw 738 164 identical split exactly by isTest 5 of 5 identical 5 of 5 label only
  • The one gin case is binding/binding_test.go, which is over the output cap: the 12-character label moves the cut one line up (lines 1–1164 of 1435, not 1–1165), and the range note says so.
  • Explore doesn't use this view, and its budgets aren't touched.
  • The predicate stays as it is, so a workflow named .github/workflows/test.yml counts as a test file, as it does for search and codegraph affected.
  • Suite: one full Vitest 4 run with 4 workers on a stack of fix(cli): reject sync for stale extraction indexes #1842, feat(mcp): warn when project indexes need rebuilding #1853, fix(cli): require full rebuild for stale extraction indexes #1256 and this PR: top c8652154 on main d494e43, 845 files, 10307 tests, 10219 passed, 1 failed, 87 skipped. The failure was this PR's: owning-package.test.ts pins the files --json keys, and isTest is a new one. This commit updates that list, a one-line test change; no source line changed after that run, and no full suite has run since.
  • On this exact head: owning-package.test.ts, cli-files-test-classification.test.ts and mcp-staleness-banner.test.ts, 73 passed, Vitest 4, kernel expected. The other files changed on the stack: 174 passed, 1 skipped, at the same tree.

Fixes #1877

Lands #1960 by @maxmilian

🤖 Generated with Claude Code

… filters

Tools built on CodeGraph need to know whether a file is a test, and nothing
on the CLI said so. They kept their own naming rules, which drift from the
one CodeGraph uses for search and `codegraph affected`.

`codegraph files --json` now gives each file `isTest`, from that same
predicate. `--tests` and `--no-tests` filter the list before any output
format, `--format package` included. `codegraph node --file`, the same view
as `codegraph_node` on a file, says "test file" in its header.

Validation: 4 CLI cases fail on main and pass here. On express, flask, gin
and excalidraw, `files --json` matches main row for row apart from the new
field, and `--tests` and `--no-tests` split the list exactly by it. Of 20
source file views, 20 are byte-identical to main. Of 20 test file views, 19
differ only by the label; gin's binding_test.go is over the output cap, so
the label moves the cut one line up and the range note says so. Explore
doesn't use this view, and its budgets aren't touched.

Fixes #1877
Original PR #1960 by @maxmilian.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@colbymchenry
colbymchenry merged commit b6ea617 into main Oct 31, 2026
@colbymchenry
colbymchenry deleted the claude/pr-1960-files-test-classification branch October 31, 2026 00:12
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.

Expose the test-file predicate (isTestPath) as a per-file query

2 participants