Repository navigation
fix(cli): print find results on stdout, keep diagnostics on stderr - #1734
Merged
Shashankss1205 merged 2 commits intoSep 27, 2026
Merged
Shashankss1205 merged 2 commits into
Shashankss1205 merged 2 commits into
Conversation
Mirrors tests/integration/test_analyze_text_output_stream.py for the seven `find` subcommands. Fails today: the result headers and empty-result notices are still on the stderr console. Refs CodeGraphContext#1725
`analyze` got a stdout console in CodeGraphContext#1725; the seven `find` subcommands still carried their tables there. A separate console per command family keeps the blast radius inside `find`: result tables, empty-result notices and the truncation/wildcard footers move to stdout, while the `Invalid --type` argument error and the Neo4j full-text-index diagnostics stay on stderr.
|
@MorningStar0709 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
Shashankss1205
approved these changes
Sep 27, 2026
Shashankss1205
left a comment
Collaborator
There was a problem hiding this comment.
Verified locally on a trial merge (new stream test + CLI command tests pass). Thanks for measuring the actual seven subcommands rather than the five in the thread.
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.
What
Follow-up to #1725, as discussed there: the
findsubcommands still print theirresult tables on the module-level
Console(stderr=True), socgc find name busy > matches.txtcaptures the init chatter and loses the matches. This adds a stdout console for
the
findfamily and routes the product to it, keepingconsolefor promptsand diagnostics — the same split #1725 landed for
analyze.findalready sits alongsidestatsanddiagram, which print their product onstdout, so this closes the last command family that had its streams inverted.
Scope measured, not guessed
The follow-up was approved "in the same shape" for "the five
findcommands".On current
mainthe group actually has seven subcommands —name,pattern,type,variable,content,decorator,argument— and 28console.printsites in that block (tests/integration/cli/test_cli_commands.py:427asserts the same seven). All seven are handled here.
find nameInvalid --type '…'argument error, thentyper.Exit(1)No code elements found with name '…'Found N matches for '…':+ tablefind patternfind typefind variablefind contentcgc find patternpointerfind decoratorfind argument24 sites move, 4 stay.
Why the four stay:
--typevalidation message is not a result and must not land in aredirected document — same reasoning as fix(cli): print analyze results on stdout, keep prompts on stderr #1725's third rule.
answer to the query that was asked, and they are followed by an empty-result
notice that is the result and does move.
The wildcard/regex note (2322) and the truncation footers move because they
qualify the rows the caller is about to read — consistent with treating the
analyzefooter as part of the product.A separate
find_result_consoleis added rather than reusinganalyze_result_console, so the already-reviewedanalyzesymbol keeps itsmeaning and this change cannot regress it.
Tests
tests/integration/test_find_text_output_stream.pymirrorstests/integration/test_analyze_text_output_stream.py(isolatedHOME,DEFAULT_DATABASE=kuzudb, global context) over the seven subcommands. Eachpositive case asserts both directions — header and table on stdout and the
header absent from stderr — so printing to both streams cannot satisfy it.
Empty-result notices are asserted as stdout content, and the
--typeerror isasserted to stay off stdout.
Committed test-first: the test commit fails 8/9 against the pre-change tree
(the ninth is the stderr guard that already holds) and passes after the fix
commit.
Smoke check on a real install, with stderr discarded:
Local verification
pytest tests/unit/ tests/integration/(i.e../tests/run_tests.sh fast) on this branch atb05d549, two back-to-back runs: 1605 passed, 0 failed, 8 skipped in 16:40 and 1605 passed, 0 failed, 8 skipped in 16:32.test_find_text_output_stream.py+test_analyze_text_output_stream.py) → 13 passed in 131 s.ruff checkon the changed file → 19 findings, byte-identical to the pre-change file ata864a9f; the new test file is clean. (cli/main.pyis not in the lint workflow's file list, so these are not gate findings.)One stability note so the numbers above are read correctly:
fastis load-sensitive on this machine. In an earlier session the identical command on the identical tree returned 16 failures, then 1 on a repeat, with no overlap between the two sets — and most of those files are untouched by this branch. The two runs above are clean; CI is the better arbiter for this suite.What the change actually does, measured
Same fixture (1 file, 3 function nodes, isolated
HOME,DEFAULT_DATABASE=kuzudb), same command set, same interpreter — the only variable is the code version:a864a9fversus this branch. Every command is read-only, so the database is identical for both runs.find name busyfind name nothing_herefind pattern busyfind type functionfind variable MAX_LIMITfind content busyfind decorator route(empty result)find argument xanalyze callers busyanalyze complexity --threshold 2Two cross-checks that come out of this table:
find name busy: before462 B - 109 B = 353 B, after445 B - 92 B = 353 B. The residual bytes are what stays behind on each stream (two config lines on stderr; three pre-existing progress lines on stdout), so the table itself is byte-identical on both sides — this change does not touch rendering.analyzerows are identical before and after, which is the same guarantee the existingtest_analyze_text_output_stream.pylocks in: the new console does not reach into fix(cli): print analyze results on stdout, keep prompts on stderr #1725's symbols.One adjacent thing, deliberately untouched
Those three progress lines ("Resolving context…", "Initializing services…",
"Services initialized.") are already on stdout today for every command, so
post-change stdout is chatter + table. A script consuming
findoutput stillhas to skip that prefix;
analyze,statsanddiagramhave the same propertytoday. Fixing it means deciding where those stage messages belong, which is a
different contract question than this one, so it stays out of this PR.