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