unplugin-devpilot 0.0.3 → 0.0.4
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/farm.d.mts +1 -1
- package/dist/farm.mjs +1 -1
- package/dist/{index-9V3dRAxA.d.mts → index-Csy16I0Z.d.mts} +16 -1
- package/dist/{index-CQudsm6j.d.mts → index-WH3owjvn.d.mts} +51 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{plugin-BPkoZQbf.mjs → plugin-B1Afr0m3.mjs} +20 -2
- package/dist/plugin.d.mts +2 -2
- package/dist/plugin.mjs +2 -2
- package/dist/rspack.d.mts +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{src-Bm2tOOQC.mjs → src-AEXLBOF9.mjs} +211 -63
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +27 -3
package/dist/farm.d.mts
CHANGED
package/dist/farm.mjs
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
//#region src/core/utils.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the module path relative to the plugin to an absolute path
|
|
4
|
+
* Handles cross-platform paths (Windows, macOS, Linux) and proper escaping for imports
|
|
5
|
+
* @param importMetaUrl - Pass in import.meta.url
|
|
6
|
+
* @param relativePath - Path relative to the plugin
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { resolveModule } from 'unplugin-devpilot/core/utils'
|
|
10
|
+
*
|
|
11
|
+
* const skillPath = resolveModule(import.meta.url, './skill.md')
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare function resolveModule(importMetaUrl: string, relativePath: string): string;
|
|
15
|
+
//#endregion
|
|
1
16
|
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.cts
|
|
2
17
|
type Primitive$2 = string | number | symbol | bigint | boolean | null | undefined;
|
|
3
18
|
//#endregion
|
|
@@ -4128,4 +4143,4 @@ interface DevpilotPluginContext {
|
|
|
4128
4143
|
*/
|
|
4129
4144
|
declare function resolveClientModule(importMetaUrl: string, relativePath: string): string;
|
|
4130
4145
|
//#endregion
|
|
4131
|
-
export { defineMcpToolRegister as i, resolveClientModule as n, McpToolRegister as r, DevpilotPluginContext as t };
|
|
4146
|
+
export { resolveModule as a, defineMcpToolRegister as i, resolveClientModule as n, McpToolRegister as r, DevpilotPluginContext as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as McpToolRegister, t as DevpilotPluginContext } from "./index-
|
|
1
|
+
import { r as McpToolRegister, t as DevpilotPluginContext } from "./index-Csy16I0Z.mjs";
|
|
2
2
|
import { UnpluginInstance } from "unplugin";
|
|
3
3
|
import { WebSocket } from "ws";
|
|
4
4
|
|
|
@@ -25,11 +25,40 @@ interface DevpilotPlugin {
|
|
|
25
25
|
*/
|
|
26
26
|
serverSetup?: (ctx: DevpilotPluginContext) => Record<string, (...args: any[]) => any>;
|
|
27
27
|
mcpSetup?: (ctx: DevpilotPluginContext) => Array<McpToolRegister>;
|
|
28
|
+
/**
|
|
29
|
+
* The skill module path to be injected
|
|
30
|
+
* - npm package path: 'my-plugin/skill'
|
|
31
|
+
* - absolute path: '/path/to/skill.md'
|
|
32
|
+
*
|
|
33
|
+
* Note: relative paths need to be resolved to absolute paths first
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { resolveSkillModule } from 'unplugin-devpilot'
|
|
37
|
+
*
|
|
38
|
+
* skillModule: resolveSkillModule(import.meta.url, './skill.md')
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
skillModule?: string | ((ctx: DevpilotPluginContext) => string);
|
|
28
42
|
}
|
|
29
43
|
interface Options {
|
|
30
44
|
wsPort?: number;
|
|
31
45
|
mcpPort?: number;
|
|
32
46
|
plugins?: DevpilotPlugin[];
|
|
47
|
+
/**
|
|
48
|
+
* The path to generate the core skill file
|
|
49
|
+
* - directory path: './src/skills/devpilot' (will generate SKILL.md in this directory)
|
|
50
|
+
* - file path: './src/skills/devpilot/SKILL.md' (will generate the specified file)
|
|
51
|
+
*
|
|
52
|
+
* If not specified, no core skill file will be generated
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* Devpilot({
|
|
56
|
+
* skillCorePath: './src/skills/devpilot',
|
|
57
|
+
* plugins: [],
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
skillCorePath?: string;
|
|
33
62
|
}
|
|
34
63
|
//#endregion
|
|
35
64
|
//#region ../../node_modules/.pnpm/birpc@4.0.0/node_modules/birpc/dist/index.d.mts
|
|
@@ -222,7 +251,27 @@ declare class ClientManager {
|
|
|
222
251
|
}
|
|
223
252
|
declare const clientManager: ClientManager;
|
|
224
253
|
//#endregion
|
|
254
|
+
//#region src/core/skill-generator.d.ts
|
|
255
|
+
/**
|
|
256
|
+
* Resolve the skill module path relative to the plugin to an absolute path
|
|
257
|
+
* Handles cross-platform paths (Windows, macOS, Linux) and proper escaping for imports
|
|
258
|
+
* @param importMetaUrl - Pass in import.meta.url
|
|
259
|
+
* @param relativePath - Path relative to the plugin
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* import { resolveSkillModule } from 'unplugin-devpilot'
|
|
263
|
+
*
|
|
264
|
+
* export function myPlugin(): DevpilotPlugin {
|
|
265
|
+
* return {
|
|
266
|
+
* namespace: 'my-plugin',
|
|
267
|
+
* skillModule: resolveSkillModule(import.meta.url, './skill.md'),
|
|
268
|
+
* }
|
|
269
|
+
* }
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
declare function resolveSkillModule(importMetaUrl: string, relativePath: string): string;
|
|
273
|
+
//#endregion
|
|
225
274
|
//#region src/index.d.ts
|
|
226
275
|
declare const unpluginDevpilot: UnpluginInstance<Options | undefined, false>;
|
|
227
276
|
//#endregion
|
|
228
|
-
export {
|
|
277
|
+
export { BaseServerFunctions as a, ClientInfo as c, PluginServerFunctions as d, ServerFunctions as f, Options as h, BaseClientFunctions as i, PendingTask as l, DevpilotPlugin as m, resolveSkillModule as n, ClientDiscoveryFilter as o, TaskHistory as p, clientManager as r, ClientFunctions as s, unpluginDevpilot as t, PluginClientFunctions as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as defineMcpToolRegister, n as resolveClientModule, t as DevpilotPluginContext } from "./index-
|
|
2
|
-
import { a as
|
|
3
|
-
export { BaseClientFunctions, BaseServerFunctions, ClientDiscoveryFilter, ClientFunctions, ClientInfo, DevpilotPlugin, DevpilotPluginContext, Options, PendingTask, PluginClientFunctions, PluginServerFunctions, ServerFunctions, TaskHistory, clientManager, unpluginDevpilot as default, unpluginDevpilot, defineMcpToolRegister, resolveClientModule };
|
|
1
|
+
import { a as resolveModule, i as defineMcpToolRegister, n as resolveClientModule, t as DevpilotPluginContext } from "./index-Csy16I0Z.mjs";
|
|
2
|
+
import { a as BaseServerFunctions, c as ClientInfo, d as PluginServerFunctions, f as ServerFunctions, h as Options, i as BaseClientFunctions, l as PendingTask, m as DevpilotPlugin, n as resolveSkillModule, o as ClientDiscoveryFilter, p as TaskHistory, r as clientManager, s as ClientFunctions, t as unpluginDevpilot, u as PluginClientFunctions } from "./index-WH3owjvn.mjs";
|
|
3
|
+
export { BaseClientFunctions, BaseServerFunctions, ClientDiscoveryFilter, ClientFunctions, ClientInfo, DevpilotPlugin, DevpilotPluginContext, Options, PendingTask, PluginClientFunctions, PluginServerFunctions, ServerFunctions, TaskHistory, clientManager, unpluginDevpilot as default, unpluginDevpilot, defineMcpToolRegister, resolveClientModule, resolveModule, resolveSkillModule };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as unpluginDevpilot, r as
|
|
2
|
-
import { n as defineMcpToolRegister, t as resolveClientModule } from "./plugin-
|
|
1
|
+
import { i as clientManager, n as unpluginDevpilot, r as resolveSkillModule, t as src_default } from "./src-AEXLBOF9.mjs";
|
|
2
|
+
import { n as defineMcpToolRegister, r as resolveModule, t as resolveClientModule } from "./plugin-B1Afr0m3.mjs";
|
|
3
3
|
|
|
4
|
-
export { clientManager, src_default as default, defineMcpToolRegister, resolveClientModule, unpluginDevpilot };
|
|
4
|
+
export { clientManager, src_default as default, defineMcpToolRegister, resolveClientModule, resolveModule, resolveSkillModule, unpluginDevpilot };
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { dirname, join } from "node:path";
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
3
|
|
|
4
|
+
//#region src/core/utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the module path relative to the plugin to an absolute path
|
|
7
|
+
* Handles cross-platform paths (Windows, macOS, Linux) and proper escaping for imports
|
|
8
|
+
* @param importMetaUrl - Pass in import.meta.url
|
|
9
|
+
* @param relativePath - Path relative to the plugin
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { resolveModule } from 'unplugin-devpilot/core/utils'
|
|
13
|
+
*
|
|
14
|
+
* const skillPath = resolveModule(import.meta.url, './skill.md')
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function resolveModule(importMetaUrl, relativePath) {
|
|
18
|
+
return pathToFileURL(join(dirname(fileURLToPath(importMetaUrl)), relativePath)).href;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
4
22
|
//#region src/core/plugin/mcp.ts
|
|
5
23
|
function defineMcpToolRegister(name, config, cb) {
|
|
6
24
|
return () => ({
|
|
@@ -30,8 +48,8 @@ function defineMcpToolRegister(name, config, cb) {
|
|
|
30
48
|
* ```
|
|
31
49
|
*/
|
|
32
50
|
function resolveClientModule(importMetaUrl, relativePath) {
|
|
33
|
-
return
|
|
51
|
+
return resolveModule(importMetaUrl, relativePath);
|
|
34
52
|
}
|
|
35
53
|
|
|
36
54
|
//#endregion
|
|
37
|
-
export { defineMcpToolRegister as n, resolveClientModule as t };
|
|
55
|
+
export { defineMcpToolRegister as n, resolveModule as r, resolveClientModule as t };
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as defineMcpToolRegister, n as resolveClientModule, r as McpToolRegister, t as DevpilotPluginContext } from "./index-
|
|
2
|
-
export { DevpilotPluginContext, McpToolRegister as McpServerRegister, defineMcpToolRegister, resolveClientModule };
|
|
1
|
+
import { a as resolveModule, i as defineMcpToolRegister, n as resolveClientModule, r as McpToolRegister, t as DevpilotPluginContext } from "./index-Csy16I0Z.mjs";
|
|
2
|
+
export { DevpilotPluginContext, McpToolRegister as McpServerRegister, defineMcpToolRegister, resolveClientModule, resolveModule };
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as defineMcpToolRegister, t as resolveClientModule } from "./plugin-
|
|
1
|
+
import { n as defineMcpToolRegister, r as resolveModule, t as resolveClientModule } from "./plugin-B1Afr0m3.mjs";
|
|
2
2
|
|
|
3
|
-
export { defineMcpToolRegister, resolveClientModule };
|
|
3
|
+
export { defineMcpToolRegister, resolveClientModule, resolveModule };
|
package/dist/rspack.d.mts
CHANGED
package/dist/rspack.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { r as resolveModule } from "./plugin-B1Afr0m3.mjs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
import process$1 from "node:process";
|
|
3
4
|
import { createUnplugin } from "unplugin";
|
|
@@ -7,8 +8,9 @@ import { Readable } from "stream";
|
|
|
7
8
|
import crypto$1 from "crypto";
|
|
8
9
|
import { createServer as createServer$1 } from "node:net";
|
|
9
10
|
import { networkInterfaces } from "node:os";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import {
|
|
11
|
+
import { dirname, extname, join } from "node:path";
|
|
12
|
+
import { promises } from "node:fs";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
12
14
|
|
|
13
15
|
//#region rolldown:runtime
|
|
14
16
|
var __create = Object.create;
|
|
@@ -19797,7 +19799,7 @@ var StreamableHTTPServerTransport = class {
|
|
|
19797
19799
|
|
|
19798
19800
|
//#endregion
|
|
19799
19801
|
//#region package.json
|
|
19800
|
-
var version = "0.0.
|
|
19802
|
+
var version = "0.0.4";
|
|
19801
19803
|
|
|
19802
19804
|
//#endregion
|
|
19803
19805
|
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/compat/util/uniqueId.mjs
|
|
@@ -20194,10 +20196,13 @@ async function startMcpServer(port) {
|
|
|
20194
20196
|
});
|
|
20195
20197
|
}
|
|
20196
20198
|
function stopMcpServer() {
|
|
20197
|
-
|
|
20198
|
-
httpServer
|
|
20199
|
-
|
|
20200
|
-
|
|
20199
|
+
return new Promise((resolve) => {
|
|
20200
|
+
if (httpServer) {
|
|
20201
|
+
const server = httpServer;
|
|
20202
|
+
httpServer = null;
|
|
20203
|
+
server.close(() => resolve());
|
|
20204
|
+
} else resolve();
|
|
20205
|
+
});
|
|
20201
20206
|
}
|
|
20202
20207
|
|
|
20203
20208
|
//#endregion
|
|
@@ -20347,36 +20352,158 @@ async function checkPort(port, host = process.env.HOST, verbose) {
|
|
|
20347
20352
|
|
|
20348
20353
|
//#endregion
|
|
20349
20354
|
//#region src/core/options.ts
|
|
20355
|
+
let lastResolvedWsPort;
|
|
20356
|
+
let lastResolvedMcpPort;
|
|
20350
20357
|
async function resolveOptions(options) {
|
|
20351
|
-
|
|
20352
|
-
|
|
20353
|
-
|
|
20354
|
-
|
|
20355
|
-
const preferredMcpPort = options.mcpPort || 3101;
|
|
20356
|
-
if (await checkPort(preferredMcpPort) === false) throw new Error(`MCP port ${preferredMcpPort} is already in use. Please specify a different port or free up the port.`);
|
|
20358
|
+
const wsPort = await resolveWsPort(options.wsPort);
|
|
20359
|
+
const mcpPort = await resolveMcpPort(options.mcpPort);
|
|
20360
|
+
lastResolvedWsPort = wsPort;
|
|
20361
|
+
lastResolvedMcpPort = mcpPort;
|
|
20357
20362
|
return {
|
|
20358
20363
|
wsPort,
|
|
20359
|
-
mcpPort
|
|
20360
|
-
plugins: options.plugins || []
|
|
20364
|
+
mcpPort,
|
|
20365
|
+
plugins: options.plugins || [],
|
|
20366
|
+
skillCorePath: options.skillCorePath
|
|
20361
20367
|
};
|
|
20362
20368
|
}
|
|
20369
|
+
async function resolveWsPort(preferred) {
|
|
20370
|
+
const candidate = preferred ?? lastResolvedWsPort;
|
|
20371
|
+
if (candidate !== void 0) {
|
|
20372
|
+
if (await checkPort(candidate) !== false) return candidate;
|
|
20373
|
+
if (candidate === lastResolvedWsPort) return candidate;
|
|
20374
|
+
}
|
|
20375
|
+
if (lastResolvedWsPort !== void 0) return lastResolvedWsPort;
|
|
20376
|
+
return getRandomPort();
|
|
20377
|
+
}
|
|
20378
|
+
async function resolveMcpPort(preferred) {
|
|
20379
|
+
const candidate = preferred || 3101;
|
|
20380
|
+
if (candidate === lastResolvedMcpPort) return candidate;
|
|
20381
|
+
if (await checkPort(candidate) === false) throw new Error(`MCP port ${candidate} is already in use. Please specify a different port or free up the port.`);
|
|
20382
|
+
return candidate;
|
|
20383
|
+
}
|
|
20363
20384
|
|
|
20364
20385
|
//#endregion
|
|
20365
|
-
//#region src/core/
|
|
20386
|
+
//#region src/core/skill-generator.ts
|
|
20387
|
+
/**
|
|
20388
|
+
* Resolve the skill module path relative to the plugin to an absolute path
|
|
20389
|
+
* Handles cross-platform paths (Windows, macOS, Linux) and proper escaping for imports
|
|
20390
|
+
* @param importMetaUrl - Pass in import.meta.url
|
|
20391
|
+
* @param relativePath - Path relative to the plugin
|
|
20392
|
+
* @example
|
|
20393
|
+
* ```ts
|
|
20394
|
+
* import { resolveSkillModule } from 'unplugin-devpilot'
|
|
20395
|
+
*
|
|
20396
|
+
* export function myPlugin(): DevpilotPlugin {
|
|
20397
|
+
* return {
|
|
20398
|
+
* namespace: 'my-plugin',
|
|
20399
|
+
* skillModule: resolveSkillModule(import.meta.url, './skill.md'),
|
|
20400
|
+
* }
|
|
20401
|
+
* }
|
|
20402
|
+
* ```
|
|
20403
|
+
*/
|
|
20404
|
+
function resolveSkillModule(importMetaUrl, relativePath) {
|
|
20405
|
+
return resolveModule(importMetaUrl, relativePath);
|
|
20406
|
+
}
|
|
20366
20407
|
/**
|
|
20367
|
-
*
|
|
20408
|
+
* Determine if a path is a directory (no file extension) or a file
|
|
20409
|
+
* @param path - The path to check
|
|
20410
|
+
* @returns true if the path is a directory, false if it's a file
|
|
20368
20411
|
*/
|
|
20369
|
-
|
|
20370
|
-
return
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20375
|
-
|
|
20376
|
-
|
|
20377
|
-
|
|
20412
|
+
function isDirectoryPath(path) {
|
|
20413
|
+
return extname(path) === "";
|
|
20414
|
+
}
|
|
20415
|
+
/**
|
|
20416
|
+
* Get the core skill file path, handling both directory and file paths
|
|
20417
|
+
* @param skillCorePath - The configured skill core path (directory or file)
|
|
20418
|
+
* @returns The actual file path to use for the core skill file
|
|
20419
|
+
*/
|
|
20420
|
+
function getCoreSkillFilePath(skillCorePath) {
|
|
20421
|
+
if (isDirectoryPath(skillCorePath)) return join(skillCorePath, "SKILL.md");
|
|
20422
|
+
return skillCorePath;
|
|
20423
|
+
}
|
|
20424
|
+
/**
|
|
20425
|
+
* Get all plugin skill modules
|
|
20426
|
+
*/
|
|
20427
|
+
function getPluginSkillModules(plugins, options) {
|
|
20428
|
+
const ctx = { wsPort: options.wsPort };
|
|
20429
|
+
return plugins.filter((p) => p.skillModule).map((p) => {
|
|
20430
|
+
const mod = typeof p.skillModule === "function" ? p.skillModule(ctx) : p.skillModule;
|
|
20431
|
+
let skillPath;
|
|
20432
|
+
if (mod.startsWith("file://")) skillPath = fileURLToPath(mod);
|
|
20433
|
+
else if (mod.startsWith("npm:") || !mod.startsWith(".") && !mod.startsWith("/") && (mod.includes("/") || mod.match(/^[@a-z0-9]\S+$/i))) skillPath = mod;
|
|
20434
|
+
else skillPath = mod;
|
|
20435
|
+
return {
|
|
20436
|
+
namespace: p.namespace,
|
|
20437
|
+
path: skillPath,
|
|
20438
|
+
originalSkillModule: mod
|
|
20439
|
+
};
|
|
20378
20440
|
});
|
|
20379
20441
|
}
|
|
20442
|
+
/**
|
|
20443
|
+
* Generate the core skill markdown content
|
|
20444
|
+
*/
|
|
20445
|
+
function generateCoreSkillContent(options, isDev) {
|
|
20446
|
+
if (!isDev) return "";
|
|
20447
|
+
return `# Devpilot Core Skills
|
|
20448
|
+
|
|
20449
|
+
This is the core skill file that aggregates all plugin skills.
|
|
20450
|
+
|
|
20451
|
+
## Available Skills
|
|
20452
|
+
|
|
20453
|
+
${getPluginSkillModules(options.plugins, options).map((skill) => {
|
|
20454
|
+
if (skill.originalSkillModule.startsWith("file://")) {
|
|
20455
|
+
const linkPath = `./${skill.namespace}.md`;
|
|
20456
|
+
return `- [${skill.namespace}](${linkPath}) - ${skill.namespace} capabilities`;
|
|
20457
|
+
} else if (skill.originalSkillModule.startsWith("npm:") || !skill.originalSkillModule.startsWith(".") && !skill.originalSkillModule.startsWith("/") && (skill.originalSkillModule.includes("/") || skill.originalSkillModule.match(/^[@a-z0-9]\S+$/i))) return `- [${skill.namespace}](${skill.originalSkillModule}) - ${skill.namespace} capabilities`;
|
|
20458
|
+
else {
|
|
20459
|
+
const linkPath = `./${skill.namespace}.md`;
|
|
20460
|
+
return `- [${skill.namespace}](${linkPath}) - ${skill.namespace} capabilities`;
|
|
20461
|
+
}
|
|
20462
|
+
}).join("\n") || "No plugin skills configured"}
|
|
20463
|
+
|
|
20464
|
+
## Usage
|
|
20465
|
+
|
|
20466
|
+
These skills can be used with Claude Agent to interact with web applications.
|
|
20467
|
+
|
|
20468
|
+
## Configuration
|
|
20469
|
+
|
|
20470
|
+
- **Core Skill Path**: ${options.skillCorePath || "Not configured"}
|
|
20471
|
+
- **Plugins**: ${options.plugins.length}
|
|
20472
|
+
- **WebSocket Port**: ${options.wsPort}
|
|
20473
|
+
- **MCP Port**: ${options.mcpPort}
|
|
20474
|
+
`;
|
|
20475
|
+
}
|
|
20476
|
+
/**
|
|
20477
|
+
* Generate and write the core skill file
|
|
20478
|
+
*/
|
|
20479
|
+
async function generateCoreSkill(options, isDev) {
|
|
20480
|
+
if (!options.skillCorePath) return;
|
|
20481
|
+
const skillFilePath = getCoreSkillFilePath(options.skillCorePath);
|
|
20482
|
+
const content = generateCoreSkillContent(options, isDev);
|
|
20483
|
+
if (!isDev || !content) {
|
|
20484
|
+
try {
|
|
20485
|
+
await promises.unlink(skillFilePath);
|
|
20486
|
+
} catch {}
|
|
20487
|
+
return;
|
|
20488
|
+
}
|
|
20489
|
+
let existingContent;
|
|
20490
|
+
try {
|
|
20491
|
+
existingContent = await promises.readFile(skillFilePath, "utf-8");
|
|
20492
|
+
} catch {}
|
|
20493
|
+
if (existingContent === content) return;
|
|
20494
|
+
const dir = dirname(skillFilePath);
|
|
20495
|
+
await promises.mkdir(dir, { recursive: true });
|
|
20496
|
+
const pluginSkills = getPluginSkillModules(options.plugins, options);
|
|
20497
|
+
for (const skill of pluginSkills) if (skill.originalSkillModule.startsWith("file://")) {
|
|
20498
|
+
const sourcePath = skill.path;
|
|
20499
|
+
const destPath = join(dir, `${skill.namespace}.md`);
|
|
20500
|
+
try {
|
|
20501
|
+
const skillContent = await promises.readFile(sourcePath, "utf-8");
|
|
20502
|
+
await promises.writeFile(destPath, skillContent, "utf-8");
|
|
20503
|
+
} catch {}
|
|
20504
|
+
}
|
|
20505
|
+
await promises.writeFile(skillFilePath, content, "utf-8");
|
|
20506
|
+
}
|
|
20380
20507
|
|
|
20381
20508
|
//#endregion
|
|
20382
20509
|
//#region ../../node_modules/.pnpm/birpc@4.0.0/node_modules/birpc/dist/index.mjs
|
|
@@ -24162,10 +24289,13 @@ function startWebSocketServer(port) {
|
|
|
24162
24289
|
return wss;
|
|
24163
24290
|
}
|
|
24164
24291
|
function stopWebSocketServer() {
|
|
24165
|
-
|
|
24166
|
-
wss
|
|
24167
|
-
|
|
24168
|
-
|
|
24292
|
+
return new Promise((resolve) => {
|
|
24293
|
+
if (wss) {
|
|
24294
|
+
const server = wss;
|
|
24295
|
+
wss = null;
|
|
24296
|
+
server.close(() => resolve());
|
|
24297
|
+
} else resolve();
|
|
24298
|
+
});
|
|
24169
24299
|
}
|
|
24170
24300
|
|
|
24171
24301
|
//#endregion
|
|
@@ -24196,30 +24326,33 @@ ${handlerCollection}
|
|
|
24196
24326
|
});
|
|
24197
24327
|
`;
|
|
24198
24328
|
}
|
|
24329
|
+
let serversStarted = false;
|
|
24330
|
+
let lastOptions = null;
|
|
24331
|
+
async function startServers(rawOptions) {
|
|
24332
|
+
const options = await resolveOptions(rawOptions);
|
|
24333
|
+
lastOptions = options;
|
|
24334
|
+
registerPluginServerMethods(options.plugins);
|
|
24335
|
+
registerPluginMcpRegisterMethods(options.plugins);
|
|
24336
|
+
if (!serversStarted) {
|
|
24337
|
+
serversStarted = true;
|
|
24338
|
+
startWebSocketServer(options.wsPort);
|
|
24339
|
+
await startMcpServer(options.mcpPort);
|
|
24340
|
+
}
|
|
24341
|
+
await generateCoreSkill(options, process$1.env.NODE_ENV !== "production");
|
|
24342
|
+
return options;
|
|
24343
|
+
}
|
|
24344
|
+
async function stopServers() {
|
|
24345
|
+
if (!serversStarted) return;
|
|
24346
|
+
serversStarted = false;
|
|
24347
|
+
await Promise.all([stopWebSocketServer(), stopMcpServer()]);
|
|
24348
|
+
if (lastOptions) await generateCoreSkill(lastOptions, false);
|
|
24349
|
+
}
|
|
24199
24350
|
const unpluginDevpilot = createUnplugin((rawOptions = {}) => {
|
|
24200
24351
|
let options = null;
|
|
24201
|
-
let
|
|
24352
|
+
let isDevServer = false;
|
|
24202
24353
|
const name = "unplugin-devpilot";
|
|
24203
|
-
async function
|
|
24204
|
-
|
|
24205
|
-
return options;
|
|
24206
|
-
}
|
|
24207
|
-
async function startServers() {
|
|
24208
|
-
if (serversStarted) return;
|
|
24209
|
-
serversStarted = true;
|
|
24210
|
-
const resolvedOptions = await ensureOptionsResolved();
|
|
24211
|
-
registerPluginServerMethods(resolvedOptions.plugins);
|
|
24212
|
-
registerPluginMcpRegisterMethods(resolvedOptions.plugins);
|
|
24213
|
-
startWebSocketServer(resolvedOptions.wsPort);
|
|
24214
|
-
await startMcpServer(resolvedOptions.mcpPort);
|
|
24215
|
-
}
|
|
24216
|
-
async function stopServers() {
|
|
24217
|
-
if (!serversStarted) return;
|
|
24218
|
-
const resolvedOptions = await ensureOptionsResolved();
|
|
24219
|
-
serversStarted = false;
|
|
24220
|
-
stopWebSocketServer();
|
|
24221
|
-
stopMcpServer();
|
|
24222
|
-
await killPort(resolvedOptions.mcpPort);
|
|
24354
|
+
async function ensureServersStarted() {
|
|
24355
|
+
options = await startServers(rawOptions);
|
|
24223
24356
|
}
|
|
24224
24357
|
return {
|
|
24225
24358
|
name,
|
|
@@ -24231,37 +24364,52 @@ const unpluginDevpilot = createUnplugin((rawOptions = {}) => {
|
|
|
24231
24364
|
return id === RESOLVED_VIRTUAL_MODULE_ID;
|
|
24232
24365
|
},
|
|
24233
24366
|
async load(id) {
|
|
24234
|
-
if (id === RESOLVED_VIRTUAL_MODULE_ID)
|
|
24367
|
+
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
|
24368
|
+
if (!options) options = await resolveOptions(rawOptions);
|
|
24369
|
+
return generateVirtualClientModule(options, process$1.env.NODE_ENV !== "production");
|
|
24370
|
+
}
|
|
24235
24371
|
},
|
|
24236
24372
|
buildStart() {
|
|
24237
24373
|
if (process$1.env.NODE_ENV === "production") return;
|
|
24238
|
-
|
|
24374
|
+
if (isDevServer) return;
|
|
24375
|
+
return ensureServersStarted();
|
|
24239
24376
|
},
|
|
24240
24377
|
buildEnd() {
|
|
24241
|
-
|
|
24378
|
+
if (isDevServer) return;
|
|
24379
|
+
return stopServers();
|
|
24242
24380
|
},
|
|
24243
24381
|
vite: { configureServer() {
|
|
24244
|
-
|
|
24382
|
+
isDevServer = true;
|
|
24383
|
+
ensureServersStarted();
|
|
24245
24384
|
} },
|
|
24246
24385
|
webpack(compiler) {
|
|
24247
24386
|
compiler.hooks.watchRun.tapPromise(name, async () => {
|
|
24248
|
-
|
|
24387
|
+
isDevServer = true;
|
|
24388
|
+
await ensureServersStarted();
|
|
24249
24389
|
});
|
|
24250
|
-
compiler.hooks.
|
|
24251
|
-
|
|
24390
|
+
compiler.hooks.shutdown?.tap(name, () => {
|
|
24391
|
+
stopServers();
|
|
24252
24392
|
});
|
|
24253
24393
|
},
|
|
24254
24394
|
rspack(compiler) {
|
|
24255
24395
|
compiler.hooks.watchRun.tapPromise(name, async () => {
|
|
24256
|
-
|
|
24396
|
+
isDevServer = true;
|
|
24397
|
+
await ensureServersStarted();
|
|
24257
24398
|
});
|
|
24258
|
-
compiler.hooks.
|
|
24259
|
-
|
|
24399
|
+
compiler.hooks.shutdown?.tap(name, () => {
|
|
24400
|
+
stopServers();
|
|
24260
24401
|
});
|
|
24261
|
-
}
|
|
24402
|
+
},
|
|
24403
|
+
farm: { configureDevServer() {
|
|
24404
|
+
isDevServer = true;
|
|
24405
|
+
ensureServersStarted();
|
|
24406
|
+
} }
|
|
24262
24407
|
};
|
|
24263
24408
|
});
|
|
24409
|
+
process$1.on("beforeExit", () => {
|
|
24410
|
+
stopServers();
|
|
24411
|
+
});
|
|
24264
24412
|
var src_default = unpluginDevpilot;
|
|
24265
24413
|
|
|
24266
24414
|
//#endregion
|
|
24267
|
-
export { unpluginDevpilot as n,
|
|
24415
|
+
export { clientManager as i, unpluginDevpilot as n, resolveSkillModule as r, src_default as t };
|
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
package/dist/webpack.d.mts
CHANGED
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-devpilot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "Description.",
|
|
6
6
|
"author": "zcf0508 <zcf0508@live.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,6 +52,30 @@
|
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=20.19.0"
|
|
54
54
|
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@farmfe/core": ">=1",
|
|
57
|
+
"@nuxt/kit": "^3",
|
|
58
|
+
"@nuxt/schema": "^3",
|
|
59
|
+
"vite": ">=3",
|
|
60
|
+
"webpack": "^4 || ^5"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@farmfe/core": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"@nuxt/kit": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"@nuxt/schema": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"vite": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"webpack": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
55
79
|
"dependencies": {
|
|
56
80
|
"unplugin": "^3.0.0"
|
|
57
81
|
},
|
|
@@ -70,8 +94,8 @@
|
|
|
70
94
|
"build": "tsdown",
|
|
71
95
|
"dev": "tsdown --watch",
|
|
72
96
|
"test": "vitest --run",
|
|
73
|
-
"typecheck:client": "
|
|
74
|
-
"typecheck:node": "
|
|
97
|
+
"typecheck:client": "tsgo --project tsconfig.client.json --noEmit",
|
|
98
|
+
"typecheck:node": "tsgo --noEmit",
|
|
75
99
|
"typecheck": "pnpm run typecheck:client && pnpm run typecheck:node"
|
|
76
100
|
}
|
|
77
101
|
}
|