Skip to content

perf(output): default to terse output when stdout is non-TTY#585

Merged
NagyVikt merged 2 commits into
mainfrom
agent/claude/perf-cli-startup-and-terse-output-2026-05-16-02-41
May 16, 2026
Merged

perf(output): default to terse output when stdout is non-TTY#585
NagyVikt merged 2 commits into
mainfrom
agent/claude/perf-cli-startup-and-terse-output-2026-05-16-02-41

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Automated by gx branch finish (PR flow).

NagyVikt 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.
@NagyVikt NagyVikt merged commit 2e4b75e into main May 16, 2026
@NagyVikt NagyVikt deleted the agent/claude/perf-cli-startup-and-terse-output-2026-05-16-02-41 branch May 16, 2026 00:44
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.

1 participant