Skip to content

perf(start): run the published max from an esbuild bundle (cli-dev bundle) - #856

Merged
leemour merged 4 commits into
mainfrom
perf/bundle
Oct 27, 2026
Merged

leemour merged 4 commits into
mainfrom
perf/bundle

Conversation

@leemour

@leemour leemour commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Task

Ship max as an esbuild bundle built by cli-base's shared cli-dev bundle (0.65.0), as tg does since 0.100.0 (owner-approved rollout).

Why

A command imports about a thousand module files before it does any work; the bundle loads a few dozen. tg's start halved (cli-testing tg-bundle).

What

  • build: tsc --build --force && cli-dev bundle --bin dist/bin/max.js --external ws; esbuild 0.28.2 as a devDependency (cli-base's optional peer).
  • dist/bin/max.js becomes the loader: it answers --version, turns the compile cache on, and for serve, watch and mcp serve (also after a flag) preloads every chunk so an in-place upgrade cannot pull one from under a running server.
  • Smoke: the bin starts the bundle, the loader preloads only chunks that exist, its --version equals the bundle's, skills and document readers are found, and the store opens where a read needs no account. smoke:node (new) runs in CI; smoke:bun runs it under Bun.
  • TESTING.md and a changelog line.

Testing

Results follow in a comment: identity under npm and pnpm, the upgrade test with and without a flag before mcp serve, timings.

🤖 Generated with Claude Code

@leemour

leemour commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

Results (cli-core 0.469.0, cli-base 0.65.0)

Installed from npm pack tarballs; before = main (tsc only), after = this branch.

  • Identity: 26 commands plus an MCP session (smoke mcp serve), under npm and pnpm: byte-identical after normalising paths, run ids and timings; the only difference is the stack frames in a failed run's record. All 16 rewritten asset paths exist in both layouts.
  • Upgrade with an MCP server running, bundle A → B with every chunk renamed: smoke mcp serve and smoke --quiet mcp serve both preloaded (139 bundle loads each) and answered all 9 calls after the upgrade; none crashed.
  • Timing, warm, median of 10, taskset -c 0-3, load 2.5–3.0: --version 37 → 19 ms; --help 452 → 221 (−51%); messages list --help 436 → 211 (−52%); bench chats list --offline 469 → 246 (−48%).
  • Package: 0.48 → 2.99 MB to download.
  • smoke:node and smoke:bun pass.

🤖 Generated with Claude Code

@leemour
leemour merged commit bfebb73 into main Oct 27, 2026
13 checks passed
@leemour
leemour deleted the perf/bundle branch October 29, 2026 15:42
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