@weapp-vite/mcp 1.5.8 → 2.1.0
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/README.md +2 -0
- package/dist/index.d.ts +234 -202
- package/dist/index.mjs +2502 -2436
- package/package.json +21 -11
- package/dist/index.d.mts +0 -222
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/mcp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "@weapp-vite/mcp tools and runtime components for modern WeChat and multi-platform mini-program development.",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "ISC",
|
|
@@ -37,29 +37,39 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"engines": {
|
|
40
|
-
"node": "
|
|
40
|
+
"node": ">=22.12.0"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public",
|
|
44
44
|
"registry": "https://registry.npmjs.org"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@modelcontextprotocol/node": "^2.1.
|
|
48
|
-
"@modelcontextprotocol/server": "^2.
|
|
49
|
-
"@weapp-
|
|
50
|
-
"
|
|
47
|
+
"@modelcontextprotocol/node": "^2.1.1",
|
|
48
|
+
"@modelcontextprotocol/server": "^2.3.1",
|
|
49
|
+
"@weapp-core/constants": "0.4.0",
|
|
50
|
+
"@weapp-vite/acceptance": "0.1.1",
|
|
51
|
+
"@weapp-vite/devtools-runtime": "0.6.0",
|
|
52
|
+
"weapp-ide-cli": "6.3.0",
|
|
53
|
+
"zod": "^4.6.7"
|
|
54
|
+
},
|
|
55
|
+
"tsd": {
|
|
56
|
+
"compilerOptions": {
|
|
57
|
+
"module": "NodeNext",
|
|
58
|
+
"moduleResolution": "NodeNext"
|
|
59
|
+
}
|
|
51
60
|
},
|
|
52
61
|
"devDependencies": {
|
|
53
|
-
"@modelcontextprotocol/client": "^2.
|
|
62
|
+
"@modelcontextprotocol/client": "^2.3.1"
|
|
54
63
|
},
|
|
55
64
|
"scripts": {
|
|
56
|
-
"dev": "
|
|
57
|
-
"build:watch": "
|
|
58
|
-
"build": "
|
|
65
|
+
"dev": "tsdown -w --sourcemap",
|
|
66
|
+
"build:watch": "tsdown -w --sourcemap",
|
|
67
|
+
"build": "tsdown",
|
|
59
68
|
"test": "vitest run",
|
|
60
69
|
"test:dev": "vitest",
|
|
61
70
|
"pretest:types": "pnpm build",
|
|
62
|
-
"test:types": "
|
|
71
|
+
"test:types": "pnpm run test:types:check",
|
|
72
|
+
"test:types:check": "tsd",
|
|
63
73
|
"typecheck": "tsc --noEmit",
|
|
64
74
|
"release": "pnpm publish",
|
|
65
75
|
"lint": "eslint .",
|
package/dist/index.d.mts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { DevtoolsRuntimeHooks } from '@weapp-vite/devtools-runtime';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/server';
|
|
3
|
-
|
|
4
|
-
declare const MCP_SERVER_NAME = "@weapp-vite/mcp";
|
|
5
|
-
declare const MCP_SERVER_VERSION = "2.0.0";
|
|
6
|
-
declare const EXPOSED_PACKAGES: {
|
|
7
|
-
readonly 'weapp-vite': {
|
|
8
|
-
readonly id: "weapp-vite";
|
|
9
|
-
readonly label: "weapp-vite";
|
|
10
|
-
readonly packageName: "weapp-vite";
|
|
11
|
-
readonly relativePath: string;
|
|
12
|
-
};
|
|
13
|
-
readonly wevu: {
|
|
14
|
-
readonly id: "wevu";
|
|
15
|
-
readonly label: "wevu";
|
|
16
|
-
readonly packageName: "wevu";
|
|
17
|
-
readonly relativePath: string;
|
|
18
|
-
};
|
|
19
|
-
readonly 'wevu-compiler': {
|
|
20
|
-
readonly id: "wevu-compiler";
|
|
21
|
-
readonly label: "wevu-compiler";
|
|
22
|
-
readonly packageName: "@wevu/compiler";
|
|
23
|
-
readonly relativePath: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
type ExposedPackageId = keyof typeof EXPOSED_PACKAGES;
|
|
27
|
-
declare const DEFAULT_TIMEOUT_MS = 120000;
|
|
28
|
-
declare const DEFAULT_MAX_OUTPUT_CHARS = 120000;
|
|
29
|
-
declare const DEFAULT_MAX_FILE_CHARS = 80000;
|
|
30
|
-
declare const DEFAULT_MAX_RESULTS = 200;
|
|
31
|
-
declare const SKIPPED_DIR_NAMES: Set<string>;
|
|
32
|
-
|
|
33
|
-
interface ResolvedExposedPackage {
|
|
34
|
-
id: ExposedPackageId;
|
|
35
|
-
label: string;
|
|
36
|
-
packageName: string;
|
|
37
|
-
version: string;
|
|
38
|
-
absolutePath: string;
|
|
39
|
-
relativePath: string;
|
|
40
|
-
scripts: string[];
|
|
41
|
-
docs: {
|
|
42
|
-
readme?: string;
|
|
43
|
-
changelog?: string;
|
|
44
|
-
};
|
|
45
|
-
sourceRoot?: string;
|
|
46
|
-
cliPath?: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface ExposedPackageSummary extends ResolvedExposedPackage {
|
|
50
|
-
}
|
|
51
|
-
declare function loadPackageSummary(workspaceRoot: string, id: ExposedPackageId): Promise<ExposedPackageSummary>;
|
|
52
|
-
declare function loadExposedCatalog(workspaceRoot: string): Promise<ResolvedExposedPackage[]>;
|
|
53
|
-
|
|
54
|
-
interface CommandResult {
|
|
55
|
-
command: string;
|
|
56
|
-
args: string[];
|
|
57
|
-
cwd: string;
|
|
58
|
-
exitCode: number;
|
|
59
|
-
stdout: string;
|
|
60
|
-
stderr: string;
|
|
61
|
-
timedOut: boolean;
|
|
62
|
-
}
|
|
63
|
-
declare function runCommand(workspaceRoot: string, command: string, args: string[], options?: {
|
|
64
|
-
cwdRelative?: string;
|
|
65
|
-
timeoutMs?: number;
|
|
66
|
-
maxOutputChars?: number;
|
|
67
|
-
}): Promise<CommandResult>;
|
|
68
|
-
|
|
69
|
-
interface SearchMatch {
|
|
70
|
-
filePath: string;
|
|
71
|
-
line: number;
|
|
72
|
-
column: number;
|
|
73
|
-
text: string;
|
|
74
|
-
}
|
|
75
|
-
declare function listFilesInDirectory(root: string, relativeDirectory?: string, maxResults?: number): Promise<string[]>;
|
|
76
|
-
declare function readFileContent(root: string, relativeFilePath: string, options?: {
|
|
77
|
-
startLine?: number;
|
|
78
|
-
endLine?: number;
|
|
79
|
-
maxChars?: number;
|
|
80
|
-
}): Promise<{
|
|
81
|
-
filePath: string;
|
|
82
|
-
content: string;
|
|
83
|
-
}>;
|
|
84
|
-
declare function searchTextInDirectory(root: string, query: string, options?: {
|
|
85
|
-
relativeDirectory?: string;
|
|
86
|
-
maxResults?: number;
|
|
87
|
-
}): Promise<SearchMatch[]>;
|
|
88
|
-
|
|
89
|
-
interface MiniProgramElement {
|
|
90
|
-
tagName?: string;
|
|
91
|
-
$?: (selector: string) => Promise<MiniProgramElement | null>;
|
|
92
|
-
$$?: (selector: string) => Promise<MiniProgramElement[]>;
|
|
93
|
-
tap: () => Promise<void>;
|
|
94
|
-
}
|
|
95
|
-
interface MiniProgramPage {
|
|
96
|
-
path: string;
|
|
97
|
-
query?: unknown;
|
|
98
|
-
$: (selector: string, options?: MiniProgramPageQueryOptions) => Promise<MiniProgramElement | null>;
|
|
99
|
-
$$?: (selector: string, options?: MiniProgramPageQueryOptions) => Promise<MiniProgramElement[]>;
|
|
100
|
-
data: (path?: string) => Promise<unknown>;
|
|
101
|
-
size: () => Promise<unknown>;
|
|
102
|
-
scrollTop: () => Promise<unknown>;
|
|
103
|
-
waitFor: (milliseconds: number) => Promise<void>;
|
|
104
|
-
}
|
|
105
|
-
interface MiniProgramPageQueryOptions {
|
|
106
|
-
fallback?: boolean;
|
|
107
|
-
}
|
|
108
|
-
interface MiniProgramLike {
|
|
109
|
-
on: (name: 'console' | 'exception', handler: (payload: unknown) => void) => void;
|
|
110
|
-
off?: (name: 'console' | 'exception', handler: (payload: unknown) => void) => void;
|
|
111
|
-
currentPage: () => Promise<MiniProgramPage>;
|
|
112
|
-
systemInfo: () => Promise<unknown>;
|
|
113
|
-
pageStack: () => Promise<MiniProgramPage[]>;
|
|
114
|
-
navigateTo: (url: string) => Promise<MiniProgramPage>;
|
|
115
|
-
redirectTo: (url: string) => Promise<MiniProgramPage>;
|
|
116
|
-
reLaunch: (url: string) => Promise<MiniProgramPage>;
|
|
117
|
-
switchTab: (url: string) => Promise<MiniProgramPage>;
|
|
118
|
-
navigateBack: () => Promise<MiniProgramPage>;
|
|
119
|
-
screenshot: (options?: {
|
|
120
|
-
timeout?: number;
|
|
121
|
-
}) => Promise<string | Uint8Array | undefined>;
|
|
122
|
-
callWxMethod: (method: string, ...args: unknown[]) => Promise<unknown>;
|
|
123
|
-
}
|
|
124
|
-
interface RuntimeConnectionInput {
|
|
125
|
-
projectPath: string;
|
|
126
|
-
timeout?: number;
|
|
127
|
-
port?: number;
|
|
128
|
-
preferOpenedSession?: boolean;
|
|
129
|
-
preserveProjectRoot?: boolean;
|
|
130
|
-
sessionId?: string;
|
|
131
|
-
}
|
|
132
|
-
interface RuntimeConsoleLogEntry {
|
|
133
|
-
level: string;
|
|
134
|
-
message: string;
|
|
135
|
-
timestamp: number;
|
|
136
|
-
raw: unknown;
|
|
137
|
-
}
|
|
138
|
-
declare class RuntimeSessionManager {
|
|
139
|
-
private readonly workspaceRoot;
|
|
140
|
-
private readonly runtimeHooks;
|
|
141
|
-
private readonly logs;
|
|
142
|
-
private readonly attachedSessions;
|
|
143
|
-
private readonly maxLogs;
|
|
144
|
-
constructor(workspaceRoot: string, runtimeHooks?: DevtoolsRuntimeHooks);
|
|
145
|
-
close(input: RuntimeConnectionInput): Promise<void>;
|
|
146
|
-
clearLogs(): void;
|
|
147
|
-
getLogs(): RuntimeConsoleLogEntry[];
|
|
148
|
-
resolveProjectPath(projectPath: string): string;
|
|
149
|
-
resolveWorkspacePath(filePath: string): string;
|
|
150
|
-
withMiniProgram<T>(input: RuntimeConnectionInput, runner: (miniProgram: MiniProgramLike) => Promise<T>): Promise<T>;
|
|
151
|
-
withPage<T>(input: RuntimeConnectionInput, runner: (page: MiniProgramPage, miniProgram: MiniProgramLike) => Promise<T>): Promise<T>;
|
|
152
|
-
rememberPage(input: RuntimeConnectionInput, page: MiniProgramPage | null | undefined): void;
|
|
153
|
-
private resolveSessionKey;
|
|
154
|
-
private attach;
|
|
155
|
-
private resolveCurrentPage;
|
|
156
|
-
private detach;
|
|
157
|
-
private pushLog;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
interface CreateServerOptions {
|
|
161
|
-
runtimeHooks?: DevtoolsRuntimeHooks;
|
|
162
|
-
workspaceRoot?: string;
|
|
163
|
-
}
|
|
164
|
-
interface WeappViteMcpServerFactory {
|
|
165
|
-
createServer: () => McpServer;
|
|
166
|
-
runtimeManager: RuntimeSessionManager;
|
|
167
|
-
workspaceRoot: string;
|
|
168
|
-
}
|
|
169
|
-
declare function createWeappViteMcpServerFactory(options?: CreateServerOptions): Promise<WeappViteMcpServerFactory>;
|
|
170
|
-
declare function createWeappViteMcpServer(options?: CreateServerOptions): Promise<{
|
|
171
|
-
runtimeManager: RuntimeSessionManager;
|
|
172
|
-
server: McpServer;
|
|
173
|
-
workspaceRoot: string;
|
|
174
|
-
}>;
|
|
175
|
-
|
|
176
|
-
declare const DEFAULT_RUNTIME_REST_ENDPOINT = "/api/weapp/devtools";
|
|
177
|
-
|
|
178
|
-
declare const DEFAULT_MCP_HOST = "127.0.0.1";
|
|
179
|
-
declare const DEFAULT_MCP_PORT = 3088;
|
|
180
|
-
declare const DEFAULT_MCP_ENDPOINT = "/mcp";
|
|
181
|
-
interface StartMcpServerOptions extends CreateServerOptions {
|
|
182
|
-
transport?: 'stdio' | 'streamable-http';
|
|
183
|
-
host?: string;
|
|
184
|
-
port?: number;
|
|
185
|
-
endpoint?: string;
|
|
186
|
-
restEndpoint?: string | false;
|
|
187
|
-
unref?: boolean;
|
|
188
|
-
quiet?: boolean;
|
|
189
|
-
onReady?: (message: string) => void;
|
|
190
|
-
}
|
|
191
|
-
interface McpServerHandle {
|
|
192
|
-
transport: 'stdio' | 'streamable-http';
|
|
193
|
-
close?: () => Promise<void>;
|
|
194
|
-
}
|
|
195
|
-
declare function startStdioServer(options?: CreateServerOptions): Promise<McpServerHandle>;
|
|
196
|
-
declare function startWeappViteMcpServer(options?: StartMcpServerOptions): Promise<McpServerHandle>;
|
|
197
|
-
|
|
198
|
-
declare function formatJson(value: unknown): string;
|
|
199
|
-
declare function normalizeErrorMessage(error: unknown): string;
|
|
200
|
-
declare function toToolResult(data: unknown, text?: string): {
|
|
201
|
-
content: {
|
|
202
|
-
type: "text";
|
|
203
|
-
text: string;
|
|
204
|
-
}[];
|
|
205
|
-
structuredContent: {
|
|
206
|
-
result: unknown;
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
declare function toToolError(error: unknown): {
|
|
210
|
-
isError: boolean;
|
|
211
|
-
content: {
|
|
212
|
-
type: "text";
|
|
213
|
-
text: string;
|
|
214
|
-
}[];
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
declare function resolveWorkspaceRoot(start?: string): string;
|
|
218
|
-
declare function assertInsideRoot(root: string, targetPath: string): string;
|
|
219
|
-
declare function resolveSubPath(root: string, relativePath: string): string;
|
|
220
|
-
|
|
221
|
-
export { DEFAULT_MAX_FILE_CHARS, DEFAULT_MAX_OUTPUT_CHARS, DEFAULT_MAX_RESULTS, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, DEFAULT_TIMEOUT_MS, EXPOSED_PACKAGES, MCP_SERVER_NAME, MCP_SERVER_VERSION, SKIPPED_DIR_NAMES, assertInsideRoot, createWeappViteMcpServer, createWeappViteMcpServerFactory, formatJson, listFilesInDirectory, loadExposedCatalog, loadPackageSummary, normalizeErrorMessage, readFileContent, resolveSubPath, resolveWorkspaceRoot, runCommand, searchTextInDirectory, startStdioServer, startWeappViteMcpServer, toToolError, toToolResult };
|
|
222
|
-
export type { CommandResult, CreateServerOptions, ExposedPackageId, ExposedPackageSummary, McpServerHandle, SearchMatch, StartMcpServerOptions, WeappViteMcpServerFactory };
|