Skip to content

fix(cli): TUI imports runtime-host/server via MCP capability provider, adding 800ms ESM compile #4005

Closed

Description

@me2seeks

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.

Activity

  1. me2seeks commented on Aug 27, 2026

    @me2seeks
    ContributorAuthor

    我在工作

  2. added a commit that references this issue on Aug 28, 2026
    86e97b9
  3. added a commit that references this issue on Aug 28, 2026
    e85a61a
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions