@modootoday/pmcp 0.9.1 → 0.10.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 +177 -8
- package/dist/attachment-tU5FZrgZ.d.ts +17 -0
- package/dist/chunk-HNAVQG6R.js +1198 -0
- package/dist/chunk-JRSR4JBR.js +88 -0
- package/dist/chunk-MSTKY33C.js +147 -0
- package/dist/{chunk-VQHNG3KM.js → chunk-VRZFM2M5.js} +53 -75
- package/dist/chunk-XEH4ZGGJ.js +336 -0
- package/dist/chunk-XOH2CW6P.js +297 -0
- package/dist/{chunk-QCOJ3WCM.js → chunk-ZUFFVIHQ.js} +166 -117
- package/dist/cli.js +507 -74
- package/dist/config-CJ43_oBS.d.ts +49 -0
- package/dist/embed-BBhv3y5x.d.ts +53 -0
- package/dist/encoder-DGRy9skC.d.ts +36 -0
- package/dist/http.d.ts +7 -38
- package/dist/http.js +18 -7
- package/dist/index.d.ts +25 -44
- package/dist/index.js +31 -11
- package/dist/mailbox/index.d.ts +44 -0
- package/dist/mailbox/index.js +387 -0
- package/dist/{server-BBZDjzWZ.d.ts → server-CwWcRjqz.d.ts} +135 -15
- package/dist/service-qpCsOXkQ.d.ts +116 -0
- package/dist/stdio.d.ts +10 -4
- package/dist/stdio.js +9 -4
- package/package.json +5 -1
- package/dist/catalog-BU5VLLyd.d.ts +0 -121
- package/dist/chunk-7DD2ADL2.js +0 -160
- package/dist/chunk-AJYMOFVX.js +0 -41
- package/dist/chunk-R2QPKEI4.js +0 -134
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSkillServer
|
|
3
|
+
} from "./chunk-VRZFM2M5.js";
|
|
4
|
+
import {
|
|
5
|
+
attachMailbox
|
|
6
|
+
} from "./chunk-HNAVQG6R.js";
|
|
7
|
+
|
|
8
|
+
// src/stdio.ts
|
|
9
|
+
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
10
|
+
function resolveRoots(argv, cwd) {
|
|
11
|
+
const given = argv.filter((arg) => !arg.startsWith("-"));
|
|
12
|
+
return given.length > 0 ? given : [`${cwd}/node_modules`];
|
|
13
|
+
}
|
|
14
|
+
function serve(catalog, serving = {}) {
|
|
15
|
+
const options = {
|
|
16
|
+
...catalog,
|
|
17
|
+
...serving,
|
|
18
|
+
onReject: ({ path, reason }) => process.stderr.write(`pmcp: skipped ${path}: ${reason}
|
|
19
|
+
`),
|
|
20
|
+
onWarning: ({ path, reason }) => process.stderr.write(`pmcp: warning ${path}: ${reason}
|
|
21
|
+
`)
|
|
22
|
+
};
|
|
23
|
+
return serveStdio(() => createSkillServer(options), {
|
|
24
|
+
// stdout is the protocol. A diagnostic written there corrupts the stream,
|
|
25
|
+
// so out-of-band errors go to stderr and nowhere else.
|
|
26
|
+
onerror: (error) => process.stderr.write(`pmcp: ${error.message}
|
|
27
|
+
`)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function serveWithMailbox(catalog, mailbox, serving = {}) {
|
|
31
|
+
let stop;
|
|
32
|
+
const attachment = await attachMailbox({
|
|
33
|
+
...mailbox,
|
|
34
|
+
onExpired: () => {
|
|
35
|
+
process.stderr.write("pmcp: mailbox attachment expired or superseded\n");
|
|
36
|
+
void stop?.().catch(() => {
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
let handle;
|
|
42
|
+
try {
|
|
43
|
+
handle = serve(catalog, { ...serving, mailbox: attachment.service });
|
|
44
|
+
} catch (error) {
|
|
45
|
+
await attachment.close();
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
let shutdown;
|
|
49
|
+
const onExit = () => {
|
|
50
|
+
void stop().catch(() => {
|
|
51
|
+
process.exitCode = 1;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
stop = () => {
|
|
55
|
+
if (shutdown) return shutdown;
|
|
56
|
+
process.removeListener("SIGINT", onExit);
|
|
57
|
+
process.removeListener("SIGTERM", onExit);
|
|
58
|
+
process.stdin.removeListener("end", onExit);
|
|
59
|
+
shutdown = (async () => {
|
|
60
|
+
try {
|
|
61
|
+
await handle.close();
|
|
62
|
+
} finally {
|
|
63
|
+
await attachment.close();
|
|
64
|
+
}
|
|
65
|
+
})();
|
|
66
|
+
return shutdown;
|
|
67
|
+
};
|
|
68
|
+
process.once("SIGINT", onExit);
|
|
69
|
+
process.once("SIGTERM", onExit);
|
|
70
|
+
process.stdin.once("end", onExit);
|
|
71
|
+
return stop;
|
|
72
|
+
}
|
|
73
|
+
function main(argv = process.argv.slice(2)) {
|
|
74
|
+
const scopeArg = argv.find((arg) => arg.startsWith("--scope="));
|
|
75
|
+
const scopes = scopeArg ? scopeArg.slice("--scope=".length).split(",") : [];
|
|
76
|
+
serve({
|
|
77
|
+
roots: resolveRoots(argv, process.cwd()),
|
|
78
|
+
...scopes.length > 0 ? { scopes } : {}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
resolveRoots,
|
|
84
|
+
serve,
|
|
85
|
+
serveWithMailbox,
|
|
86
|
+
main
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=chunk-JRSR4JBR.js.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveEncoder
|
|
3
|
+
} from "./chunk-XOH2CW6P.js";
|
|
4
|
+
|
|
5
|
+
// src/config.ts
|
|
6
|
+
import { existsSync, readFileSync } from "fs";
|
|
7
|
+
import { dirname, join, resolve } from "path";
|
|
8
|
+
import { parse } from "smol-toml";
|
|
9
|
+
var CONFIG_FILE = "pmcp.toml";
|
|
10
|
+
function embeddingSection(path, dir, value) {
|
|
11
|
+
if (value === void 0) return void 0;
|
|
12
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
13
|
+
throw new ConfigError(path, "[embedding] must be a table");
|
|
14
|
+
const section = value;
|
|
15
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
16
|
+
"enabled",
|
|
17
|
+
"model",
|
|
18
|
+
"dtype",
|
|
19
|
+
"dimensions",
|
|
20
|
+
"revision",
|
|
21
|
+
"model_path",
|
|
22
|
+
"cache_dir",
|
|
23
|
+
"encoder"
|
|
24
|
+
]);
|
|
25
|
+
for (const key of Object.keys(section)) {
|
|
26
|
+
if (!allowed.has(key))
|
|
27
|
+
throw new ConfigError(path, `unknown key [embedding] ${key}`);
|
|
28
|
+
}
|
|
29
|
+
if (section.enabled !== void 0 && typeof section.enabled !== "boolean")
|
|
30
|
+
throw new ConfigError(path, "[embedding] enabled must be a boolean");
|
|
31
|
+
const string = (key) => {
|
|
32
|
+
const item = section[key];
|
|
33
|
+
if (item === void 0) return void 0;
|
|
34
|
+
if (typeof item !== "string" || !item.trim())
|
|
35
|
+
throw new ConfigError(
|
|
36
|
+
path,
|
|
37
|
+
`[embedding] ${key} must be a non-empty string`
|
|
38
|
+
);
|
|
39
|
+
return item;
|
|
40
|
+
};
|
|
41
|
+
let encoder;
|
|
42
|
+
if (section.encoder !== void 0) {
|
|
43
|
+
if (section.encoder === null || typeof section.encoder !== "object" || Array.isArray(section.encoder))
|
|
44
|
+
throw new ConfigError(path, "[embedding.encoder] must be a table");
|
|
45
|
+
const source = section.encoder;
|
|
46
|
+
const keys = /* @__PURE__ */ new Set([
|
|
47
|
+
"query_prefix",
|
|
48
|
+
"passage_prefix",
|
|
49
|
+
"pooling",
|
|
50
|
+
"projected"
|
|
51
|
+
]);
|
|
52
|
+
for (const key of Object.keys(source)) {
|
|
53
|
+
if (!keys.has(key))
|
|
54
|
+
throw new ConfigError(path, `unknown key [embedding.encoder] ${key}`);
|
|
55
|
+
}
|
|
56
|
+
encoder = {};
|
|
57
|
+
if (source.query_prefix !== void 0)
|
|
58
|
+
encoder = { ...encoder, queryPrefix: source.query_prefix };
|
|
59
|
+
if (source.passage_prefix !== void 0)
|
|
60
|
+
encoder = { ...encoder, passagePrefix: source.passage_prefix };
|
|
61
|
+
if (source.pooling !== void 0)
|
|
62
|
+
encoder = { ...encoder, pooling: source.pooling };
|
|
63
|
+
if (source.projected !== void 0)
|
|
64
|
+
encoder = { ...encoder, projected: source.projected };
|
|
65
|
+
}
|
|
66
|
+
const modelPath = string("model_path");
|
|
67
|
+
const cacheDir = string("cache_dir");
|
|
68
|
+
const result = {
|
|
69
|
+
modelId: string("model"),
|
|
70
|
+
dtype: string("dtype"),
|
|
71
|
+
dimensions: section.dimensions,
|
|
72
|
+
revision: string("revision"),
|
|
73
|
+
encoder,
|
|
74
|
+
enabled: section.enabled,
|
|
75
|
+
modelPath: modelPath === void 0 ? void 0 : resolve(dir, modelPath),
|
|
76
|
+
cacheDir: cacheDir === void 0 ? void 0 : resolve(dir, cacheDir)
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
resolveEncoder(result.modelId, result);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw new ConfigError(
|
|
82
|
+
path,
|
|
83
|
+
error instanceof Error ? error.message : "Invalid embedding configuration"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
var ConfigError = class extends Error {
|
|
89
|
+
constructor(path, message) {
|
|
90
|
+
super(`${path}: ${message}`);
|
|
91
|
+
this.name = "ConfigError";
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var PATH_KEYS = ["roots", "workspaces", "packages", "marketplaces"];
|
|
95
|
+
var CATALOG_KEYS = /* @__PURE__ */ new Set([...PATH_KEYS, "scopes"]);
|
|
96
|
+
function findConfig(start) {
|
|
97
|
+
let dir = resolve(start);
|
|
98
|
+
for (; ; ) {
|
|
99
|
+
const candidate = join(dir, CONFIG_FILE);
|
|
100
|
+
if (existsSync(candidate)) return candidate;
|
|
101
|
+
const parent = dirname(dir);
|
|
102
|
+
if (parent === dir) return null;
|
|
103
|
+
dir = parent;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function stringList(path, key, value) {
|
|
107
|
+
if (!Array.isArray(value) || !value.every((v) => typeof v === "string")) {
|
|
108
|
+
throw new ConfigError(path, `[catalog] ${key} must be a list of strings`);
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
function readConfig(path) {
|
|
113
|
+
const absolute = resolve(path);
|
|
114
|
+
const dir = dirname(absolute);
|
|
115
|
+
let raw;
|
|
116
|
+
try {
|
|
117
|
+
raw = parse(readFileSync(absolute, "utf8"));
|
|
118
|
+
} catch (error) {
|
|
119
|
+
const reason = error instanceof Error ? error.message : "unreadable";
|
|
120
|
+
throw new ConfigError(absolute, reason.split("\n")[0] ?? reason);
|
|
121
|
+
}
|
|
122
|
+
const section = raw["catalog"];
|
|
123
|
+
const embedding = embeddingSection(absolute, dir, raw.embedding);
|
|
124
|
+
const configured = embedding === void 0 ? {} : { embedding };
|
|
125
|
+
if (section === void 0)
|
|
126
|
+
return { path: absolute, dir, catalog: {}, raw, ...configured };
|
|
127
|
+
if (section === null || typeof section !== "object" || Array.isArray(section)) {
|
|
128
|
+
throw new ConfigError(absolute, "[catalog] must be a table");
|
|
129
|
+
}
|
|
130
|
+
const catalog = {};
|
|
131
|
+
for (const [key, value] of Object.entries(section)) {
|
|
132
|
+
if (!CATALOG_KEYS.has(key)) {
|
|
133
|
+
throw new ConfigError(absolute, `unknown key [catalog] ${key}`);
|
|
134
|
+
}
|
|
135
|
+
const list = stringList(absolute, key, value);
|
|
136
|
+
catalog[key] = key === "scopes" ? list : list.map((p) => resolve(dir, p));
|
|
137
|
+
}
|
|
138
|
+
return { path: absolute, dir, catalog, raw, ...configured };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
CONFIG_FILE,
|
|
143
|
+
ConfigError,
|
|
144
|
+
findConfig,
|
|
145
|
+
readConfig
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=chunk-MSTKY33C.js.map
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RUNTIMES,
|
|
3
|
+
detectRuntime,
|
|
4
|
+
registerMailboxTools,
|
|
5
|
+
verifiedRuntimesOf
|
|
6
|
+
} from "./chunk-XOH2CW6P.js";
|
|
7
|
+
|
|
1
8
|
// src/intent.ts
|
|
2
9
|
function normaliseIntent(intent) {
|
|
3
10
|
return intent.toLowerCase().replaceAll(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/u).filter(Boolean).join(" ");
|
|
@@ -935,6 +942,7 @@ function registerSkillResources(server, skills) {
|
|
|
935
942
|
}
|
|
936
943
|
|
|
937
944
|
// src/find.ts
|
|
945
|
+
import { createHash as createHash2 } from "crypto";
|
|
938
946
|
var DEFAULT_FIND_LIMIT = 5;
|
|
939
947
|
function tokens(text) {
|
|
940
948
|
return normaliseIntent(text).split(" ").filter(Boolean);
|
|
@@ -977,15 +985,17 @@ async function find(options) {
|
|
|
977
985
|
if (semantic) {
|
|
978
986
|
const embedder = options.embedder;
|
|
979
987
|
const vectors = options.vectors;
|
|
980
|
-
|
|
988
|
+
const namespace = createHash2("sha256").update(embedder.indexKey ?? embedder.modelId).digest("hex");
|
|
989
|
+
const cacheKey = `${namespace} ${normaliseIntent(options.intent)}`;
|
|
990
|
+
let query = options.cache?.get(cacheKey) ?? null;
|
|
981
991
|
if (!query) {
|
|
982
992
|
query = await embedder.embed(options.intent);
|
|
983
|
-
options.cache?.put(
|
|
993
|
+
options.cache?.put(cacheKey, query);
|
|
984
994
|
}
|
|
985
995
|
const scored = [];
|
|
986
996
|
for (const entry of options.entries) {
|
|
987
997
|
const vector = vectors.get(entry.name);
|
|
988
|
-
if (!vector) continue;
|
|
998
|
+
if (!vector || vector.length !== query.length) continue;
|
|
989
999
|
scored.push({
|
|
990
1000
|
name: entry.name,
|
|
991
1001
|
package: entry.package,
|
|
@@ -1035,44 +1045,6 @@ function bundleSkill(entry) {
|
|
|
1035
1045
|
};
|
|
1036
1046
|
}
|
|
1037
1047
|
|
|
1038
|
-
// src/runtime.ts
|
|
1039
|
-
import { CLIENT_INFO_META_KEY } from "@modelcontextprotocol/server";
|
|
1040
|
-
var RUNTIMES = [
|
|
1041
|
-
"claude-code",
|
|
1042
|
-
"codex-cli",
|
|
1043
|
-
"gemini-cli",
|
|
1044
|
-
"grok-cli",
|
|
1045
|
-
"antigravity"
|
|
1046
|
-
];
|
|
1047
|
-
var VERIFIED_RUNTIMES_KEY = "verified-runtimes";
|
|
1048
|
-
var isRuntime = (value) => RUNTIMES.includes(value);
|
|
1049
|
-
function verifiedRuntimesOf(metadata) {
|
|
1050
|
-
const raw = metadata?.[VERIFIED_RUNTIMES_KEY];
|
|
1051
|
-
if (raw === void 0) return [];
|
|
1052
|
-
const words = typeof raw === "string" ? raw.split(/[\s,]+/u) : Array.isArray(raw) ? raw.map((word) => String(word).trim()) : [];
|
|
1053
|
-
return [...new Set(words.filter(isRuntime))];
|
|
1054
|
-
}
|
|
1055
|
-
var CLIENT_PATTERNS = [
|
|
1056
|
-
[/claude[-_ ]?code/u, "claude-code"],
|
|
1057
|
-
[/codex/u, "codex-cli"],
|
|
1058
|
-
[/gemini/u, "gemini-cli"],
|
|
1059
|
-
[/grok/u, "grok-cli"],
|
|
1060
|
-
[/antigravity/u, "antigravity"]
|
|
1061
|
-
];
|
|
1062
|
-
function runtimeOfClient(name) {
|
|
1063
|
-
if (!name) return null;
|
|
1064
|
-
const lower = name.toLowerCase();
|
|
1065
|
-
for (const [pattern, runtime] of CLIENT_PATTERNS)
|
|
1066
|
-
if (pattern.test(lower)) return runtime;
|
|
1067
|
-
return null;
|
|
1068
|
-
}
|
|
1069
|
-
function detectRuntime(server, ctx) {
|
|
1070
|
-
const envelope = ctx?.mcpReq?.envelope;
|
|
1071
|
-
const fromEnvelope = envelope?.[CLIENT_INFO_META_KEY]?.name;
|
|
1072
|
-
if (typeof fromEnvelope === "string") return runtimeOfClient(fromEnvelope);
|
|
1073
|
-
return runtimeOfClient(server.server?.getClientVersion?.()?.name);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
1048
|
// src/server.ts
|
|
1077
1049
|
import { readFileSync as readFileSync6 } from "fs";
|
|
1078
1050
|
var DESCRIBE_FILE_LIMIT = FILE_LIST_LIMIT;
|
|
@@ -1103,7 +1075,8 @@ function matches(entry, filters) {
|
|
|
1103
1075
|
}
|
|
1104
1076
|
return true;
|
|
1105
1077
|
}
|
|
1106
|
-
function verification(entry, runtime) {
|
|
1078
|
+
function verification(entry, runtime, asked) {
|
|
1079
|
+
if (!asked) return {};
|
|
1107
1080
|
const verifiedRuntimes = verifiedRuntimesOf(entry?.metadata);
|
|
1108
1081
|
return {
|
|
1109
1082
|
...verifiedRuntimes.length > 0 ? { verifiedRuntimes } : {},
|
|
@@ -1116,15 +1089,28 @@ function verifiedFirst(items) {
|
|
|
1116
1089
|
...items.filter((item) => item.verified !== true)
|
|
1117
1090
|
];
|
|
1118
1091
|
}
|
|
1119
|
-
function catalogItem(entry, runtime) {
|
|
1092
|
+
function catalogItem(entry, runtime, asked) {
|
|
1120
1093
|
return {
|
|
1121
1094
|
name: entry.name,
|
|
1122
1095
|
description: entry.description,
|
|
1123
1096
|
...entry.tier === void 0 ? {} : { tier: entry.tier },
|
|
1124
1097
|
...kindOf(entry) === "skill" ? {} : { kind: kindOf(entry) },
|
|
1125
|
-
...verification(entry, runtime)
|
|
1098
|
+
...verification(entry, runtime, asked)
|
|
1126
1099
|
};
|
|
1127
1100
|
}
|
|
1101
|
+
function flatMetadata(metadata) {
|
|
1102
|
+
const flat = {};
|
|
1103
|
+
for (const [key, value] of Object.entries(metadata ?? {})) {
|
|
1104
|
+
if (typeof value === "string" || Array.isArray(value)) {
|
|
1105
|
+
flat[key] = value;
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
for (const [inner, leaf] of Object.entries(value ?? {})) {
|
|
1109
|
+
flat[`${key}.${inner}`] = leaf;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
return flat;
|
|
1113
|
+
}
|
|
1128
1114
|
function createSkillTools(options) {
|
|
1129
1115
|
const load = options.loadCatalog ?? readCatalog;
|
|
1130
1116
|
let entries = null;
|
|
@@ -1149,6 +1135,7 @@ function createSkillTools(options) {
|
|
|
1149
1135
|
catalog(request = {}) {
|
|
1150
1136
|
const client = options.rankByClientRuntime ? request.clientRuntime : null;
|
|
1151
1137
|
const runtime = request.runtime ?? client ?? null;
|
|
1138
|
+
const asked = runtime !== null || request.verifiedOnly !== void 0;
|
|
1152
1139
|
const byPackage = /* @__PURE__ */ new Map();
|
|
1153
1140
|
let count = 0;
|
|
1154
1141
|
for (const entry of catalog()) {
|
|
@@ -1161,7 +1148,7 @@ function createSkillTools(options) {
|
|
|
1161
1148
|
continue;
|
|
1162
1149
|
count += 1;
|
|
1163
1150
|
const list = byPackage.get(entry.package) ?? [];
|
|
1164
|
-
list.push(catalogItem(entry, runtime));
|
|
1151
|
+
list.push(catalogItem(entry, runtime, asked));
|
|
1165
1152
|
byPackage.set(entry.package, list);
|
|
1166
1153
|
}
|
|
1167
1154
|
const groups = [...byPackage.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([pkg, skills]) => [
|
|
@@ -1186,6 +1173,7 @@ function createSkillTools(options) {
|
|
|
1186
1173
|
find(intent, limit, filters, clientRuntime) {
|
|
1187
1174
|
const client = options.rankByClientRuntime ? clientRuntime : null;
|
|
1188
1175
|
const runtime = filters?.runtime ?? client ?? null;
|
|
1176
|
+
const asked = runtime !== null || filters?.verifiedOnly !== void 0;
|
|
1189
1177
|
const scoped = catalog().filter((entry) => matches(entry, filters)).map(
|
|
1190
1178
|
(entry) => entry.keywords && entry.keywords.length > 0 ? {
|
|
1191
1179
|
...entry,
|
|
@@ -1205,13 +1193,13 @@ function createSkillTools(options) {
|
|
|
1205
1193
|
return {
|
|
1206
1194
|
...match,
|
|
1207
1195
|
description: entry?.description ?? match.description,
|
|
1208
|
-
...verification(entry, runtime)
|
|
1196
|
+
...verification(entry, runtime, asked)
|
|
1209
1197
|
};
|
|
1210
1198
|
});
|
|
1211
1199
|
const ordered = runtime === null ? marked : verifiedFirst(marked);
|
|
1212
1200
|
return {
|
|
1213
1201
|
...result,
|
|
1214
|
-
runtime,
|
|
1202
|
+
...asked ? { runtime } : {},
|
|
1215
1203
|
matches: runtime === null ? ordered : ordered.slice(0, limit ?? DEFAULT_FIND_LIMIT)
|
|
1216
1204
|
};
|
|
1217
1205
|
});
|
|
@@ -1228,9 +1216,9 @@ function createSkillTools(options) {
|
|
|
1228
1216
|
package: entry.package,
|
|
1229
1217
|
description: entry.description,
|
|
1230
1218
|
...entry.tier === void 0 ? {} : { tier: entry.tier },
|
|
1231
|
-
metadata: entry.metadata
|
|
1219
|
+
metadata: flatMetadata(entry.metadata),
|
|
1232
1220
|
frontmatter: readFrontmatterText(source),
|
|
1233
|
-
files:
|
|
1221
|
+
files: listing2.files.map((file) => ({ ...file })),
|
|
1234
1222
|
filesTruncated: listing2.truncated
|
|
1235
1223
|
};
|
|
1236
1224
|
},
|
|
@@ -1276,7 +1264,7 @@ function createSkillTools(options) {
|
|
|
1276
1264
|
}
|
|
1277
1265
|
|
|
1278
1266
|
// src/extension/entry.ts
|
|
1279
|
-
import { createHash as
|
|
1267
|
+
import { createHash as createHash3 } from "crypto";
|
|
1280
1268
|
import { readFileSync as readFileSync7, readdirSync as readdirSync4, statSync as statSync6 } from "fs";
|
|
1281
1269
|
import { basename as basename5, dirname as dirname5, join as join5, relative as relative4, sep as sep3 } from "path";
|
|
1282
1270
|
var MAX_RESOURCES = 512;
|
|
@@ -1288,7 +1276,7 @@ function facts(path) {
|
|
|
1288
1276
|
const cached = digests.get(path);
|
|
1289
1277
|
if (cached?.key === key) return cached;
|
|
1290
1278
|
const bytes = servedBytes(path, readFileSync7(path));
|
|
1291
|
-
const digest = `sha256:${
|
|
1279
|
+
const digest = `sha256:${createHash3("sha256").update(bytes).digest("hex")}`;
|
|
1292
1280
|
const fresh = { key, digest, size: bytes.length };
|
|
1293
1281
|
digests.set(path, fresh);
|
|
1294
1282
|
return fresh;
|
|
@@ -1404,7 +1392,7 @@ function registerSkillsExtension(server, skills, options = {}) {
|
|
|
1404
1392
|
import { z as z3 } from "zod";
|
|
1405
1393
|
var kind = z3.enum(ASSET_KINDS);
|
|
1406
1394
|
var runtimeSchema = z3.enum(RUNTIMES);
|
|
1407
|
-
var catalogItemSchema = z3.
|
|
1395
|
+
var catalogItemSchema = z3.looseObject({
|
|
1408
1396
|
name: z3.string(),
|
|
1409
1397
|
description: z3.string(),
|
|
1410
1398
|
tier: z3.string().optional(),
|
|
@@ -1412,20 +1400,20 @@ var catalogItemSchema = z3.object({
|
|
|
1412
1400
|
verifiedRuntimes: z3.array(runtimeSchema).optional(),
|
|
1413
1401
|
verified: z3.boolean().optional()
|
|
1414
1402
|
});
|
|
1415
|
-
var catalogResponseSchema = z3.
|
|
1403
|
+
var catalogResponseSchema = z3.looseObject({
|
|
1416
1404
|
count: z3.number().int(),
|
|
1417
1405
|
page: z3.number().int(),
|
|
1418
1406
|
totalPages: z3.number().int(),
|
|
1419
1407
|
hasNext: z3.boolean(),
|
|
1420
1408
|
packages: z3.array(
|
|
1421
|
-
z3.
|
|
1409
|
+
z3.looseObject({ package: z3.string(), skills: z3.array(catalogItemSchema) })
|
|
1422
1410
|
)
|
|
1423
1411
|
});
|
|
1424
|
-
var findResultSchema = z3.
|
|
1412
|
+
var findResultSchema = z3.looseObject({
|
|
1425
1413
|
ranking: z3.enum(["semantic", "lexical"]),
|
|
1426
|
-
runtime: runtimeSchema.nullable(),
|
|
1414
|
+
runtime: runtimeSchema.nullable().optional(),
|
|
1427
1415
|
matches: z3.array(
|
|
1428
|
-
z3.
|
|
1416
|
+
z3.looseObject({
|
|
1429
1417
|
name: z3.string(),
|
|
1430
1418
|
package: z3.string(),
|
|
1431
1419
|
description: z3.string(),
|
|
@@ -1435,16 +1423,12 @@ var findResultSchema = z3.object({
|
|
|
1435
1423
|
})
|
|
1436
1424
|
)
|
|
1437
1425
|
});
|
|
1438
|
-
var skillFileSchema = z3.
|
|
1426
|
+
var skillFileSchema = z3.looseObject({
|
|
1439
1427
|
path: z3.string(),
|
|
1440
1428
|
bytes: z3.number().int(),
|
|
1441
1429
|
sha256: z3.string()
|
|
1442
1430
|
});
|
|
1443
|
-
var
|
|
1444
|
-
z3.string(),
|
|
1445
|
-
z3.array(z3.string()).readonly()
|
|
1446
|
-
]);
|
|
1447
|
-
var describeResponseSchema = z3.object({
|
|
1431
|
+
var describeResponseSchema = z3.looseObject({
|
|
1448
1432
|
name: z3.string(),
|
|
1449
1433
|
kind,
|
|
1450
1434
|
package: z3.string(),
|
|
@@ -1452,16 +1436,13 @@ var describeResponseSchema = z3.object({
|
|
|
1452
1436
|
tier: z3.string().optional(),
|
|
1453
1437
|
metadata: z3.record(
|
|
1454
1438
|
z3.string(),
|
|
1455
|
-
z3.union([
|
|
1456
|
-
metadataLeafSchema,
|
|
1457
|
-
z3.record(z3.string(), metadataLeafSchema).readonly()
|
|
1458
|
-
])
|
|
1439
|
+
z3.union([z3.string(), z3.array(z3.string()).readonly()])
|
|
1459
1440
|
),
|
|
1460
1441
|
frontmatter: z3.string(),
|
|
1461
1442
|
files: z3.array(skillFileSchema),
|
|
1462
1443
|
filesTruncated: z3.boolean()
|
|
1463
1444
|
});
|
|
1464
|
-
var bundleResponseSchema = z3.
|
|
1445
|
+
var bundleResponseSchema = z3.looseObject({
|
|
1465
1446
|
name: z3.string(),
|
|
1466
1447
|
truncated: z3.boolean(),
|
|
1467
1448
|
files: z3.array(
|
|
@@ -1641,7 +1622,7 @@ function registerDescribeTool(server, tools) {
|
|
|
1641
1622
|
"skill_describe",
|
|
1642
1623
|
{
|
|
1643
1624
|
...readOnlyTool("Describe a skill"),
|
|
1644
|
-
description: "One skill's frontmatter, metadata (tier, level, requirements as
|
|
1625
|
+
description: "One skill's frontmatter, metadata (tier, level, requirements as requires.<name> entries, verified-runtimes, licence, approval), and the files it carries with sizes and sha256, without any body.",
|
|
1645
1626
|
inputSchema: z8.object({ name: skillNameInput }),
|
|
1646
1627
|
outputSchema: describeResponseSchema
|
|
1647
1628
|
},
|
|
@@ -1718,7 +1699,7 @@ function registerReadTool(server, tools) {
|
|
|
1718
1699
|
|
|
1719
1700
|
// src/mcp.ts
|
|
1720
1701
|
var SERVER_NAME = "pmcp";
|
|
1721
|
-
var SERVER_VERSION = "0.
|
|
1702
|
+
var SERVER_VERSION = "0.10.0";
|
|
1722
1703
|
function registerSkillTools(server, tools) {
|
|
1723
1704
|
registerCatalogTool(server, tools);
|
|
1724
1705
|
registerFindTool(server, tools);
|
|
@@ -1734,6 +1715,7 @@ function createSkillServer(options) {
|
|
|
1734
1715
|
registerSkillsExtension(server, tools.skills, options.skillsExtension);
|
|
1735
1716
|
registerSkillResources(server, tools.skills);
|
|
1736
1717
|
if (options.prompts) registerSkillPrompts(server, tools);
|
|
1718
|
+
if (options.mailbox) registerMailboxTools(server, options.mailbox);
|
|
1737
1719
|
return registerSkillTools(server, tools);
|
|
1738
1720
|
}
|
|
1739
1721
|
|
|
@@ -1773,10 +1755,6 @@ export {
|
|
|
1773
1755
|
cosine,
|
|
1774
1756
|
find,
|
|
1775
1757
|
bundleSkill,
|
|
1776
|
-
RUNTIMES,
|
|
1777
|
-
verifiedRuntimesOf,
|
|
1778
|
-
runtimeOfClient,
|
|
1779
|
-
detectRuntime,
|
|
1780
1758
|
DESCRIBE_FILE_LIMIT,
|
|
1781
1759
|
CATALOG_PAGE_SIZE,
|
|
1782
1760
|
CATALOG_PAGE_MAX,
|
|
@@ -1793,4 +1771,4 @@ export {
|
|
|
1793
1771
|
registerSkillTools,
|
|
1794
1772
|
createSkillServer
|
|
1795
1773
|
};
|
|
1796
|
-
//# sourceMappingURL=chunk-
|
|
1774
|
+
//# sourceMappingURL=chunk-VRZFM2M5.js.map
|