What happened
maka TUI cold start is ~1.28s ESM compile on main@a5c2631 vs maka --help 0.23s.
strace shows TUI loads 879 files vs cli-core 148 files. Dominant cost is compileSourceTextModule.
Root cause: packages/cli/src/tui-mcp-control.ts statically imports createMcpCapabilityProvider from runtime-host-capability-provider-command.ts, which statically imports runRuntimeHostProcessLifecycle from @maka/runtime-host/server. That pulls full @maka/runtime (372 files, linkedom/zod/openai etc) even though TUI only needs the pure createMcpCapabilityProvider function.
Patched (remove server import) reduces TUI import from 1280ms/879 files/233 runtime to 471ms/287 files/3 runtime (-62%).
How to reproduce
On main@a5c2631 after npm --workspace maka-agent run build:
node -e "let s=performance.now(); await import('./packages/cli/dist/runtime-host-tui-command.js'); console.log(performance.now()-s)"
# ~1280ms
node -e "let s=performance.now(); await import('./packages/cli/dist/tui-mcp-control.js'); console.log(performance.now()-s)"
# ~1110ms, strace shows 233 runtime files
# patched (sed remove server import) -> 470ms / 287 files
Environment
- Commit:
a5c2631
- Node: 26.3.0
- OS: Linux
- Surface: TUI / CLI
Additional context
maka is Node ESM (packages/cli/dist/cli.js), not a compiled Rust binary. Release npm tarball ships same JS, so binary release has same issue. Native addons are only runtime-host-peer/gitoxide-helper.
Proposed fix: split mcp-capability-provider.ts (pure) from runtime-host-capability-provider-command.ts (CLI, needs server). tui-mcp-control.ts should import from pure module.
Verified via strace -e openat and NODE_DEBUG=esm / --cpu-prof.
What happened
makaTUI cold start is ~1.28s ESM compile onmain@a5c2631vsmaka --help0.23s.straceshows TUI loads 879 files vscli-core148 files. Dominant cost iscompileSourceTextModule.Root cause:
packages/cli/src/tui-mcp-control.tsstatically importscreateMcpCapabilityProviderfromruntime-host-capability-provider-command.ts, which statically importsrunRuntimeHostProcessLifecyclefrom@maka/runtime-host/server. That pulls full@maka/runtime(372 files, linkedom/zod/openai etc) even though TUI only needs the purecreateMcpCapabilityProviderfunction.Patched (remove server import) reduces TUI import from 1280ms/879 files/233 runtime to 471ms/287 files/3 runtime (-62%).
How to reproduce
On
main@a5c2631afternpm --workspace maka-agent run build:Environment
a5c2631Additional context
makais Node ESM (packages/cli/dist/cli.js), not a compiled Rust binary. Release npm tarball ships same JS, so binary release has same issue. Native addons are onlyruntime-host-peer/gitoxide-helper.Proposed fix: split
mcp-capability-provider.ts(pure) fromruntime-host-capability-provider-command.ts(CLI, needs server).tui-mcp-control.tsshould import from pure module.Verified via
strace -e openatandNODE_DEBUG=esm/--cpu-prof.