@mavonengine/cli 0.0.6 → 0.0.8
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 +245 -7
- package/dist/{chunk-7UZYGMGO.js → chunk-33OMMYNV.js} +5 -2
- package/dist/{chunk-ZEMFSSJP.js → chunk-GOPDTCJD.js} +21 -12
- package/dist/{chunk-IIWBECVS.js → chunk-HRMANFDB.js} +13 -25
- package/dist/chunk-K3NQKI34.js +10 -0
- package/dist/chunk-WMXVMJDM.js +53 -0
- package/dist/{docs-S2SWFUIL.js → docs-5J3ZQJSF.js} +4 -2
- package/dist/index.js +3347 -422
- package/dist/projectPluginTools-QWULLUMD.js +96 -0
- package/dist/{server-AC5LBJ6A.js → server-KTKAYX65.js} +327 -67
- package/package.json +3 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
READ_ONLY,
|
|
4
|
+
run
|
|
5
|
+
} from "./chunk-WMXVMJDM.js";
|
|
6
|
+
import "./chunk-K3NQKI34.js";
|
|
7
|
+
|
|
8
|
+
// src/mcp/projectPluginTools.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
function inputSchema(input) {
|
|
11
|
+
try {
|
|
12
|
+
const schema = z.fromJSONSchema(input);
|
|
13
|
+
if (schema instanceof z.ZodObject)
|
|
14
|
+
return schema;
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
return z.object({}).loose();
|
|
18
|
+
}
|
|
19
|
+
function annotations(tool) {
|
|
20
|
+
return tool.readOnly ? { ...READ_ONLY, openWorldHint: tool.openWorld } : {
|
|
21
|
+
readOnlyHint: false,
|
|
22
|
+
destructiveHint: tool.destructive,
|
|
23
|
+
idempotentHint: false,
|
|
24
|
+
openWorldHint: tool.openWorld
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var ProjectPluginTools = class {
|
|
28
|
+
constructor(server, client, options = {}) {
|
|
29
|
+
this.server = server;
|
|
30
|
+
this.client = client;
|
|
31
|
+
this.options = options;
|
|
32
|
+
}
|
|
33
|
+
server;
|
|
34
|
+
client;
|
|
35
|
+
options;
|
|
36
|
+
registered = /* @__PURE__ */ new Map();
|
|
37
|
+
/** Tools left out already said so, they would be on every refresh */
|
|
38
|
+
warned = /* @__PURE__ */ new Set();
|
|
39
|
+
/** The names of the plugin tools offered now */
|
|
40
|
+
get names() {
|
|
41
|
+
return [
|
|
42
|
+
...this.registered.keys()
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
async refresh() {
|
|
46
|
+
const listed = await this.client.pluginTools();
|
|
47
|
+
if (!listed)
|
|
48
|
+
return;
|
|
49
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
50
|
+
for (const tool of listed) {
|
|
51
|
+
if (this.options.readOnly && !tool.readOnly)
|
|
52
|
+
continue;
|
|
53
|
+
wanted.set(tool.name, tool);
|
|
54
|
+
}
|
|
55
|
+
for (const [name, { tool, signature }] of this.registered) {
|
|
56
|
+
if (wanted.get(name) && JSON.stringify(wanted.get(name)) === signature)
|
|
57
|
+
continue;
|
|
58
|
+
tool.remove();
|
|
59
|
+
this.registered.delete(name);
|
|
60
|
+
}
|
|
61
|
+
for (const [name, info] of wanted) {
|
|
62
|
+
if (this.registered.has(name))
|
|
63
|
+
continue;
|
|
64
|
+
let tool;
|
|
65
|
+
try {
|
|
66
|
+
tool = this.server.registerTool(name, {
|
|
67
|
+
title: info.title,
|
|
68
|
+
description: `${info.description}
|
|
69
|
+
|
|
70
|
+
From the plugin ${info.plugin}, through the client's dev server.`,
|
|
71
|
+
inputSchema: inputSchema(info.input),
|
|
72
|
+
annotations: annotations(info)
|
|
73
|
+
}, (args) => run(() => this.client.callPluginTool(name, args)));
|
|
74
|
+
} catch (err) {
|
|
75
|
+
if (!this.warned.has(name))
|
|
76
|
+
this.options.warn?.(`${info.plugin}: tool ${name} left out: ${err.message}`);
|
|
77
|
+
this.warned.add(name);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
this.registered.set(name, {
|
|
81
|
+
tool,
|
|
82
|
+
signature: JSON.stringify(info)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Ask again every `intervalMs`, so plugin tools come and go with the dev server. Returns a function that stops it */
|
|
87
|
+
watch(intervalMs = 5e3) {
|
|
88
|
+
const timer = setInterval(() => void this.refresh().catch(() => {
|
|
89
|
+
}), intervalMs);
|
|
90
|
+
timer.unref?.();
|
|
91
|
+
return () => clearInterval(timer);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export {
|
|
95
|
+
ProjectPluginTools
|
|
96
|
+
};
|