0.1.0 完成 vscode 插件端的改造
This commit is contained in:
parent
df8b4df2c0
commit
b853118fa0
@ -48,11 +48,11 @@ onMounted(async () => {
|
||||
pinkLog('OpenMCP Client 启动');
|
||||
|
||||
// 跳转到首页
|
||||
// if (route.name !== 'debug') {
|
||||
// const targetRoute = import.meta.env.BASE_URL + 'debug';
|
||||
// console.log('go to ' + targetRoute);
|
||||
// router.push(targetRoute);
|
||||
// }
|
||||
if (route.name !== 'debug') {
|
||||
const targetRoute = import.meta.env.BASE_URL + 'debug';
|
||||
console.log('go to ' + targetRoute);
|
||||
router.push(targetRoute);
|
||||
}
|
||||
|
||||
// 进行桥接
|
||||
await bridge.awaitForWebsocket();
|
||||
|
@ -58,7 +58,7 @@
|
||||
</el-tour-step>
|
||||
|
||||
<el-tour-step
|
||||
:target="client.connectionSettingRef"
|
||||
:target="mcpClientAdapter.clients[0].connectionSettingRef"
|
||||
:prev-button-props="{ children: '上一步' }"
|
||||
:next-button-props="{ children: '下一步' }"
|
||||
:show-close="false"
|
||||
@ -78,7 +78,7 @@
|
||||
</el-tour-step>
|
||||
|
||||
<el-tour-step
|
||||
:target="client.connectionLogRef"
|
||||
:target="mcpClientAdapter.clients[0].connectionLogRef"
|
||||
:prev-button-props="{ children: '上一步' }"
|
||||
:next-button-props="{ children: '下一步' }"
|
||||
:show-close="false"
|
||||
@ -92,6 +92,20 @@
|
||||
</div>
|
||||
</el-tour-step>
|
||||
|
||||
<el-tour-step
|
||||
:target="mcpServerAddRef"
|
||||
:prev-button-props="{ children: '上一步' }"
|
||||
:next-button-props="{ children: '下一步' }"
|
||||
:show-close="false"
|
||||
>
|
||||
<template #header>
|
||||
<TourTitle>调试</TourTitle>
|
||||
</template>
|
||||
<div class="tour-common-text">
|
||||
你可以点击最右侧的加号来添加额外的 mcp 服务器,让你当前正在调试的 agent 零成本快速获得额外的能力。
|
||||
</div>
|
||||
</el-tour-step>
|
||||
|
||||
<el-tour-step
|
||||
target="#sidebar-debug"
|
||||
:prev-button-props="{ children: '上一步' }"
|
||||
@ -253,13 +267,13 @@ import { llmSettingRef } from '@/views/setting/api';
|
||||
import { userHasReadGuide } from './tour';
|
||||
import { setTour } from '@/hook/setting';
|
||||
import { mcpClientAdapter } from '@/views/connect/core';
|
||||
import { mcpServerAddRef } from '@/views/connect';
|
||||
|
||||
const openTour = ref(true);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const router = useRouter();
|
||||
const client = mcpClientAdapter.masterNode;
|
||||
|
||||
const baseUrl = import.meta.env.BASE_URL;
|
||||
|
||||
|
@ -32,7 +32,7 @@ export async function getTour() {
|
||||
const { code, msg } = await bridge.commandRequest('setting/get-tour');
|
||||
|
||||
if (code === 200) {
|
||||
pinkLog('获取引导状态成功');
|
||||
pinkLog('获取引导状态成功 ' + msg.userHasReadGuide);
|
||||
userHasReadGuide.value = msg.userHasReadGuide || false;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ import { ElLoading } from "element-plus";
|
||||
import { pinkLog } from "../setting/util";
|
||||
import { mcpClientAdapter } from "./core";
|
||||
import { isConnecting } from "@/components/sidebar/connected";
|
||||
import { ref } from "vue";
|
||||
|
||||
export const mcpServerAddRef = ref<any>(null);
|
||||
|
||||
export async function initialise() {
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<div class="connection-container-wrapper">
|
||||
<div class="server-list">
|
||||
<div class="server-list"
|
||||
:ref="el => mcpServerAddRef = el"
|
||||
>
|
||||
<el-segmented
|
||||
v-model="mcpClientAdapter.currentClientIndex"
|
||||
:options="serverOptions"
|
||||
@ -47,6 +49,7 @@ import { defineComponent, computed } from 'vue';
|
||||
import ConnectionPanel from './connection-panel.vue';
|
||||
import { McpClient, mcpClientAdapter } from './core';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { mcpServerAddRef } from '.';
|
||||
|
||||
defineComponent({ name: 'connection' });
|
||||
|
||||
|
@ -175,7 +175,7 @@ async function initNpm(option: McpOptions, cwd: string, webview?: PostMessageble
|
||||
let projectDir = cwd;
|
||||
|
||||
while (projectDir !== path.dirname(projectDir)) {
|
||||
if (fs.readFileSync(projectDir).includes('package.json')) {
|
||||
if (fs.readdirSync(projectDir).includes('package.json')) {
|
||||
break;
|
||||
}
|
||||
projectDir = path.dirname(projectDir);
|
||||
|
@ -34,6 +34,8 @@ export class McpInstalledConnectProvider implements vscode.TreeDataProvider<Conn
|
||||
@RegisterCommand('revealWebviewPanel')
|
||||
public revealWebviewPanel(context: vscode.ExtensionContext, view: ConnectionViewItem) {
|
||||
const item = view.item;
|
||||
console.log(item);
|
||||
|
||||
const masterNode = Array.isArray(item)? item[0] : item;
|
||||
const name = masterNode.filePath || masterNode.name || '';
|
||||
revealOpenMcpWebviewPanel(context, 'installed', name, item);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
import * as fspath from 'path';
|
||||
import { McpOptions, panels, updateInstalledConnectionConfig, updateWorkspaceConnectionConfig } from '../global';
|
||||
import { ConnectionType, McpOptions, panels, updateInstalledConnectionConfig, updateWorkspaceConnectionConfig } from '../global';
|
||||
import { routeMessage } from '../../openmcp-sdk/service';
|
||||
|
||||
export function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined {
|
||||
@ -43,6 +43,17 @@ export function revealOpenMcpWebviewPanel(
|
||||
return panel;
|
||||
}
|
||||
|
||||
// 对老版本的 option 进行调整
|
||||
option = Array.isArray(option)? option : [option];
|
||||
option.forEach(item => {
|
||||
const itemType = (item.type || item.connectionType).toUpperCase() as ConnectionType;
|
||||
item.type = undefined;
|
||||
item.connectionType = itemType;
|
||||
if (itemType === 'STDIO') {
|
||||
item.commandString = [item.command, ...(item.args || [])]?.join(' ');
|
||||
}
|
||||
})
|
||||
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
'OpenMCP',
|
||||
'OpenMCP',
|
||||
|
Loading…
x
Reference in New Issue
Block a user