#1877·codegraph

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

Author: iwan-uschkaCreated Sep 15, 2026Updated Sep 15, 2026

Tooling that consumes CodeGraph often needs "is this file a test suite" as a graph fact rather than a hand-rolled naming regex: routing a reviewed test file to a different prompt, deciding whether a changed file needs a test-coverage check at all, or filtering a file list to non-test code.

Since #1803 (issue #1507) codegraph affected shares one notion of a test file, isTestPath in src/search/query-utils.ts, with search and the MCP tools. That predicate already covers the cross-ecosystem conventions (test_foo.py, foo_test.go, foo.test.ts, FooTest.kt, root-level tests/ and spec/ dirs). But it is internal. Nothing on the CLI or MCP surface lets a caller ask it about one path, so downstream tools keep a diverging copy, the same divergence #1507 fixed inside the CLI.

Checked against 1.6.0 and current main:

  • codegraph files --json reports language and symbol count per file, no test flag.
  • codegraph node --file <path> --symbols-only reports symbols and dependents, no test flag.
  • No subcommand answers the question for a single path.

Proposed shape:

  • Add an isTest: boolean field to each entry of codegraph files --json, and a --tests / --no-tests filter on files.
  • Print the same fact in codegraph node --file header output (e.g. "test file") so agents reading it see it.
  • Optionally a tiny codegraph is-test <path>... that exits 0/1 per path for shell use, or a --json list.

Reusing isTestPath directly keeps a single definition; downstream tools can then delete their own regexes instead of maintaining a copy that drifts.