You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(output): default to terse output when stdout is non-TTY (#585)
* perf(cli): lazy-load subcommand modules to cut startup latency
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.
* perf(output): default to terse output when stdout is non-TTY
---------
Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
0 commit comments