') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); fix(cli): split MCP capability provider to avoid pulling runtime-host/server into TUI by me2seeks · Pull Request #4007 · apache/maka · GitHub
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

@me2seeksme2seeks 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-actionsgithub-actionsBot added the effort/M Under 500 readable lines label Aug 27, 2026

@jackwenerjackwener 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.
Fixesapache#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
me2seeksforce-pushed the fix/cli-tui-startup-mcp-server-import branch from 69f85d4 to 532dbc2CompareAugust 28, 2026 01:57

@jackwenerjackwener 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
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

@likun666661
likun666661 merged commit e85a61a into apache:mainAug 28, 2026
1 check passed
@me2seeksme2seeks mentioned this pull request Aug 28, 2026
6 tasks
saltand pushed a commit to saltand/maka-agent that referenced this pull request Aug 31, 2026
…/server into TUI (apache#4007)
* fix(cli): split MCP capability provider to avoid pulling runtime-host/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.
Fixesapache#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
* style(cli): collapse mcp-capability-provider type import
* test(cli): guard TUI MCP import boundary
Generated-by: Codex
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/MUnder 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

@me2seeks@jackwener@likun666661