@akon-labs/nexus-cli 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +1 -0
- package/README.md +3 -2
- package/dist/app-bridge.bundle.js +67 -0
- package/dist/cli.js +20263 -2158
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auto-model.d.ts +1 -1
- package/dist/core/auto-model.d.ts.map +1 -1
- package/dist/core/auto-model.js +1 -1
- package/dist/core/auto-model.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +3 -3
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +15 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +50 -0
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -3
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +5 -5
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/websearch.d.ts.map +1 -1
- package/dist/core/tools/websearch.js +3 -3
- package/dist/core/tools/websearch.js.map +1 -1
- package/dist/extensions/gitnexus/gateway.d.ts +6 -6
- package/dist/extensions/gitnexus/gateway.d.ts.map +1 -1
- package/dist/extensions/gitnexus/gateway.js +4 -4
- package/dist/extensions/gitnexus/gateway.js.map +1 -1
- package/dist/extensions/gitnexus/index.d.ts.map +1 -1
- package/dist/extensions/gitnexus/index.js +4 -2
- package/dist/extensions/gitnexus/index.js.map +1 -1
- package/dist/extensions/mcp/abort.d.ts +3 -0
- package/dist/extensions/mcp/abort.d.ts.map +1 -0
- package/dist/extensions/mcp/abort.js +41 -0
- package/dist/extensions/mcp/abort.js.map +1 -0
- package/dist/extensions/mcp/agent-dir.d.ts +6 -0
- package/dist/extensions/mcp/agent-dir.d.ts.map +1 -0
- package/dist/extensions/mcp/agent-dir.js +18 -0
- package/dist/extensions/mcp/agent-dir.js.map +1 -0
- package/dist/extensions/mcp/agent-plugin-loader.d.ts +9 -0
- package/dist/extensions/mcp/agent-plugin-loader.d.ts.map +1 -0
- package/dist/extensions/mcp/agent-plugin-loader.js +384 -0
- package/dist/extensions/mcp/agent-plugin-loader.js.map +1 -0
- package/dist/extensions/mcp/app-bridge.bundle.js +67 -0
- package/dist/extensions/mcp/commands.d.ts +27 -0
- package/dist/extensions/mcp/commands.d.ts.map +1 -0
- package/dist/extensions/mcp/commands.js +629 -0
- package/dist/extensions/mcp/commands.js.map +1 -0
- package/dist/extensions/mcp/config.d.ts +121 -38
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +1030 -70
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/consent-manager.d.ts +14 -0
- package/dist/extensions/mcp/consent-manager.d.ts.map +1 -0
- package/dist/extensions/mcp/consent-manager.js +60 -0
- package/dist/extensions/mcp/consent-manager.js.map +1 -0
- package/dist/extensions/mcp/direct-tools.d.ts +11 -0
- package/dist/extensions/mcp/direct-tools.d.ts.map +1 -0
- package/dist/extensions/mcp/direct-tools.js +562 -0
- package/dist/extensions/mcp/direct-tools.js.map +1 -0
- package/dist/extensions/mcp/elicitation-handler.d.ts +18 -0
- package/dist/extensions/mcp/elicitation-handler.d.ts.map +1 -0
- package/dist/extensions/mcp/elicitation-handler.js +320 -0
- package/dist/extensions/mcp/elicitation-handler.js.map +1 -0
- package/dist/extensions/mcp/error-signal.d.ts +16 -0
- package/dist/extensions/mcp/error-signal.d.ts.map +1 -0
- package/dist/extensions/mcp/error-signal.js +22 -0
- package/dist/extensions/mcp/error-signal.js.map +1 -0
- package/dist/extensions/mcp/errors.d.ts +104 -0
- package/dist/extensions/mcp/errors.d.ts.map +1 -0
- package/dist/extensions/mcp/errors.js +171 -0
- package/dist/extensions/mcp/errors.js.map +1 -0
- package/dist/extensions/mcp/glimpse-ui.d.ts +10 -0
- package/dist/extensions/mcp/glimpse-ui.d.ts.map +1 -0
- package/dist/extensions/mcp/glimpse-ui.js +67 -0
- package/dist/extensions/mcp/glimpse-ui.js.map +1 -0
- package/dist/extensions/mcp/host-html-template.d.ts +17 -0
- package/dist/extensions/mcp/host-html-template.d.ts.map +1 -0
- package/dist/extensions/mcp/host-html-template.js +442 -0
- package/dist/extensions/mcp/host-html-template.js.map +1 -0
- package/dist/extensions/mcp/index.d.ts +20 -15
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +1064 -82
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/init.d.ts +28 -0
- package/dist/extensions/mcp/init.d.ts.map +1 -0
- package/dist/extensions/mcp/init.js +631 -0
- package/dist/extensions/mcp/init.js.map +1 -0
- package/dist/extensions/mcp/json-schema-validator.d.ts +3 -0
- package/dist/extensions/mcp/json-schema-validator.d.ts.map +1 -0
- package/dist/extensions/mcp/json-schema-validator.js +53 -0
- package/dist/extensions/mcp/json-schema-validator.js.map +1 -0
- package/dist/extensions/mcp/lifecycle.d.ts +56 -0
- package/dist/extensions/mcp/lifecycle.d.ts.map +1 -0
- package/dist/extensions/mcp/lifecycle.js +395 -0
- package/dist/extensions/mcp/lifecycle.js.map +1 -0
- package/dist/extensions/mcp/logger.d.ts +52 -0
- package/dist/extensions/mcp/logger.d.ts.map +1 -0
- package/dist/extensions/mcp/logger.js +134 -0
- package/dist/extensions/mcp/logger.js.map +1 -0
- package/dist/extensions/mcp/mcp-auth-flow.d.ts +117 -0
- package/dist/extensions/mcp/mcp-auth-flow.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-auth-flow.js +869 -0
- package/dist/extensions/mcp/mcp-auth-flow.js.map +1 -0
- package/dist/extensions/mcp/mcp-auth.d.ts +162 -0
- package/dist/extensions/mcp/mcp-auth.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-auth.js +897 -0
- package/dist/extensions/mcp/mcp-auth.js.map +1 -0
- package/dist/extensions/mcp/mcp-bearer-store.d.ts +25 -0
- package/dist/extensions/mcp/mcp-bearer-store.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-bearer-store.js +350 -0
- package/dist/extensions/mcp/mcp-bearer-store.js.map +1 -0
- package/dist/extensions/mcp/mcp-callback-server.d.ts +54 -0
- package/dist/extensions/mcp/mcp-callback-server.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-callback-server.js +454 -0
- package/dist/extensions/mcp/mcp-callback-server.js.map +1 -0
- package/dist/extensions/mcp/mcp-code.d.ts +48 -0
- package/dist/extensions/mcp/mcp-code.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-code.js +358 -0
- package/dist/extensions/mcp/mcp-code.js.map +1 -0
- package/dist/extensions/mcp/mcp-keyring-helper.cjs +89 -0
- package/dist/extensions/mcp/mcp-oauth-provider.d.ts +135 -0
- package/dist/extensions/mcp/mcp-oauth-provider.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-oauth-provider.js +491 -0
- package/dist/extensions/mcp/mcp-oauth-provider.js.map +1 -0
- package/dist/extensions/mcp/mcp-output-guard.d.ts +59 -0
- package/dist/extensions/mcp/mcp-output-guard.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-output-guard.js +343 -0
- package/dist/extensions/mcp/mcp-output-guard.js.map +1 -0
- package/dist/extensions/mcp/mcp-panel.d.ts +71 -0
- package/dist/extensions/mcp/mcp-panel.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-panel.js +973 -0
- package/dist/extensions/mcp/mcp-panel.js.map +1 -0
- package/dist/extensions/mcp/mcp-probe.d.ts +7 -0
- package/dist/extensions/mcp/mcp-probe.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-probe.js +155 -0
- package/dist/extensions/mcp/mcp-probe.js.map +1 -0
- package/dist/extensions/mcp/mcp-script-worker.mjs +130 -0
- package/dist/extensions/mcp/mcp-setup-panel.d.ts +85 -0
- package/dist/extensions/mcp/mcp-setup-panel.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-setup-panel.js +618 -0
- package/dist/extensions/mcp/mcp-setup-panel.js.map +1 -0
- package/dist/extensions/mcp/mcp-status.d.ts +12 -0
- package/dist/extensions/mcp/mcp-status.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-status.js +98 -0
- package/dist/extensions/mcp/mcp-status.js.map +1 -0
- package/dist/extensions/mcp/mcp-trace.d.ts +95 -0
- package/dist/extensions/mcp/mcp-trace.d.ts.map +1 -0
- package/dist/extensions/mcp/mcp-trace.js +252 -0
- package/dist/extensions/mcp/mcp-trace.js.map +1 -0
- package/dist/extensions/mcp/metadata-cache.d.ts +20 -0
- package/dist/extensions/mcp/metadata-cache.d.ts.map +1 -0
- package/dist/extensions/mcp/metadata-cache.js +318 -0
- package/dist/extensions/mcp/metadata-cache.js.map +1 -0
- package/dist/extensions/mcp/npx-resolver.d.ts +7 -0
- package/dist/extensions/mcp/npx-resolver.d.ts.map +1 -0
- package/dist/extensions/mcp/npx-resolver.js +505 -0
- package/dist/extensions/mcp/npx-resolver.js.map +1 -0
- package/dist/extensions/mcp/oauth.d.ts +21 -0
- package/dist/extensions/mcp/oauth.d.ts.map +1 -0
- package/dist/extensions/mcp/oauth.js +15 -0
- package/dist/extensions/mcp/oauth.js.map +1 -0
- package/dist/extensions/mcp/onboarding-state.d.ts +13 -0
- package/dist/extensions/mcp/onboarding-state.d.ts.map +1 -0
- package/dist/extensions/mcp/onboarding-state.js +65 -0
- package/dist/extensions/mcp/onboarding-state.js.map +1 -0
- package/dist/extensions/mcp/package-mcp-loader.d.ts +3 -0
- package/dist/extensions/mcp/package-mcp-loader.d.ts.map +1 -0
- package/dist/extensions/mcp/package-mcp-loader.js +170 -0
- package/dist/extensions/mcp/package-mcp-loader.js.map +1 -0
- package/dist/extensions/mcp/panel-keys.d.ts +21 -0
- package/dist/extensions/mcp/panel-keys.d.ts.map +1 -0
- package/dist/extensions/mcp/panel-keys.js +29 -0
- package/dist/extensions/mcp/panel-keys.js.map +1 -0
- package/dist/extensions/mcp/prompts.d.ts +63 -0
- package/dist/extensions/mcp/prompts.d.ts.map +1 -0
- package/dist/extensions/mcp/prompts.js +297 -0
- package/dist/extensions/mcp/prompts.js.map +1 -0
- package/dist/extensions/mcp/proxy-modes.d.ts +15 -0
- package/dist/extensions/mcp/proxy-modes.d.ts.map +1 -0
- package/dist/extensions/mcp/proxy-modes.js +1421 -0
- package/dist/extensions/mcp/proxy-modes.js.map +1 -0
- package/dist/extensions/mcp/request-headers-command.d.ts +11 -0
- package/dist/extensions/mcp/request-headers-command.d.ts.map +1 -0
- package/dist/extensions/mcp/request-headers-command.js +334 -0
- package/dist/extensions/mcp/request-headers-command.js.map +1 -0
- package/dist/extensions/mcp/resource-tools.d.ts +2 -0
- package/dist/extensions/mcp/resource-tools.d.ts.map +1 -0
- package/dist/extensions/mcp/resource-tools.js +15 -0
- package/dist/extensions/mcp/resource-tools.js.map +1 -0
- package/dist/extensions/mcp/runtime-owner.d.ts +14 -0
- package/dist/extensions/mcp/runtime-owner.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime-owner.js +84 -0
- package/dist/extensions/mcp/runtime-owner.js.map +1 -0
- package/dist/extensions/mcp/sampling-handler.d.ts +18 -0
- package/dist/extensions/mcp/sampling-handler.d.ts.map +1 -0
- package/dist/extensions/mcp/sampling-handler.js +229 -0
- package/dist/extensions/mcp/sampling-handler.js.map +1 -0
- package/dist/extensions/mcp/search-ranking.d.ts +25 -0
- package/dist/extensions/mcp/search-ranking.d.ts.map +1 -0
- package/dist/extensions/mcp/search-ranking.js +234 -0
- package/dist/extensions/mcp/search-ranking.js.map +1 -0
- package/dist/extensions/mcp/server-manager.d.ts +116 -0
- package/dist/extensions/mcp/server-manager.d.ts.map +1 -0
- package/dist/extensions/mcp/server-manager.js +1052 -0
- package/dist/extensions/mcp/server-manager.js.map +1 -0
- package/dist/extensions/mcp/session-recovery.d.ts +27 -0
- package/dist/extensions/mcp/session-recovery.d.ts.map +1 -0
- package/dist/extensions/mcp/session-recovery.js +140 -0
- package/dist/extensions/mcp/session-recovery.js.map +1 -0
- package/dist/extensions/mcp/skills/mcp-scripting/SKILL.md +38 -0
- package/dist/extensions/mcp/state.d.ts +62 -0
- package/dist/extensions/mcp/state.d.ts.map +1 -0
- package/dist/extensions/mcp/state.js +2 -0
- package/dist/extensions/mcp/state.js.map +1 -0
- package/dist/extensions/mcp/tool-approval.d.ts +11 -0
- package/dist/extensions/mcp/tool-approval.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-approval.js +156 -0
- package/dist/extensions/mcp/tool-approval.js.map +1 -0
- package/dist/extensions/mcp/tool-metadata.d.ts +11 -0
- package/dist/extensions/mcp/tool-metadata.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-metadata.js +264 -0
- package/dist/extensions/mcp/tool-metadata.js.map +1 -0
- package/dist/extensions/mcp/tool-registrar.d.ts +21 -0
- package/dist/extensions/mcp/tool-registrar.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-registrar.js +229 -0
- package/dist/extensions/mcp/tool-registrar.js.map +1 -0
- package/dist/extensions/mcp/tool-result-renderer.d.ts +83 -0
- package/dist/extensions/mcp/tool-result-renderer.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-result-renderer.js +345 -0
- package/dist/extensions/mcp/tool-result-renderer.js.map +1 -0
- package/dist/extensions/mcp/ts-shape.d.ts +3 -0
- package/dist/extensions/mcp/ts-shape.d.ts.map +1 -0
- package/dist/extensions/mcp/ts-shape.js +160 -0
- package/dist/extensions/mcp/ts-shape.js.map +1 -0
- package/dist/extensions/mcp/types.d.ts +521 -0
- package/dist/extensions/mcp/types.d.ts.map +1 -0
- package/dist/extensions/mcp/types.js +294 -0
- package/dist/extensions/mcp/types.js.map +1 -0
- package/dist/extensions/mcp/ui-app-bridge-helpers.d.ts +7 -0
- package/dist/extensions/mcp/ui-app-bridge-helpers.d.ts.map +1 -0
- package/dist/extensions/mcp/ui-app-bridge-helpers.js +37 -0
- package/dist/extensions/mcp/ui-app-bridge-helpers.js.map +1 -0
- package/dist/extensions/mcp/ui-resource-handler.d.ts +18 -0
- package/dist/extensions/mcp/ui-resource-handler.d.ts.map +1 -0
- package/dist/extensions/mcp/ui-resource-handler.js +210 -0
- package/dist/extensions/mcp/ui-resource-handler.js.map +1 -0
- package/dist/extensions/mcp/ui-server.d.ts +52 -0
- package/dist/extensions/mcp/ui-server.d.ts.map +1 -0
- package/dist/extensions/mcp/ui-server.js +740 -0
- package/dist/extensions/mcp/ui-server.js.map +1 -0
- package/dist/extensions/mcp/ui-session.d.ts +40 -0
- package/dist/extensions/mcp/ui-session.d.ts.map +1 -0
- package/dist/extensions/mcp/ui-session.js +477 -0
- package/dist/extensions/mcp/ui-session.js.map +1 -0
- package/dist/extensions/mcp/ui-stream-types.d.ts +105 -0
- package/dist/extensions/mcp/ui-stream-types.d.ts.map +1 -0
- package/dist/extensions/mcp/ui-stream-types.js +61 -0
- package/dist/extensions/mcp/ui-stream-types.js.map +1 -0
- package/dist/extensions/mcp/ui-tool-visibility.d.ts +5 -0
- package/dist/extensions/mcp/ui-tool-visibility.d.ts.map +1 -0
- package/dist/extensions/mcp/ui-tool-visibility.js +27 -0
- package/dist/extensions/mcp/ui-tool-visibility.js.map +1 -0
- package/dist/extensions/mcp/unix-socket-transport.d.ts +15 -0
- package/dist/extensions/mcp/unix-socket-transport.d.ts.map +1 -0
- package/dist/extensions/mcp/unix-socket-transport.js +85 -0
- package/dist/extensions/mcp/unix-socket-transport.js.map +1 -0
- package/dist/extensions/mcp/utils.d.ts +32 -0
- package/dist/extensions/mcp/utils.d.ts.map +1 -0
- package/dist/extensions/mcp/utils.js +336 -0
- package/dist/extensions/mcp/utils.js.map +1 -0
- package/dist/extensions/subagent/index.d.ts +61 -1
- package/dist/extensions/subagent/index.d.ts.map +1 -1
- package/dist/extensions/subagent/index.js +177 -4
- package/dist/extensions/subagent/index.js.map +1 -1
- package/dist/extensions/web-access.d.ts.map +1 -1
- package/dist/extensions/web-access.js +1 -1
- package/dist/extensions/web-access.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20057 -1947
- package/dist/index.js.map +1 -1
- package/dist/mcp-keyring-helper.cjs +89 -0
- package/dist/mcp-script-worker.mjs +130 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +1 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/response-separator.d.ts +1 -1
- package/dist/modes/interactive/components/response-separator.d.ts.map +1 -1
- package/dist/modes/interactive/components/response-separator.js +1 -1
- package/dist/modes/interactive/components/response-separator.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +7 -5
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/rpc-entry.js +20263 -2158
- package/dist/skills/mcp-scripting/SKILL.md +38 -0
- package/dist/vendor/ai.js +280 -205
- package/docs/mcp.md +178 -0
- package/docs/pi-subagents.md +75 -0
- package/docs/quickstart.md +1 -1
- package/docs/usage.md +2 -1
- package/examples/extensions/pi-subagents-worker-policy.ts +86 -0
- package/npm-shrinkwrap.json +763 -6
- package/package.json +15 -4
- package/dist/extensions/mcp/client.d.ts +0 -86
- package/dist/extensions/mcp/client.d.ts.map +0 -1
- package/dist/extensions/mcp/client.js +0 -275
- package/dist/extensions/mcp/client.js.map +0 -1
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
import { matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { getConfigDirName } from "./agent-dir.js";
|
|
3
|
+
import { KNOWN_SERVER_PRESETS, } from "./config.js";
|
|
4
|
+
import { createPanelKeys } from "./panel-keys.js";
|
|
5
|
+
const DEFAULT_THEME = {
|
|
6
|
+
border: "2",
|
|
7
|
+
title: "36",
|
|
8
|
+
selected: "32",
|
|
9
|
+
hint: "2",
|
|
10
|
+
success: "32",
|
|
11
|
+
warning: "33",
|
|
12
|
+
muted: "2;3",
|
|
13
|
+
};
|
|
14
|
+
const MIN_PANEL_WIDTH = 24;
|
|
15
|
+
const COMPACT_WIDTH = 60;
|
|
16
|
+
const COMPACT_ACTION_ROWS = 7;
|
|
17
|
+
const DESKTOP_PREVIEW_WIDTH = 74;
|
|
18
|
+
function fg(code, text) {
|
|
19
|
+
return code ? `\x1b[${code}m${text}\x1b[0m` : text;
|
|
20
|
+
}
|
|
21
|
+
function wrapText(text, width) {
|
|
22
|
+
if (width <= 8)
|
|
23
|
+
return [text];
|
|
24
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
25
|
+
const lines = [];
|
|
26
|
+
let current = "";
|
|
27
|
+
for (const word of words) {
|
|
28
|
+
const candidate = current ? `${current} ${word}` : word;
|
|
29
|
+
if (visibleWidth(candidate) <= width) {
|
|
30
|
+
current = candidate;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (current)
|
|
34
|
+
lines.push(current);
|
|
35
|
+
current = word;
|
|
36
|
+
}
|
|
37
|
+
if (current)
|
|
38
|
+
lines.push(current);
|
|
39
|
+
return lines.length > 0 ? lines : [""];
|
|
40
|
+
}
|
|
41
|
+
export class McpSetupPanel {
|
|
42
|
+
screen;
|
|
43
|
+
actionCursor = 0;
|
|
44
|
+
importCursor = 0;
|
|
45
|
+
pathCursor = 0;
|
|
46
|
+
selectedImports = new Set();
|
|
47
|
+
busy = false;
|
|
48
|
+
notice = null;
|
|
49
|
+
tui;
|
|
50
|
+
t = DEFAULT_THEME;
|
|
51
|
+
keys;
|
|
52
|
+
inactivityTimeout = null;
|
|
53
|
+
discovery;
|
|
54
|
+
callbacks;
|
|
55
|
+
options;
|
|
56
|
+
done;
|
|
57
|
+
static INACTIVITY_MS = 60_000;
|
|
58
|
+
constructor(discovery, callbacks, options, tui, done) {
|
|
59
|
+
this.discovery = discovery;
|
|
60
|
+
this.callbacks = callbacks;
|
|
61
|
+
this.options = options;
|
|
62
|
+
this.done = done;
|
|
63
|
+
this.tui = tui;
|
|
64
|
+
this.keys = createPanelKeys(options.keybindings);
|
|
65
|
+
this.screen = options.mode;
|
|
66
|
+
for (const entry of discovery.imports) {
|
|
67
|
+
this.selectedImports.add(entry.kind);
|
|
68
|
+
}
|
|
69
|
+
this.resetInactivityTimeout();
|
|
70
|
+
}
|
|
71
|
+
resetInactivityTimeout() {
|
|
72
|
+
if (this.inactivityTimeout)
|
|
73
|
+
clearTimeout(this.inactivityTimeout);
|
|
74
|
+
this.inactivityTimeout = setTimeout(() => {
|
|
75
|
+
this.cleanup();
|
|
76
|
+
this.done();
|
|
77
|
+
}, McpSetupPanel.INACTIVITY_MS);
|
|
78
|
+
}
|
|
79
|
+
cleanup() {
|
|
80
|
+
if (this.inactivityTimeout) {
|
|
81
|
+
clearTimeout(this.inactivityTimeout);
|
|
82
|
+
this.inactivityTimeout = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
getActions() {
|
|
86
|
+
const actions = [];
|
|
87
|
+
if (this.screen === "empty") {
|
|
88
|
+
actions.push({
|
|
89
|
+
id: "run-setup",
|
|
90
|
+
label: "Run setup",
|
|
91
|
+
description: "Inspect detected configs, adopt imports, and scaffold a minimal `.nexus/mcp.json`.",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (this.discovery.imports.length > 0) {
|
|
95
|
+
actions.push({
|
|
96
|
+
id: "adopt-imports",
|
|
97
|
+
label: "Adopt detected compatibility imports",
|
|
98
|
+
description: `Choose which host-specific MCP configs Nexus should import into its own override file. ${this.discovery.imports.length} source${this.discovery.imports.length === 1 ? "" : "s"} found.`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
actions.push({
|
|
102
|
+
id: "view-example",
|
|
103
|
+
label: "View example `.nexus/mcp.json`",
|
|
104
|
+
description: "Preview a working Nexus MCP config you can paste or adapt.",
|
|
105
|
+
});
|
|
106
|
+
if (!this.discovery.sources.some((source) => source.id === "nexus-project" && source.exists)) {
|
|
107
|
+
actions.push({
|
|
108
|
+
id: "scaffold-project",
|
|
109
|
+
label: "Scaffold project `.nexus/mcp.json`",
|
|
110
|
+
description: "Write a minimal Nexus project MCP config, then reload Nexus.",
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
actions.push({
|
|
114
|
+
id: "show-precedence",
|
|
115
|
+
label: "Explain config precedence",
|
|
116
|
+
description: "Show the read order and where Nexus writes compatibility settings.",
|
|
117
|
+
});
|
|
118
|
+
if (this.getDetectedPaths().length > 0) {
|
|
119
|
+
actions.push({
|
|
120
|
+
id: "open-paths",
|
|
121
|
+
label: "Open detected config paths",
|
|
122
|
+
description: "Browse the actual config files that Nexus discovered on this machine.",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
for (const preset of KNOWN_SERVER_PRESETS) {
|
|
126
|
+
actions.push({ id: "add-known-server", label: preset.name, description: preset.summary, preset });
|
|
127
|
+
}
|
|
128
|
+
if (!this.discovery.repoPrompt.configured &&
|
|
129
|
+
this.discovery.repoPrompt.executablePath &&
|
|
130
|
+
this.discovery.repoPrompt.targetPath &&
|
|
131
|
+
this.discovery.repoPrompt.entry &&
|
|
132
|
+
this.discovery.repoPrompt.serverName) {
|
|
133
|
+
actions.push({
|
|
134
|
+
id: "add-repoprompt",
|
|
135
|
+
label: "Add RepoPrompt to Nexus MCP config",
|
|
136
|
+
description: "Write an MCP entry for RepoPrompt to the recommended Nexus target, then reload MCP in-session.",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
actions.push({ id: "close", label: "Close", description: "Exit the onboarding flow." });
|
|
140
|
+
return actions;
|
|
141
|
+
}
|
|
142
|
+
getDetectedPaths() {
|
|
143
|
+
const paths = [
|
|
144
|
+
...this.discovery.sources.filter((source) => source.exists).map((source) => source.path),
|
|
145
|
+
...this.discovery.imports.map((entry) => entry.path),
|
|
146
|
+
];
|
|
147
|
+
return [...new Set(paths)];
|
|
148
|
+
}
|
|
149
|
+
getSelectedAction() {
|
|
150
|
+
const actions = this.getActions();
|
|
151
|
+
return actions[this.actionCursor];
|
|
152
|
+
}
|
|
153
|
+
handleInput(data) {
|
|
154
|
+
this.resetInactivityTimeout();
|
|
155
|
+
if (!this.busy)
|
|
156
|
+
this.notice = null;
|
|
157
|
+
if (matchesKey(data, "ctrl+c")) {
|
|
158
|
+
this.cleanup();
|
|
159
|
+
this.done();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (matchesKey(data, "escape")) {
|
|
163
|
+
if (this.screen === "imports" || this.screen === "paths") {
|
|
164
|
+
this.screen = this.discovery.hasAnyConfig ? "setup" : "empty";
|
|
165
|
+
this.tui.requestRender();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.cleanup();
|
|
169
|
+
this.done();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (this.busy)
|
|
173
|
+
return;
|
|
174
|
+
if (this.screen === "imports") {
|
|
175
|
+
this.handleImportsInput(data);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (this.screen === "paths") {
|
|
179
|
+
this.handlePathsInput(data);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const actions = this.getActions();
|
|
183
|
+
if (this.keys.selectUp(data)) {
|
|
184
|
+
this.actionCursor = Math.max(0, this.actionCursor - 1);
|
|
185
|
+
this.tui.requestRender();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (this.keys.selectDown(data)) {
|
|
189
|
+
this.actionCursor = Math.min(actions.length - 1, this.actionCursor + 1);
|
|
190
|
+
this.tui.requestRender();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (this.keys.selectConfirm(data)) {
|
|
194
|
+
const selected = this.getSelectedAction();
|
|
195
|
+
if (selected)
|
|
196
|
+
void this.runAction(selected);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
handleImportsInput(data) {
|
|
200
|
+
const imports = this.discovery.imports;
|
|
201
|
+
if (this.keys.selectUp(data)) {
|
|
202
|
+
this.importCursor = Math.max(0, this.importCursor - 1);
|
|
203
|
+
this.tui.requestRender();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (this.keys.selectDown(data)) {
|
|
207
|
+
this.importCursor = Math.min(imports.length - 1, this.importCursor + 1);
|
|
208
|
+
this.tui.requestRender();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (matchesKey(data, "space")) {
|
|
212
|
+
const current = imports[this.importCursor];
|
|
213
|
+
if (!current)
|
|
214
|
+
return;
|
|
215
|
+
if (this.selectedImports.has(current.kind)) {
|
|
216
|
+
this.selectedImports.delete(current.kind);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
this.selectedImports.add(current.kind);
|
|
220
|
+
}
|
|
221
|
+
this.tui.requestRender();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (this.keys.selectConfirm(data)) {
|
|
225
|
+
void this.applySelectedImports();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
handlePathsInput(data) {
|
|
229
|
+
const paths = this.getDetectedPaths();
|
|
230
|
+
if (this.keys.selectUp(data)) {
|
|
231
|
+
this.pathCursor = Math.max(0, this.pathCursor - 1);
|
|
232
|
+
this.tui.requestRender();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (this.keys.selectDown(data)) {
|
|
236
|
+
this.pathCursor = Math.min(paths.length - 1, this.pathCursor + 1);
|
|
237
|
+
this.tui.requestRender();
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (this.keys.selectConfirm(data)) {
|
|
241
|
+
const selected = paths[this.pathCursor];
|
|
242
|
+
if (!selected)
|
|
243
|
+
return;
|
|
244
|
+
void this.runBusy(async () => {
|
|
245
|
+
await this.callbacks.openPath(selected);
|
|
246
|
+
this.notice = { text: `Opened ${selected}`, tone: "success" };
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async runAction(action) {
|
|
251
|
+
if (action.id === "run-setup") {
|
|
252
|
+
this.screen = "setup";
|
|
253
|
+
this.actionCursor = 0;
|
|
254
|
+
this.tui.requestRender();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (action.id === "adopt-imports") {
|
|
258
|
+
this.screen = "imports";
|
|
259
|
+
this.importCursor = 0;
|
|
260
|
+
this.tui.requestRender();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (action.id === "open-paths") {
|
|
264
|
+
this.screen = "paths";
|
|
265
|
+
this.pathCursor = 0;
|
|
266
|
+
this.tui.requestRender();
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (action.id === "scaffold-project") {
|
|
270
|
+
await this.runBusy(async () => {
|
|
271
|
+
const result = await this.callbacks.scaffoldProjectConfig();
|
|
272
|
+
this.callbacks.markSetupCompleted();
|
|
273
|
+
this.notice = {
|
|
274
|
+
text: `Wrote starter config to ${result.path}. Nexus will reload after this panel closes.`,
|
|
275
|
+
tone: "success",
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (action.id === "add-repoprompt") {
|
|
281
|
+
await this.runBusy(async () => {
|
|
282
|
+
const result = await this.callbacks.addRepoPrompt();
|
|
283
|
+
this.callbacks.markSetupCompleted();
|
|
284
|
+
this.notice = {
|
|
285
|
+
text: `Added ${result.serverName} to ${result.path}. Nexus will reload after this panel closes.`,
|
|
286
|
+
tone: "success",
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (action.id === "add-known-server" && action.preset) {
|
|
292
|
+
const preset = action.preset;
|
|
293
|
+
await this.runBusy(async () => {
|
|
294
|
+
const result = await this.callbacks.addKnownServer(preset);
|
|
295
|
+
this.callbacks.markSetupCompleted();
|
|
296
|
+
this.notice = {
|
|
297
|
+
text: `Added ${result.serverName} to ${result.path}. Nexus will reload after this panel closes.`,
|
|
298
|
+
tone: "success",
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (action.id === "close") {
|
|
304
|
+
this.cleanup();
|
|
305
|
+
this.done();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
this.notice = {
|
|
309
|
+
text: "Review the details below. Press Enter on an action with a side effect to apply it.",
|
|
310
|
+
tone: "muted",
|
|
311
|
+
};
|
|
312
|
+
this.tui.requestRender();
|
|
313
|
+
}
|
|
314
|
+
async applySelectedImports() {
|
|
315
|
+
const selected = this.discovery.imports
|
|
316
|
+
.filter((entry) => this.selectedImports.has(entry.kind))
|
|
317
|
+
.map((entry) => entry.kind);
|
|
318
|
+
if (selected.length === 0) {
|
|
319
|
+
this.notice = { text: "Select at least one compatibility import first.", tone: "warning" };
|
|
320
|
+
this.tui.requestRender();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
await this.runBusy(async () => {
|
|
324
|
+
const result = await this.callbacks.adoptImports(selected);
|
|
325
|
+
this.callbacks.markSetupCompleted();
|
|
326
|
+
this.notice =
|
|
327
|
+
result.added.length > 0
|
|
328
|
+
? {
|
|
329
|
+
text: `Added ${result.added.join(", ")} to ${result.path}. Nexus will reload after this panel closes.`,
|
|
330
|
+
tone: "success",
|
|
331
|
+
}
|
|
332
|
+
: { text: `No changes needed in ${result.path}.`, tone: "muted" };
|
|
333
|
+
this.screen = this.discovery.hasAnyConfig ? "setup" : "empty";
|
|
334
|
+
this.actionCursor = 0;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
async runBusy(fn) {
|
|
338
|
+
this.busy = true;
|
|
339
|
+
this.notice = { text: "Working...", tone: "muted" };
|
|
340
|
+
this.tui.requestRender();
|
|
341
|
+
try {
|
|
342
|
+
await fn();
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
this.notice = {
|
|
346
|
+
text: error instanceof Error ? error.message : String(error),
|
|
347
|
+
tone: "warning",
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
finally {
|
|
351
|
+
this.busy = false;
|
|
352
|
+
this.tui.requestRender();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
render(width) {
|
|
356
|
+
const panelW = Math.max(MIN_PANEL_WIDTH, width);
|
|
357
|
+
const innerW = panelW - 2;
|
|
358
|
+
const contentW = this.contentWidth(innerW);
|
|
359
|
+
const lines = [];
|
|
360
|
+
const border = fg(this.t.border, "─".repeat(innerW));
|
|
361
|
+
lines.push(`┌${border}┐`);
|
|
362
|
+
lines.push(this.padLine(fg(this.t.title, "MCP setup"), innerW));
|
|
363
|
+
for (const line of wrapText(this.discoverySummaryLine(), contentW)) {
|
|
364
|
+
lines.push(this.padLine(line, innerW));
|
|
365
|
+
}
|
|
366
|
+
for (const line of wrapText(this.secondarySummaryLine(), contentW)) {
|
|
367
|
+
lines.push(this.padLine(fg(this.t.muted, line), innerW));
|
|
368
|
+
}
|
|
369
|
+
lines.push(this.padLine("", innerW));
|
|
370
|
+
if (this.notice) {
|
|
371
|
+
const tone = this.notice.tone === "success"
|
|
372
|
+
? this.t.success
|
|
373
|
+
: this.notice.tone === "warning"
|
|
374
|
+
? this.t.warning
|
|
375
|
+
: this.t.hint;
|
|
376
|
+
for (const line of wrapText(this.notice.text, contentW)) {
|
|
377
|
+
lines.push(this.padLine(fg(tone, line), innerW));
|
|
378
|
+
}
|
|
379
|
+
lines.push(this.padLine("", innerW));
|
|
380
|
+
}
|
|
381
|
+
lines.push(`├${border}┤`);
|
|
382
|
+
if (this.screen === "imports") {
|
|
383
|
+
lines.push(...this.renderImports(innerW));
|
|
384
|
+
}
|
|
385
|
+
else if (this.screen === "paths") {
|
|
386
|
+
lines.push(...this.renderPaths(innerW));
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
lines.push(...this.renderActions(innerW));
|
|
390
|
+
}
|
|
391
|
+
lines.push(`└${border}┘`);
|
|
392
|
+
return lines;
|
|
393
|
+
}
|
|
394
|
+
renderActions(innerW) {
|
|
395
|
+
const lines = [];
|
|
396
|
+
const actions = this.getActions();
|
|
397
|
+
const compact = innerW < COMPACT_WIDTH;
|
|
398
|
+
const { start, end } = compact ? this.visibleActionRange(actions.length) : { start: 0, end: actions.length };
|
|
399
|
+
if (start > 0) {
|
|
400
|
+
lines.push(this.padLine(fg(this.t.muted, `… ${start} more above`), innerW));
|
|
401
|
+
}
|
|
402
|
+
for (let index = start; index < end; index++) {
|
|
403
|
+
const action = actions[index];
|
|
404
|
+
if (!action)
|
|
405
|
+
continue;
|
|
406
|
+
if (action.id === "add-known-server" && (index === start || actions[index - 1]?.id !== "add-known-server")) {
|
|
407
|
+
lines.push(this.padLine(fg(this.t.title, "Add a known server"), innerW));
|
|
408
|
+
}
|
|
409
|
+
const selected = index === this.actionCursor;
|
|
410
|
+
const cursor = selected ? fg(this.t.selected, "›") : " ";
|
|
411
|
+
lines.push(this.padLine(`${cursor} ${truncateToWidth(action.label, this.contentWidth(innerW) - 2)}`, innerW));
|
|
412
|
+
}
|
|
413
|
+
if (end < actions.length) {
|
|
414
|
+
lines.push(this.padLine(fg(this.t.muted, `… ${actions.length - end} more below`), innerW));
|
|
415
|
+
}
|
|
416
|
+
lines.push(this.padLine("", innerW));
|
|
417
|
+
const preview = this.getActionPreview(this.getSelectedAction(), this.previewWidth(innerW));
|
|
418
|
+
for (const line of preview) {
|
|
419
|
+
lines.push(this.padLine(line, innerW));
|
|
420
|
+
}
|
|
421
|
+
lines.push(this.padLine("", innerW));
|
|
422
|
+
const hint = compact ? "Enter select · Esc back" : "Enter selects, Esc goes back, Ctrl+C closes.";
|
|
423
|
+
lines.push(this.padLine(fg(this.t.muted, hint), innerW));
|
|
424
|
+
return lines;
|
|
425
|
+
}
|
|
426
|
+
renderImports(innerW) {
|
|
427
|
+
const lines = [];
|
|
428
|
+
lines.push(this.padLine("Select compatibility imports. Space toggles, Enter saves, Esc goes back.", innerW));
|
|
429
|
+
lines.push(this.padLine("", innerW));
|
|
430
|
+
for (let index = 0; index < this.discovery.imports.length; index++) {
|
|
431
|
+
const entry = this.discovery.imports[index];
|
|
432
|
+
if (!entry)
|
|
433
|
+
continue;
|
|
434
|
+
const selected = this.selectedImports.has(entry.kind) ? "[x]" : "[ ]";
|
|
435
|
+
const cursor = index === this.importCursor ? fg(this.t.selected, "›") : " ";
|
|
436
|
+
lines.push(this.padLine(`${cursor} ${selected} ${entry.kind} ${entry.path}`, innerW));
|
|
437
|
+
}
|
|
438
|
+
lines.push(this.padLine("", innerW));
|
|
439
|
+
const selected = this.discovery.imports
|
|
440
|
+
.filter((entry) => this.selectedImports.has(entry.kind))
|
|
441
|
+
.map((entry) => entry.kind);
|
|
442
|
+
const preview = this.callbacks.previewImports(selected);
|
|
443
|
+
for (const line of this.formatWritePreview("Compatibility import write preview", preview, [], this.previewWidth(innerW))) {
|
|
444
|
+
lines.push(this.padLine(line, innerW));
|
|
445
|
+
}
|
|
446
|
+
return lines;
|
|
447
|
+
}
|
|
448
|
+
renderPaths(innerW) {
|
|
449
|
+
const lines = [];
|
|
450
|
+
lines.push(this.padLine("Select a detected config path to open. Enter opens it, Esc goes back.", innerW));
|
|
451
|
+
lines.push(this.padLine("", innerW));
|
|
452
|
+
const paths = this.getDetectedPaths();
|
|
453
|
+
for (let index = 0; index < paths.length; index++) {
|
|
454
|
+
const cursor = index === this.pathCursor ? fg(this.t.selected, "›") : " ";
|
|
455
|
+
const path = paths[index];
|
|
456
|
+
if (path !== undefined)
|
|
457
|
+
lines.push(this.padLine(`${cursor} ${path}`, innerW));
|
|
458
|
+
}
|
|
459
|
+
return lines;
|
|
460
|
+
}
|
|
461
|
+
discoverySummaryLine() {
|
|
462
|
+
if (!this.discovery.hasAnyConfig) {
|
|
463
|
+
return fg(this.t.warning, this.options.onboardingState.setupCompleted
|
|
464
|
+
? "No MCP servers are active right now."
|
|
465
|
+
: "No MCP config is active yet.");
|
|
466
|
+
}
|
|
467
|
+
if (this.discovery.totalServerCount === 0 &&
|
|
468
|
+
(this.discovery.imports.length > 0 || !!this.discovery.repoPrompt.executablePath)) {
|
|
469
|
+
return fg(this.t.warning, "Nexus found MCP-related setup options, but none are active in Nexus yet.");
|
|
470
|
+
}
|
|
471
|
+
const configuredSources = this.discovery.sources.filter((source) => source.serverCount > 0).length;
|
|
472
|
+
return fg(this.t.hint, `Detected ${this.discovery.totalServerCount} configured servers across ${configuredSources} Nexus source${configuredSources === 1 ? "" : "s"}.`);
|
|
473
|
+
}
|
|
474
|
+
secondarySummaryLine() {
|
|
475
|
+
const hostNote = this.discovery.hostConfigs.length > 0
|
|
476
|
+
? ` Host discovery is ${this.discovery.hostConfigDiscovery}; ${this.discovery.hostConfigs.length} host source${this.discovery.hostConfigs.length === 1 ? "" : "s"} detected.`
|
|
477
|
+
: "";
|
|
478
|
+
const conflictNote = this.discovery.conflicts.length > 0
|
|
479
|
+
? ` ${this.discovery.conflicts.length} same-name conflict${this.discovery.conflicts.length === 1 ? "" : "s"} reported.`
|
|
480
|
+
: "";
|
|
481
|
+
if (!this.discovery.hasAnyConfig) {
|
|
482
|
+
return `Create .nexus/mcp.json, adopt host imports, or quick-add RepoPrompt from this screen.${hostNote}${conflictNote}`;
|
|
483
|
+
}
|
|
484
|
+
if (this.discovery.totalServerCount === 0 && this.discovery.imports.length > 0) {
|
|
485
|
+
return `Detected ${this.discovery.imports.length} compatibility import source${this.discovery.imports.length === 1 ? "" : "s"}. Adopt them into Nexus or inspect the underlying files.${hostNote}${conflictNote}`;
|
|
486
|
+
}
|
|
487
|
+
return `Nexus MCP files contain server definitions, compatibility imports, and MCP-specific overrides.${hostNote}${conflictNote}`;
|
|
488
|
+
}
|
|
489
|
+
visibleActionRange(total) {
|
|
490
|
+
if (total <= COMPACT_ACTION_ROWS)
|
|
491
|
+
return { start: 0, end: total };
|
|
492
|
+
const half = Math.floor(COMPACT_ACTION_ROWS / 2);
|
|
493
|
+
const start = Math.min(Math.max(0, this.actionCursor - half), Math.max(0, total - COMPACT_ACTION_ROWS));
|
|
494
|
+
return { start, end: Math.min(total, start + COMPACT_ACTION_ROWS) };
|
|
495
|
+
}
|
|
496
|
+
contentWidth(innerW) {
|
|
497
|
+
return Math.max(8, innerW - 4);
|
|
498
|
+
}
|
|
499
|
+
previewWidth(innerW) {
|
|
500
|
+
return Math.max(12, Math.min(DESKTOP_PREVIEW_WIDTH, this.contentWidth(innerW)));
|
|
501
|
+
}
|
|
502
|
+
getActionPreview(action, previewW = DESKTOP_PREVIEW_WIDTH) {
|
|
503
|
+
switch (action?.id) {
|
|
504
|
+
case "run-setup":
|
|
505
|
+
return this.formatPreview([
|
|
506
|
+
"Run setup to adopt host-specific imports, inspect detected paths, and scaffold a minimal `.nexus/mcp.json` if needed.",
|
|
507
|
+
], previewW);
|
|
508
|
+
case "adopt-imports":
|
|
509
|
+
return this.formatWritePreview("Compatibility import write preview", this.callbacks.previewImports(this.discovery.imports
|
|
510
|
+
.filter((entry) => this.selectedImports.has(entry.kind))
|
|
511
|
+
.map((entry) => entry.kind)), [
|
|
512
|
+
`Detected imports: ${this.discovery.imports.map((entry) => `${entry.kind} (${entry.serverCount} servers)`).join(", ")}`,
|
|
513
|
+
"Selected imports are written to the Nexus global MCP configuration shown above.",
|
|
514
|
+
], previewW);
|
|
515
|
+
case "view-example":
|
|
516
|
+
return this.formatPreview([
|
|
517
|
+
"Example Nexus `.nexus/mcp.json`:",
|
|
518
|
+
"{",
|
|
519
|
+
' "mcpServers": {',
|
|
520
|
+
' "chrome-devtools": {',
|
|
521
|
+
' "command": "npx",',
|
|
522
|
+
' "args": ["-y", "chrome-devtools-mcp@1.6.0"]',
|
|
523
|
+
" }",
|
|
524
|
+
" }",
|
|
525
|
+
"}",
|
|
526
|
+
"",
|
|
527
|
+
"Use Scaffold project `.nexus/mcp.json` when you want a safe empty shell instead of a live example server.",
|
|
528
|
+
], previewW);
|
|
529
|
+
case "show-precedence":
|
|
530
|
+
return this.formatPreview([
|
|
531
|
+
"Read order (later entries win):",
|
|
532
|
+
"0. detected host configs (opt-in lowest-precedence fallback)",
|
|
533
|
+
"1. ~/.config/nexus/mcp.json",
|
|
534
|
+
`2. ${getConfigDirName()}/mcp.json`,
|
|
535
|
+
`Host discovery: ${this.discovery.hostConfigDiscovery}. Conflicts reported: ${this.discovery.conflicts.length}.`,
|
|
536
|
+
...this.discovery.conflicts
|
|
537
|
+
.slice(0, 8)
|
|
538
|
+
.map((conflict) => `${conflict.serverName}: ${conflict.sources.map((source) => source.path).join(" -> ")} (winner: ${conflict.winner.path})`),
|
|
539
|
+
"Nexus writes global MCP state to ~/.config/nexus/mcp.json and project state to .nexus/mcp.json.",
|
|
540
|
+
], previewW);
|
|
541
|
+
case "open-paths":
|
|
542
|
+
return this.formatPreview(this.getDetectedPaths().length > 0
|
|
543
|
+
? ["Detected paths:", ...this.getDetectedPaths()]
|
|
544
|
+
: ["No config paths were detected."], previewW);
|
|
545
|
+
case "add-repoprompt": {
|
|
546
|
+
const repoPrompt = this.discovery.repoPrompt;
|
|
547
|
+
const preview = this.callbacks.previewRepoPrompt();
|
|
548
|
+
if (!preview) {
|
|
549
|
+
return this.formatPreview(["RepoPrompt is not available to add from this setup screen."], previewW);
|
|
550
|
+
}
|
|
551
|
+
return this.formatWritePreview("RepoPrompt write preview", preview, [
|
|
552
|
+
`Executable: ${repoPrompt.executablePath ?? "not found"}`,
|
|
553
|
+
`Target: ${repoPrompt.targetPath ?? "n/a"}`,
|
|
554
|
+
`Server name: ${repoPrompt.serverName ?? "repoprompt"}`,
|
|
555
|
+
], previewW);
|
|
556
|
+
}
|
|
557
|
+
case "add-known-server": {
|
|
558
|
+
const preset = action.preset;
|
|
559
|
+
if (!preset)
|
|
560
|
+
return this.formatPreview(["Known server preset is unavailable."], previewW);
|
|
561
|
+
return this.formatWritePreview(`${preset.name} write preview`, this.callbacks.previewKnownServer(preset), [preset.summary], previewW);
|
|
562
|
+
}
|
|
563
|
+
case "scaffold-project":
|
|
564
|
+
return this.formatWritePreview("Starter project `.nexus/mcp.json` write preview", this.callbacks.previewStarterProject(), [
|
|
565
|
+
"This writes a minimal `.nexus/mcp.json` in the current project using the Nexus MCP layout.",
|
|
566
|
+
"It intentionally avoids adding a fake placeholder server that would fail on first reload.",
|
|
567
|
+
], previewW);
|
|
568
|
+
default:
|
|
569
|
+
return this.formatPreview(["Close the setup flow."], previewW);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
formatPreview(lines, width = DESKTOP_PREVIEW_WIDTH) {
|
|
573
|
+
const preview = [];
|
|
574
|
+
for (const line of lines) {
|
|
575
|
+
preview.push(...wrapText(line, width));
|
|
576
|
+
}
|
|
577
|
+
return preview;
|
|
578
|
+
}
|
|
579
|
+
formatWritePreview(title, preview, intro = [], width = DESKTOP_PREVIEW_WIDTH) {
|
|
580
|
+
const lines = [];
|
|
581
|
+
for (const line of intro) {
|
|
582
|
+
lines.push(...wrapText(line, width));
|
|
583
|
+
}
|
|
584
|
+
if (intro.length > 0)
|
|
585
|
+
lines.push("");
|
|
586
|
+
lines.push(...wrapText(`${title}: ${preview.path}`, width));
|
|
587
|
+
lines.push(...wrapText(preview.existed
|
|
588
|
+
? "Existing file detected. Showing exact before/after diff."
|
|
589
|
+
: "New file will be created. Showing exact content diff.", width));
|
|
590
|
+
lines.push("");
|
|
591
|
+
const diffLines = preview.diffText.split("\n");
|
|
592
|
+
const maxLines = 18;
|
|
593
|
+
const shown = diffLines.slice(0, maxLines);
|
|
594
|
+
for (const line of shown) {
|
|
595
|
+
lines.push(...wrapText(line, width));
|
|
596
|
+
}
|
|
597
|
+
if (diffLines.length > maxLines) {
|
|
598
|
+
lines.push(...wrapText(`… ${diffLines.length - maxLines} more diff line${diffLines.length - maxLines === 1 ? "" : "s"}`, width));
|
|
599
|
+
}
|
|
600
|
+
return lines;
|
|
601
|
+
}
|
|
602
|
+
padLine(text, innerW) {
|
|
603
|
+
const inset = 2;
|
|
604
|
+
const contentW = Math.max(0, innerW - inset * 2);
|
|
605
|
+
const fitted = truncateToWidth(text, contentW, "…", true);
|
|
606
|
+
const plainWidth = visibleWidth(fitted);
|
|
607
|
+
const padding = Math.max(0, contentW - plainWidth);
|
|
608
|
+
return `│${" ".repeat(inset)}${fitted}${" ".repeat(padding)}${" ".repeat(inset)}│`;
|
|
609
|
+
}
|
|
610
|
+
invalidate() { }
|
|
611
|
+
dispose() {
|
|
612
|
+
this.cleanup();
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
export function createMcpSetupPanel(discovery, callbacks, options, tui, done) {
|
|
616
|
+
return new McpSetupPanel(discovery, callbacks, options, tui, done);
|
|
617
|
+
}
|
|
618
|
+
//# sourceMappingURL=mcp-setup-panel.js.map
|