Skip to content

fix(cli): split MCP capability provider to avoid pulling runtime-host/server into TUI - #4007

Merged
likun666661 merged 3 commits into
apache:mainfrom
me2seeks:fix/cli-tui-startup-mcp-server-import
Aug 28, 2026
Merged

fix(cli): split MCP capability provider to avoid pulling runtime-host/server into TUI#4007
likun666661 merged 3 commits into
apache:mainfrom
me2seeks:fix/cli-tui-startup-mcp-server-import

Conversation

@me2seeks

@me2seeks me2seeks commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #4005.

The CLI TUI previously reached createMcpCapabilityProvider through a command module that also imports @maka/runtime-host/server. This keeps the provider implementation in mcp-capability-provider.ts, lets tui-mcp-control import that pure module directly, and retains the command-module re-export for existing callers. The follow-up test guards the emitted TUI-to-provider boundary so it cannot silently regain the Runtime Host server dependency.

Verification

  • mise exec node@24.18.1 -- npm --workspace maka-agent run build
  • mise exec node@24.18.1 -- node --test packages/cli/dist/__tests__/runtime-host-capability-provider-command.test.js — 3 passed
  • The previous exact-head hosted test check passed before this follow-up; this push reruns CI.
  • Not rerun locally: the complete repository suite and import-performance measurement.

AI use

  • Generative tooling made a substantive contribution

Tool(s) and scope: Muse Spark was declared for the initial provider extraction. Codex added the emitted-module import-boundary regression test and restored this PR template metadata. The follow-up commit carries a Generated-by: Codex trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Aug 27, 2026

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed exact head 69f85d443f58cf441466a92c6a3c0df1317ce162. I found no P0–P2 defect in the extraction.

The production behavior is preserved: createMcpCapabilityProvider() moved unchanged into mcp-capability-provider.ts, the command module re-exports it for existing consumers, and the TUI now imports the pure module directly. The new module has no runtime dependency on @maka/runtime-host/server.

I also reproduced the performance premise with fresh builds of the PR base and this head on the same machine. Median cold imports of tui-mcp-control.js fell from about 383 ms to 99 ms, and runtime-host-tui-command.js fell from about 416 ms to 197 ms. The corresponding Node ESM debug events dropped by roughly 79% and 66%. The full repository build and all 541 CLI tests passed. Exact-head hosted test succeeded, and the current-main merge is clean.

Two non-blocking P3 gaps remain:

  1. The tests still import the compatibility re-export from runtime-host-capability-provider-command.ts, so they protect function behavior but do not protect the import boundary that this PR fixes. A small dependency-boundary check should fail if tui-mcp-control again reaches @maka/runtime-host/server.
  2. The PR body replaced the repository template and only says Generated-by: Muse Spark. Please restore the AI-use declaration with the tool's scope, the verification section, and the checklist required by the contribution template.

Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

…/server into TUI

TUI imported createMcpCapabilityProvider from
runtime-host-capability-provider-command.ts, which statically imports
runRuntimeHostProcessLifecycle from @maka/runtime-host/server. That
pulled 372 runtime files and 879 total ESM modules, making
runtime-host-tui-command import ~1.28s vs 0.23s for cli-core.

Split the pure createMcpCapabilityProvider into
mcp-capability-provider.ts (deps only on @maka/core/mcp,
@maka/mcp, @maka/runtime-host/protocol). tui-mcp-control now
imports from the pure module; the command file re-exports for
compatibility and keeps the server import only for
runRuntimeHostCapabilityProviderCli.

Fixes apache#4005

Measured:
- tui-command import 1280ms/879 files/233 runtime -> 563ms/287 files/3 runtime (-56%)
- tui-mcp-control 1110ms/808 files/233 runtime -> 76 core/5 storage/0 runtime

Generated-by: Muse Spark
@me2seeks
me2seeks force-pushed the fix/cli-tui-startup-mcp-server-import branch from 69f85d4 to 532dbc2 Compare August 28, 2026 01:57

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed the updated exact head 532dbc2fb6def5ce34ec77167aa3bde9e55f52a5. I found no P0-P3 issues.

The two earlier non-blocking gaps are closed:

  • The original extraction commits are patch-equivalent after the rebase. The added emitted-module regression now verifies that the TUI imports mcp-capability-provider.js, that both the TUI and provider stay free of @maka/runtime-host/server, and that the command compatibility re-export is the same implementation. Reverting the import boundary makes this test fail.
  • The PR body now contains the verification results, AI-use scope, checklist, and behavior declaration required by the repository template. The new commit also carries its Generated-by: Codex trailer.

The exact-head hosted test check completed successfully, and the current-main merge is clean. The prior same-machine performance measurements remain applicable because the rebased extraction is patch-equivalent: median cold imports fell from about 383 ms to 99 ms for tui-mcp-control and from about 416 ms to 197 ms for the TUI command.


Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

@jackwener
jackwener requested a review from Astro-Han August 28, 2026 04:15
@likun666661
likun666661 merged commit e85a61a into apache:main Aug 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants