unplugin-devpilot 0.0.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/LICENSE +21 -0
- package/dist/client/index.d.mts +62 -0
- package/dist/client/index.mjs +146 -0
- package/dist/client/virtual.d.ts +6 -0
- package/dist/farm.d.mts +19 -0
- package/dist/farm.mjs +26 -0
- package/dist/index-CL0Gw5-1.d.mts +4130 -0
- package/dist/index-CyKvTBcJ.d.mts +228 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +4 -0
- package/dist/plugin-PB-j5Ck2.mjs +36 -0
- package/dist/plugin.d.mts +2 -0
- package/dist/plugin.mjs +3 -0
- package/dist/rspack.d.mts +19 -0
- package/dist/rspack.mjs +26 -0
- package/dist/src-aMXlip6o.mjs +24085 -0
- package/dist/vite.d.mts +19 -0
- package/dist/vite.mjs +26 -0
- package/dist/webpack.d.mts +19 -0
- package/dist/webpack.mjs +26 -0
- package/package.json +76 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { r as McpToolRegister, t as DevpilotPluginContext } from "./index-CL0Gw5-1.mjs";
|
|
2
|
+
import { UnpluginInstance } from "unplugin";
|
|
3
|
+
import { WebSocket } from "ws";
|
|
4
|
+
|
|
5
|
+
//#region src/core/options.d.ts
|
|
6
|
+
interface DevpilotPlugin {
|
|
7
|
+
namespace: string;
|
|
8
|
+
/**
|
|
9
|
+
* The client module path to be injected
|
|
10
|
+
* - npm package path: 'my-plugin/client'
|
|
11
|
+
* - absolute path: '/path/to/client.ts'
|
|
12
|
+
*
|
|
13
|
+
* Note: relative paths need to be resolved to absolute paths first
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { resolveClientModule } from 'unplugin-devpilot'
|
|
17
|
+
*
|
|
18
|
+
* clientModule: resolveClientModule(import.meta.url, './client.ts')
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
clientModule?: string | ((ctx: DevpilotPluginContext) => string);
|
|
22
|
+
/**
|
|
23
|
+
* Setup server-side RPC methods for this plugin
|
|
24
|
+
* These methods can be called from the client via rpcCall()
|
|
25
|
+
*/
|
|
26
|
+
serverSetup?: (ctx: DevpilotPluginContext) => Record<string, (...args: any[]) => any>;
|
|
27
|
+
mcpSetup?: (ctx: DevpilotPluginContext) => Array<McpToolRegister>;
|
|
28
|
+
}
|
|
29
|
+
interface Options {
|
|
30
|
+
wsPort?: number;
|
|
31
|
+
mcpPort?: number;
|
|
32
|
+
plugins?: DevpilotPlugin[];
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region ../../node_modules/.pnpm/birpc@4.0.0/node_modules/birpc/dist/index.d.mts
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/utils.d.ts
|
|
38
|
+
type ArgumentsType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
39
|
+
type ReturnType<T> = T extends ((...args: any) => infer R) ? R : never;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/main.d.ts
|
|
42
|
+
type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
43
|
+
type BirpcFn<T> = PromisifyFn<T> & {
|
|
44
|
+
/**
|
|
45
|
+
* Send event without asking for response
|
|
46
|
+
*/
|
|
47
|
+
asEvent: (...args: ArgumentsType<T>) => Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
interface BirpcReturnBuiltin<RemoteFunctions, LocalFunctions = Record<string, unknown>> {
|
|
50
|
+
/**
|
|
51
|
+
* Raw functions object
|
|
52
|
+
*/
|
|
53
|
+
$functions: LocalFunctions;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the RPC is closed
|
|
56
|
+
*/
|
|
57
|
+
readonly $closed: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Custom meta data attached to the RPC instance
|
|
60
|
+
*/
|
|
61
|
+
readonly $meta: any;
|
|
62
|
+
/**
|
|
63
|
+
* Close the RPC connection
|
|
64
|
+
*/
|
|
65
|
+
$close: (error?: Error) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Reject pending calls
|
|
68
|
+
*/
|
|
69
|
+
$rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
|
|
70
|
+
/**
|
|
71
|
+
* Call the remote function and wait for the result.
|
|
72
|
+
* An alternative to directly calling the function
|
|
73
|
+
*/
|
|
74
|
+
$call: <K$1 extends keyof RemoteFunctions>(method: K$1, ...args: ArgumentsType<RemoteFunctions[K$1]>) => Promise<Awaited<ReturnType<RemoteFunctions[K$1]>>>;
|
|
75
|
+
/**
|
|
76
|
+
* Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
|
|
77
|
+
*/
|
|
78
|
+
$callOptional: <K$1 extends keyof RemoteFunctions>(method: K$1, ...args: ArgumentsType<RemoteFunctions[K$1]>) => Promise<Awaited<ReturnType<RemoteFunctions[K$1]> | undefined>>;
|
|
79
|
+
/**
|
|
80
|
+
* Send event without asking for response
|
|
81
|
+
*/
|
|
82
|
+
$callEvent: <K$1 extends keyof RemoteFunctions>(method: K$1, ...args: ArgumentsType<RemoteFunctions[K$1]>) => Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Call the remote function with the raw options.
|
|
85
|
+
*/
|
|
86
|
+
$callRaw: (options: {
|
|
87
|
+
method: string;
|
|
88
|
+
args: unknown[];
|
|
89
|
+
event?: boolean;
|
|
90
|
+
optional?: boolean;
|
|
91
|
+
}) => Promise<Awaited<ReturnType<any>>[]>;
|
|
92
|
+
}
|
|
93
|
+
type ProxifiedRemoteFunctions<RemoteFunctions extends object = Record<string, unknown>> = { [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]> };
|
|
94
|
+
type BirpcReturn<RemoteFunctions extends object = Record<string, unknown>, LocalFunctions extends object = Record<string, unknown>, Proxify extends boolean = true> = Proxify extends true ? ProxifiedRemoteFunctions<RemoteFunctions> & BirpcReturnBuiltin<RemoteFunctions, LocalFunctions> : BirpcReturnBuiltin<RemoteFunctions, LocalFunctions>;
|
|
95
|
+
type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
|
|
96
|
+
interface PromiseEntry {
|
|
97
|
+
resolve: (arg: any) => void;
|
|
98
|
+
reject: (error: any) => void;
|
|
99
|
+
method: string;
|
|
100
|
+
timeoutId?: ReturnType<typeof setTimeout>;
|
|
101
|
+
}
|
|
102
|
+
declare const setTimeout: typeof globalThis.setTimeout;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/core/types.d.ts
|
|
105
|
+
interface ClientInfo {
|
|
106
|
+
clientId: string;
|
|
107
|
+
url: string;
|
|
108
|
+
title: string;
|
|
109
|
+
userAgent: string;
|
|
110
|
+
connectedAt: number;
|
|
111
|
+
lastActiveAt: number;
|
|
112
|
+
}
|
|
113
|
+
interface TaskHistory {
|
|
114
|
+
id: string;
|
|
115
|
+
sourceClient: string;
|
|
116
|
+
intent: "analyze" | "modify" | "test" | "style" | "ask";
|
|
117
|
+
element: {
|
|
118
|
+
uid: string;
|
|
119
|
+
selector: string;
|
|
120
|
+
role: string;
|
|
121
|
+
name: string;
|
|
122
|
+
codeLocation?: {
|
|
123
|
+
file: string;
|
|
124
|
+
line: number;
|
|
125
|
+
column: number;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
userNote?: string;
|
|
129
|
+
timestamp: number;
|
|
130
|
+
status: "pending" | "in_progress" | "completed" | "failed";
|
|
131
|
+
completedAt?: number;
|
|
132
|
+
completedBy?: string;
|
|
133
|
+
result?: Record<string, any>;
|
|
134
|
+
}
|
|
135
|
+
interface ClientDiscoveryFilter {
|
|
136
|
+
urlPattern?: string;
|
|
137
|
+
titlePattern?: string;
|
|
138
|
+
clientId?: string;
|
|
139
|
+
activeOnly?: boolean;
|
|
140
|
+
}
|
|
141
|
+
interface PendingTask {
|
|
142
|
+
id: string;
|
|
143
|
+
sourceClient: string;
|
|
144
|
+
intent: "analyze" | "modify" | "test" | "style" | "ask";
|
|
145
|
+
element: {
|
|
146
|
+
uid: string;
|
|
147
|
+
selector: string;
|
|
148
|
+
role: string;
|
|
149
|
+
name: string;
|
|
150
|
+
codeLocation?: {
|
|
151
|
+
file: string;
|
|
152
|
+
line: number;
|
|
153
|
+
column: number;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
userNote?: string;
|
|
157
|
+
timestamp: number;
|
|
158
|
+
}
|
|
159
|
+
interface BaseServerFunctions {
|
|
160
|
+
ping: () => string;
|
|
161
|
+
updateClientInfo: (info: Omit<ClientInfo, "clientId" | "connectedAt" | "lastActiveAt">) => void;
|
|
162
|
+
}
|
|
163
|
+
interface PluginServerFunctions {}
|
|
164
|
+
type ServerFunctions = BaseServerFunctions & PluginServerFunctions;
|
|
165
|
+
interface BaseClientFunctions {
|
|
166
|
+
notifyTaskUpdate: (count: number) => void;
|
|
167
|
+
notifyTaskCompleted: (taskId: string) => void;
|
|
168
|
+
}
|
|
169
|
+
interface PluginClientFunctions {}
|
|
170
|
+
type ClientFunctions = BaseClientFunctions & PluginClientFunctions;
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/core/client-manager.d.ts
|
|
173
|
+
interface ClientConnection<T extends Record<string, any> = object> {
|
|
174
|
+
ws: WebSocket;
|
|
175
|
+
info: ClientInfo;
|
|
176
|
+
rpc: BirpcReturn<ClientFunctions & T, ServerFunctions>;
|
|
177
|
+
}
|
|
178
|
+
declare class ClientManager {
|
|
179
|
+
private clients;
|
|
180
|
+
private taskQueue;
|
|
181
|
+
private taskHistory;
|
|
182
|
+
private readonly maxTaskHistory;
|
|
183
|
+
generateClientId(): string;
|
|
184
|
+
addClient(clientId: string, ws: WebSocket, rpc: BirpcReturn<ClientFunctions, ServerFunctions>): ClientInfo;
|
|
185
|
+
removeClient(clientId: string): void;
|
|
186
|
+
updateClientInfo(clientId: string, update: Partial<Omit<ClientInfo, "clientId" | "connectedAt">>): void;
|
|
187
|
+
getClient<T extends Record<string, any> = object>(clientId: string): ClientConnection<T> | undefined;
|
|
188
|
+
getAllClients(activeOnly?: boolean): ClientInfo[];
|
|
189
|
+
/**
|
|
190
|
+
* Find clients by URL pattern or other filters
|
|
191
|
+
*/
|
|
192
|
+
findClients(filter: ClientDiscoveryFilter): ClientInfo[];
|
|
193
|
+
/**
|
|
194
|
+
* Get clients grouped by URL for easier identification
|
|
195
|
+
*/
|
|
196
|
+
getClientsByUrl(): Record<string, ClientInfo[]>;
|
|
197
|
+
addTask(task: PendingTask): void;
|
|
198
|
+
getPendingTasks(clear?: boolean): PendingTask[];
|
|
199
|
+
getTaskCount(): number;
|
|
200
|
+
/**
|
|
201
|
+
* Get task history with optional filters
|
|
202
|
+
*/
|
|
203
|
+
getTaskHistory(filter?: {
|
|
204
|
+
clientId?: string;
|
|
205
|
+
status?: TaskHistory["status"];
|
|
206
|
+
limit?: number;
|
|
207
|
+
}): TaskHistory[];
|
|
208
|
+
/**
|
|
209
|
+
* Mark a task as in progress
|
|
210
|
+
*/
|
|
211
|
+
markTaskInProgress(taskId: string, clientId: string): void;
|
|
212
|
+
/**
|
|
213
|
+
* Mark a task as completed
|
|
214
|
+
*/
|
|
215
|
+
markTaskCompleted(taskId: string, clientId: string, result?: Record<string, any>): void;
|
|
216
|
+
/**
|
|
217
|
+
* Mark a task as failed
|
|
218
|
+
*/
|
|
219
|
+
markTaskFailed(taskId: string, clientId: string, error?: string): void;
|
|
220
|
+
private notifyAllClients;
|
|
221
|
+
notifyTaskCompleted(taskId: string, clientId?: string): void;
|
|
222
|
+
}
|
|
223
|
+
declare const clientManager: ClientManager;
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/index.d.ts
|
|
226
|
+
declare const unpluginDevpilot: UnpluginInstance<Options | undefined, false>;
|
|
227
|
+
//#endregion
|
|
228
|
+
export { ClientDiscoveryFilter as a, PendingTask as c, ServerFunctions as d, TaskHistory as f, BaseServerFunctions as i, PluginClientFunctions as l, Options as m, clientManager as n, ClientFunctions as o, DevpilotPlugin as p, BaseClientFunctions as r, ClientInfo as s, unpluginDevpilot as t, PluginServerFunctions as u };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { i as defineMcpToolRegister, n as resolveClientModule, t as DevpilotPluginContext } from "./index-CL0Gw5-1.mjs";
|
|
2
|
+
import { a as ClientDiscoveryFilter, c as PendingTask, d as ServerFunctions, f as TaskHistory, i as BaseServerFunctions, l as PluginClientFunctions, m as Options, n as clientManager, o as ClientFunctions, p as DevpilotPlugin, r as BaseClientFunctions, s as ClientInfo, t as unpluginDevpilot, u as PluginServerFunctions } from "./index-CyKvTBcJ.mjs";
|
|
3
|
+
export { BaseClientFunctions, BaseServerFunctions, ClientDiscoveryFilter, ClientFunctions, ClientInfo, DevpilotPlugin, DevpilotPluginContext, Options, PendingTask, PluginClientFunctions, PluginServerFunctions, ServerFunctions, TaskHistory, clientManager, unpluginDevpilot as default, unpluginDevpilot, defineMcpToolRegister, resolveClientModule };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { n as unpluginDevpilot, r as clientManager, t as src_default } from "./src-aMXlip6o.mjs";
|
|
2
|
+
import { n as defineMcpToolRegister, t as resolveClientModule } from "./plugin-PB-j5Ck2.mjs";
|
|
3
|
+
|
|
4
|
+
export { clientManager, src_default as default, defineMcpToolRegister, resolveClientModule, unpluginDevpilot };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
//#region src/core/plugin/mcp.ts
|
|
5
|
+
function defineMcpToolRegister(name, config, cb) {
|
|
6
|
+
return () => ({
|
|
7
|
+
name,
|
|
8
|
+
config,
|
|
9
|
+
cb
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/core/plugin/index.ts
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the module path relative to the plugin to an absolute path
|
|
17
|
+
* @param importMetaUrl - Pass in import.meta.url
|
|
18
|
+
* @param relativePath - Path relative to the plugin
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { resolveClientModule } from 'unplugin-devpilot'
|
|
22
|
+
*
|
|
23
|
+
* export function myPlugin(): DevpilotPlugin {
|
|
24
|
+
* return {
|
|
25
|
+
* name: 'my-plugin',
|
|
26
|
+
* clientModule: resolveClientModule(import.meta.url, './client.mjs'),
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function resolveClientModule(importMetaUrl, relativePath) {
|
|
32
|
+
return `${dirname(fileURLToPath(importMetaUrl))}/${relativePath}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { defineMcpToolRegister as n, resolveClientModule as t };
|
package/dist/plugin.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { t as unpluginDevpilot } from "./index-CyKvTBcJ.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/rspack.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Rspack plugin
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```js
|
|
9
|
+
* // rspack.config.js
|
|
10
|
+
* import devpilot from 'unplugin-devpilot/rspack'
|
|
11
|
+
*
|
|
12
|
+
* export default {
|
|
13
|
+
* plugins: [devpilot()],
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const rspack: typeof unpluginDevpilot.rspack;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { rspack as default, rspack as "module.exports" };
|
package/dist/rspack.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { n as unpluginDevpilot } from "./src-aMXlip6o.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/rspack.ts
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Rspack plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Rspack plugin
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```js
|
|
14
|
+
* // rspack.config.js
|
|
15
|
+
* import devpilot from 'unplugin-devpilot/rspack'
|
|
16
|
+
*
|
|
17
|
+
* export default {
|
|
18
|
+
* plugins: [devpilot()],
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
const rspack = unpluginDevpilot.rspack;
|
|
23
|
+
var rspack_default = rspack;
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { rspack_default as default, rspack as "module.exports" };
|