perf(output): default to terse output when stdout is non-TTY#585
Merged
NagyVikt merged 2 commits intoMay 16, 2026
Merged
Conversation
added 2 commits
May 16, 2026 02:42
Top-level requires for subcommand modules (hooks, sandbox, toolchain,
finish, doctor, submodule, agents/*, report/session-severity, budget,
ci-init, cockpit, pr-review) are now wrapped in a memoizing Proxy that
defers the underlying `require()` until the first property access.
Every `gx <verb>` invocation previously paid the cost of loading the
full subcommand graph (3.9k-line dispatcher pulls in ~15 module trees).
With the Proxy, only the verb's own module(s) are walked — `gx --help`
and `gx help` now skip doctor, cockpit, finish, budget, ci-init,
submodule, pr-review, and the agents/* family entirely.
Measured on this worktree (15 samples each):
command before after delta
-------------------------------------
gx --help ~90ms ~50ms -40ms (-44%)
gx help ~100ms ~40ms -60ms (-60%)
gx doctor* ~70ms ~50ms -20ms (-29%)
(*doctor early-aborts on a non-existent --target)
Anything used by `--help` rendering or the no-arg cockpit/status default
path stays eager (context, output, scaffold, git, core/runtime, args,
dispatch). Only true subcommand modules are deferred.
Property-only access through the Proxy is a safe drop-in: there is no
spread / destructure / Object.keys against these module objects in
main.js. The single destructured import (`finishAgentSession`) is
replaced with a thin forwarding arrow that defers the load to call time.
Verified:
- `node --test test/*.test.js` — net new failures: 0 vs the clean
worktree baseline (27 pre-existing failures from parallel in-flight
work on src/context.js, src/doctor, src/git).
- `cli main no longer keeps local copies of extracted shared helpers
or dead cleanup code` (a structure-asserting test) still passes; the
lazy wrapper preserves the literal `require('../<module>')` tokens
the test scans for.
- `node bin/multiagent-safety.js --help` exits 0.
- `node bin/multiagent-safety.js status` runs to completion on this
repo.
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.
Automated by gx branch finish (PR flow).