Skip to content

perf T4-W1: libby init --help runs the full setup wizard (measured 2442 ms of network probes + authenticate) instead of printing help #11

Description

@JavaGT

Measured (median of 9 spawns, this machine, 2026-09-11)

libby init --help2442 ms, exit 0. The init branch (bin/libby.mjs:232-235) ignores all args and always calls runInit(), which non-interactively:

  1. network-probes detectInsecureTLS (src/init.mjs:64-75)
  2. resolves the saved library key over the network (src/init.mjs:93)
  3. runs authenticate (src/init.mjs:119) — cached-session verify() = GET /chip/sync
  4. reaches saveConfig (src/init.mjs:134)

This run's probes + authenticate did execute (that is the 2.4 s); the owner's config.json/session.json were verified untouched by mtime afterward — but a wizard run that completes its save would rewrite the user config as a side effect of asking for help.

Fix shape

In the init branch, handle --help/-h before runInit(): print init usage, exit 0. Everything else about runInit is out of scope.

Out-of-scope observation for the owner (no change proposed in this ticket): non-TTY libby init runs the whole wizard silently on saved defaults — stdin-closed prompts resolve instantly, so a scripted/accidental invocation can network-probe, re-authenticate, and rewrite config with nobody watching.

Acceptance

  1. libby init --help prints usage and exits 0 with spawn median within noise of libby help; zero network (hermetic: run with XDG_CONFIG_HOME pointed at an empty temp dir so even a regression cannot touch the real config).
  2. Spawn pin in test/cli-lazy.test.mjs for the above.
  3. libby init without flags still starts the wizard (no behavior change).
  4. node --test green; changes confined to bin/libby.mjs + test/cli-lazy.test.mjs.

Related: #10 (usage-error paths pay session bootstrap), #12 (cached-session verify cost).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions