mioku 1.2.3 → 1.3.1
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/cli/index.cjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{exec-CniJOLOF.cjs → exec-BoUCPBk_.cjs} +2 -2
- package/dist/exec-BoUCPBk_.cjs.map +1 -0
- package/dist/{exec-BPj3FRdI.js → exec-C_iMY_-7.js} +2 -2
- package/dist/exec-C_iMY_-7.js.map +1 -0
- package/dist/index.cjs +962 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +267 -18
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +267 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +985 -161
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/exec-BPj3FRdI.js.map +0 -1
- package/dist/exec-CniJOLOF.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_exec = require('./exec-
|
|
1
|
+
const require_exec = require('./exec-BoUCPBk_.cjs');
|
|
2
2
|
const node_fs = require_exec.__toESM(require("node:fs"));
|
|
3
3
|
const node_path = require_exec.__toESM(require("node:path"));
|
|
4
4
|
const node_url = require_exec.__toESM(require("node:url"));
|
|
@@ -23,6 +23,8 @@ const node_os = require_exec.__toESM(require("node:os"));
|
|
|
23
23
|
const node_child_process = require_exec.__toESM(require("node:child_process"));
|
|
24
24
|
const node_module = require_exec.__toESM(require("node:module"));
|
|
25
25
|
const jiti = require_exec.__toESM(require("jiti"));
|
|
26
|
+
const yaml = require_exec.__toESM(require("yaml"));
|
|
27
|
+
const node_fs_promises = require_exec.__toESM(require("node:fs/promises"));
|
|
26
28
|
|
|
27
29
|
//#region src/config.ts
|
|
28
30
|
/** 当前机器人根目录,包一层对象以便整体重定向 */
|
|
@@ -170,8 +172,8 @@ const RAW_TEXT_DECODER = new TextDecoder();
|
|
|
170
172
|
const decodeBody = async (response) => {
|
|
171
173
|
const arrayBuffer = await response.arrayBuffer();
|
|
172
174
|
const headers = {};
|
|
173
|
-
response.headers.forEach((value, key) => {
|
|
174
|
-
headers[key.toLowerCase()] = value;
|
|
175
|
+
response.headers.forEach((value, key$1) => {
|
|
176
|
+
headers[key$1.toLowerCase()] = value;
|
|
175
177
|
});
|
|
176
178
|
return {
|
|
177
179
|
body: new Uint8Array(arrayBuffer),
|
|
@@ -842,8 +844,8 @@ const definePlugin = (plugin) => plugin;
|
|
|
842
844
|
//#endregion
|
|
843
845
|
//#region src/runtime/context.ts
|
|
844
846
|
var AdapterRegistrationConflictError = class extends Error {
|
|
845
|
-
constructor(key) {
|
|
846
|
-
super(`Bot already registered for ${key}`);
|
|
847
|
+
constructor(key$1) {
|
|
848
|
+
super(`Bot already registered for ${key$1}`);
|
|
847
849
|
this.name = "AdapterRegistrationConflictError";
|
|
848
850
|
}
|
|
849
851
|
};
|
|
@@ -918,8 +920,8 @@ var AdapterContextImpl = class {
|
|
|
918
920
|
if (!gateway) throw new Error(`Resource references unknown gateway "${resource.gateway}"`);
|
|
919
921
|
}
|
|
920
922
|
if (resource.scope === "bot") {
|
|
921
|
-
const key = `${this.#state.definition.name}:${resource.bot_id}`;
|
|
922
|
-
if (!this.#bots.has(key)) throw new Error(`Resource references unknown bot "${resource.bot_id}"`);
|
|
923
|
+
const key$1 = `${this.#state.definition.name}:${resource.bot_id}`;
|
|
924
|
+
if (!this.#bots.has(key$1)) throw new Error(`Resource references unknown bot "${resource.bot_id}"`);
|
|
923
925
|
}
|
|
924
926
|
this.#state.resources.push(resource);
|
|
925
927
|
return () => {
|
|
@@ -938,17 +940,17 @@ var AdapterContextImpl = class {
|
|
|
938
940
|
const senderBot = this.#bots.pick(senderId);
|
|
939
941
|
if (senderBot && senderBot.bot_id !== event.self_id) {
|
|
940
942
|
this.#logger.debug(`拦截来自其他已连接 bot 的消息: sender=${senderId} self=${event.self_id}`);
|
|
941
|
-
return;
|
|
943
|
+
return false;
|
|
942
944
|
}
|
|
943
945
|
}
|
|
944
946
|
}
|
|
945
947
|
if (event.kind === "message") {
|
|
946
948
|
const duplicate = this.#correlator?.observationOf(event)?.duplicate ?? false;
|
|
947
949
|
if (!duplicate) {
|
|
948
|
-
if (await this.#commands.dispatch(event)) return;
|
|
950
|
+
if (await this.#commands.dispatch(event)) return true;
|
|
949
951
|
}
|
|
950
952
|
}
|
|
951
|
-
|
|
953
|
+
return this.#bus.dispatch(event);
|
|
952
954
|
}
|
|
953
955
|
listen(route, handler) {
|
|
954
956
|
return this.#bus.register(route, handler, {
|
|
@@ -972,10 +974,10 @@ function store$2() {
|
|
|
972
974
|
if (!g[STORE_SYMBOL]) g[STORE_SYMBOL] = {};
|
|
973
975
|
return g[STORE_SYMBOL];
|
|
974
976
|
}
|
|
975
|
-
function getOrCreate(key, factory) {
|
|
977
|
+
function getOrCreate(key$1, factory) {
|
|
976
978
|
const s = store$2();
|
|
977
|
-
if (s[key] === void 0) s[key] = factory();
|
|
978
|
-
return s[key];
|
|
979
|
+
if (s[key$1] === void 0) s[key$1] = factory();
|
|
980
|
+
return s[key$1];
|
|
979
981
|
}
|
|
980
982
|
|
|
981
983
|
//#endregion
|
|
@@ -993,37 +995,37 @@ var BotRegistry = class {
|
|
|
993
995
|
#disposers = new Map();
|
|
994
996
|
/** 登记一个 bot,返回可注销的上下文 */
|
|
995
997
|
register(bot) {
|
|
996
|
-
const key = connectedBotKey(bot.adapter, bot.bot_id);
|
|
997
|
-
if (this.#bots.has(key)) throw new AdapterRegistrationConflictError(key);
|
|
998
|
-
this.#bots.set(key, {
|
|
998
|
+
const key$1 = connectedBotKey(bot.adapter, bot.bot_id);
|
|
999
|
+
if (this.#bots.has(key$1)) throw new AdapterRegistrationConflictError(key$1);
|
|
1000
|
+
this.#bots.set(key$1, {
|
|
999
1001
|
adapter: bot.adapter,
|
|
1000
1002
|
bot_id: bot.bot_id,
|
|
1001
1003
|
bot
|
|
1002
1004
|
});
|
|
1003
|
-
connectedBots.set(key, bot);
|
|
1005
|
+
connectedBots.set(key$1, bot);
|
|
1004
1006
|
const dispose = () => {
|
|
1005
1007
|
this.unregister(bot.bot_id, bot.adapter);
|
|
1006
1008
|
};
|
|
1007
|
-
this.#disposers.set(key, dispose);
|
|
1009
|
+
this.#disposers.set(key$1, dispose);
|
|
1008
1010
|
return {
|
|
1009
1011
|
bot,
|
|
1010
1012
|
unregister: dispose
|
|
1011
1013
|
};
|
|
1012
1014
|
}
|
|
1013
|
-
has(key) {
|
|
1014
|
-
return this.#bots.has(key);
|
|
1015
|
+
has(key$1) {
|
|
1016
|
+
return this.#bots.has(key$1);
|
|
1015
1017
|
}
|
|
1016
1018
|
unregister(bot_id, adapter) {
|
|
1017
|
-
const key = connectedBotKey(adapter, bot_id);
|
|
1018
|
-
const removed = this.#bots.delete(key);
|
|
1019
|
-
this.#disposers.delete(key);
|
|
1020
|
-
connectedBots.delete(key);
|
|
1019
|
+
const key$1 = connectedBotKey(adapter, bot_id);
|
|
1020
|
+
const removed = this.#bots.delete(key$1);
|
|
1021
|
+
this.#disposers.delete(key$1);
|
|
1022
|
+
connectedBots.delete(key$1);
|
|
1021
1023
|
return removed;
|
|
1022
1024
|
}
|
|
1023
1025
|
/** 按 bot_id 取 bot(只按 id 匹配,不限适配器) */
|
|
1024
1026
|
pick(bot_id) {
|
|
1025
|
-
const key = String(bot_id);
|
|
1026
|
-
for (const entry of this.#bots.values()) if (entry.bot_id === key) return entry.bot;
|
|
1027
|
+
const key$1 = String(bot_id);
|
|
1028
|
+
for (const entry of this.#bots.values()) if (entry.bot_id === key$1) return entry.bot;
|
|
1027
1029
|
return void 0;
|
|
1028
1030
|
}
|
|
1029
1031
|
find(adapter, bot_id) {
|
|
@@ -1119,10 +1121,16 @@ var EventBus = class {
|
|
|
1119
1121
|
}
|
|
1120
1122
|
return matched;
|
|
1121
1123
|
}
|
|
1122
|
-
/**
|
|
1124
|
+
/**
|
|
1125
|
+
* 按优先级顺序把事件交给监听器,返回是否有人认领。
|
|
1126
|
+
*
|
|
1127
|
+
* 每个优先级组内按注册顺序逐个执行。handler 返回 `true` 即结束派发;
|
|
1128
|
+
* 返回 `undefined` / `false` 则继续交给后续监听器,全部不认领时静默结束。
|
|
1129
|
+
* 单个监听器出错只记日志,不影响后续监听器。
|
|
1130
|
+
*/
|
|
1123
1131
|
async dispatch(event) {
|
|
1124
1132
|
const matched = this.#matching(event);
|
|
1125
|
-
if (matched.length === 0) return;
|
|
1133
|
+
if (matched.length === 0) return false;
|
|
1126
1134
|
this.#dispatched++;
|
|
1127
1135
|
const priorityGroups = new Map();
|
|
1128
1136
|
for (const reg of matched) {
|
|
@@ -1133,9 +1141,21 @@ var EventBus = class {
|
|
|
1133
1141
|
const sortedPriorities = Array.from(priorityGroups.entries()).sort(([a], [b]) => a - b);
|
|
1134
1142
|
for (const [, regs] of sortedPriorities) {
|
|
1135
1143
|
regs.sort((a, b) => a.order - b.order);
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1144
|
+
for (const reg of regs) {
|
|
1145
|
+
if (reg.disposed) continue;
|
|
1146
|
+
const claimed = await this.#invoke(reg, event);
|
|
1147
|
+
if (claimed) return true;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
/** 执行单个监听器;返回它是否认领了这条事件,抛错按未认领处理 */
|
|
1153
|
+
async #invoke(reg, event) {
|
|
1154
|
+
try {
|
|
1155
|
+
return await reg.handler(event) === true;
|
|
1156
|
+
} catch (err) {
|
|
1157
|
+
this.#logger?.("error", `Event handler "${reg.source}" for route "${reg.route}" failed`, err);
|
|
1158
|
+
return false;
|
|
1139
1159
|
}
|
|
1140
1160
|
}
|
|
1141
1161
|
stats() {
|
|
@@ -1385,23 +1405,23 @@ const getGTk = (pskey) => {
|
|
|
1385
1405
|
*/
|
|
1386
1406
|
const match = async (event, pattern, quote = true) => {
|
|
1387
1407
|
const inputText = event.message.text();
|
|
1388
|
-
for (const [key, value] of Object.entries(pattern)) {
|
|
1408
|
+
for (const [key$1, value] of Object.entries(pattern)) {
|
|
1389
1409
|
let isMatched = false;
|
|
1390
1410
|
let matches = null;
|
|
1391
|
-
const isRegExp = key.startsWith("/") && key.endsWith("/");
|
|
1392
|
-
const hasWildcard = key.includes("*");
|
|
1411
|
+
const isRegExp = key$1.startsWith("/") && key$1.endsWith("/");
|
|
1412
|
+
const hasWildcard = key$1.includes("*");
|
|
1393
1413
|
if (isRegExp) try {
|
|
1394
|
-
const regex = new RegExp(key.slice(1, -1));
|
|
1414
|
+
const regex = new RegExp(key$1.slice(1, -1));
|
|
1395
1415
|
matches = inputText.match(regex);
|
|
1396
1416
|
if (matches) isMatched = true;
|
|
1397
1417
|
} catch (err) {
|
|
1398
|
-
throw new Error(`无效的正则表达式: ${key}`, { cause: err });
|
|
1418
|
+
throw new Error(`无效的正则表达式: ${key$1}`, { cause: err });
|
|
1399
1419
|
}
|
|
1400
1420
|
else if (hasWildcard) {
|
|
1401
|
-
const regex = new RegExp(`^${key.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`);
|
|
1421
|
+
const regex = new RegExp(`^${key$1.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`);
|
|
1402
1422
|
matches = inputText.match(regex);
|
|
1403
1423
|
if (matches) isMatched = true;
|
|
1404
|
-
} else if (key === inputText) isMatched = true;
|
|
1424
|
+
} else if (key$1 === inputText) isMatched = true;
|
|
1405
1425
|
if (!isMatched) continue;
|
|
1406
1426
|
const result = typeof value === "function" ? await value(matches, event) : value;
|
|
1407
1427
|
if (result) {
|
|
@@ -1874,6 +1894,47 @@ var ServiceManager = class ServiceManager {
|
|
|
1874
1894
|
};
|
|
1875
1895
|
var manager_default = ServiceManager.getInstance();
|
|
1876
1896
|
|
|
1897
|
+
//#endregion
|
|
1898
|
+
//#region src/services/config-defaults.ts
|
|
1899
|
+
const defaults = new Map();
|
|
1900
|
+
function key(scope, owner, name) {
|
|
1901
|
+
return `${scope}\u0000${owner}\u0000${name}`;
|
|
1902
|
+
}
|
|
1903
|
+
/** 登记一份配置的默认值;同名重复登记以最后一次为准 */
|
|
1904
|
+
function registerConfigDefaults(scope, owner, name, value) {
|
|
1905
|
+
if (!value || typeof value !== "object") return;
|
|
1906
|
+
defaults.set(key(scope, owner, name), clone(value));
|
|
1907
|
+
}
|
|
1908
|
+
/** 取默认值(深拷贝,调用方随便改);没有登记时返回 undefined */
|
|
1909
|
+
function getConfigDefaults(scope, owner, name) {
|
|
1910
|
+
const stored = defaults.get(key(scope, owner, name));
|
|
1911
|
+
return stored ? clone(stored) : void 0;
|
|
1912
|
+
}
|
|
1913
|
+
function isPlainObject$1(value) {
|
|
1914
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1915
|
+
}
|
|
1916
|
+
function clone(value) {
|
|
1917
|
+
return JSON.parse(JSON.stringify(value));
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* 用默认值补齐一份配置
|
|
1921
|
+
*/
|
|
1922
|
+
function withConfigDefaults(stored, fallback) {
|
|
1923
|
+
const base = fallback ? clone(fallback) : {};
|
|
1924
|
+
return mergeInto(base, stored);
|
|
1925
|
+
}
|
|
1926
|
+
function mergeInto(base, overrides) {
|
|
1927
|
+
if (!isPlainObject$1(overrides)) return base;
|
|
1928
|
+
for (const [name, value] of Object.entries(overrides)) {
|
|
1929
|
+
if (value === void 0 || value === null) continue;
|
|
1930
|
+
if (isPlainObject$1(value)) {
|
|
1931
|
+
const current = base[name];
|
|
1932
|
+
base[name] = mergeInto(isPlainObject$1(current) ? current : {}, value);
|
|
1933
|
+
} else base[name] = Array.isArray(value) ? [...value] : value;
|
|
1934
|
+
}
|
|
1935
|
+
return base;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1877
1938
|
//#endregion
|
|
1878
1939
|
//#region src/services/config.ts
|
|
1879
1940
|
const SERVICE_CONFIG_ROOT = "service";
|
|
@@ -1888,21 +1949,35 @@ function ensureDir(serviceName) {
|
|
|
1888
1949
|
const dir = resolveConfigDir(serviceName);
|
|
1889
1950
|
if (!(0, fs.existsSync)(dir)) (0, fs.mkdirSync)(dir, { recursive: true });
|
|
1890
1951
|
}
|
|
1891
|
-
/**
|
|
1892
|
-
|
|
1952
|
+
/**
|
|
1953
|
+
* 注册服务配
|
|
1954
|
+
*/
|
|
1955
|
+
async function registerServiceConfig(serviceName, configName, defaults$1) {
|
|
1893
1956
|
ensureDir(serviceName);
|
|
1957
|
+
registerConfigDefaults("service", serviceName, configName, defaults$1);
|
|
1894
1958
|
const configPath = resolveConfigPath(serviceName, configName);
|
|
1895
|
-
if (!(0, fs.existsSync)(configPath))
|
|
1959
|
+
if (!(0, fs.existsSync)(configPath)) {
|
|
1960
|
+
await fs_promises.writeFile(configPath, JSON.stringify(defaults$1, null, 2), "utf-8");
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
try {
|
|
1964
|
+
const existing = JSON.parse(await fs_promises.readFile(configPath, "utf-8"));
|
|
1965
|
+
const merged = withConfigDefaults(existing, defaults$1);
|
|
1966
|
+
if (JSON.stringify(merged) !== JSON.stringify(existing)) await fs_promises.writeFile(configPath, JSON.stringify(merged, null, 2), "utf-8");
|
|
1967
|
+
} catch (error) {
|
|
1968
|
+
rootLogger.warn(`[service-config] 补全 ${serviceName}/${configName} 失败: ${error}`);
|
|
1969
|
+
}
|
|
1896
1970
|
}
|
|
1897
1971
|
/** 读取服务配置,文件不存在或解析失败时返回空对象 */
|
|
1898
1972
|
async function getServiceConfig(serviceName, configName) {
|
|
1899
1973
|
const configPath = resolveConfigPath(serviceName, configName);
|
|
1974
|
+
const fallback = getConfigDefaults("service", serviceName, configName);
|
|
1900
1975
|
try {
|
|
1901
|
-
return JSON.parse(await fs_promises.readFile(configPath, "utf-8"));
|
|
1976
|
+
return withConfigDefaults(JSON.parse(await fs_promises.readFile(configPath, "utf-8")), fallback);
|
|
1902
1977
|
} catch (error) {
|
|
1903
|
-
if (!(0, fs.existsSync)(configPath)) return {};
|
|
1978
|
+
if (!(0, fs.existsSync)(configPath)) return fallback ?? {};
|
|
1904
1979
|
rootLogger.warn(`[service-config] 读取 ${serviceName}/${configName} 失败: ${error}`);
|
|
1905
|
-
return {};
|
|
1980
|
+
return fallback ?? {};
|
|
1906
1981
|
}
|
|
1907
1982
|
}
|
|
1908
1983
|
/** 覆盖写入服务配置 */
|
|
@@ -1916,10 +1991,13 @@ async function getServiceConfigs(serviceName) {
|
|
|
1916
1991
|
if (!(0, fs.existsSync)(dir)) return {};
|
|
1917
1992
|
const result = {};
|
|
1918
1993
|
const files = (await fs_promises.readdir(dir)).filter((name) => name.endsWith(".json"));
|
|
1919
|
-
for (const file of files)
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1994
|
+
for (const file of files) {
|
|
1995
|
+
const configName = path.basename(file, ".json");
|
|
1996
|
+
try {
|
|
1997
|
+
result[configName] = withConfigDefaults(JSON.parse(await fs_promises.readFile(path.join(dir, file), "utf-8")), getConfigDefaults("service", serviceName, configName));
|
|
1998
|
+
} catch (error) {
|
|
1999
|
+
rootLogger.warn(`[service-config] 读取 ${serviceName}/${file} 失败: ${error}`);
|
|
2000
|
+
}
|
|
1923
2001
|
}
|
|
1924
2002
|
return result;
|
|
1925
2003
|
}
|
|
@@ -2127,6 +2205,9 @@ var MiokuContext = class {
|
|
|
2127
2205
|
/**
|
|
2128
2206
|
* 注册事件监听。route 支持层级路由,如 `message`、`message.group`、
|
|
2129
2207
|
* `onebotv11:message`;返回取消监听函数。
|
|
2208
|
+
*
|
|
2209
|
+
* handler 返回 `true` 表示认领该事件,总线不再交给后续监听器;
|
|
2210
|
+
* 返回 `undefined` / `false` 则继续下传。
|
|
2130
2211
|
*/
|
|
2131
2212
|
handle(route, handler) {
|
|
2132
2213
|
const inputRoutes = Array.isArray(route) ? route : [route];
|
|
@@ -2136,10 +2217,10 @@ var MiokuContext = class {
|
|
|
2136
2217
|
const handledEvents = new WeakSet();
|
|
2137
2218
|
const correlator = bypassDedup ? void 0 : this.#options.correlator;
|
|
2138
2219
|
const wrappedHandler = async (event) => {
|
|
2139
|
-
if (handledEvents.has(event)) return;
|
|
2140
|
-
if (correlator?.isDuplicate(event)) return;
|
|
2220
|
+
if (handledEvents.has(event)) return false;
|
|
2221
|
+
if (correlator?.isDuplicate(event)) return false;
|
|
2141
2222
|
handledEvents.add(event);
|
|
2142
|
-
await handler(event);
|
|
2223
|
+
return await handler(event) === true;
|
|
2143
2224
|
};
|
|
2144
2225
|
const disposers = routes.map((r) => this.#options.bus.register(r, wrappedHandler, {
|
|
2145
2226
|
source,
|
|
@@ -2322,7 +2403,7 @@ const canonicalJson = (value) => {
|
|
|
2322
2403
|
if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
2323
2404
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
2324
2405
|
const obj = value;
|
|
2325
|
-
return `{${Object.keys(obj).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(obj[key])}`).join(",")}}`;
|
|
2406
|
+
return `{${Object.keys(obj).sort().map((key$1) => `${JSON.stringify(key$1)}:${canonicalJson(obj[key$1])}`).join(",")}}`;
|
|
2326
2407
|
};
|
|
2327
2408
|
/** 结构化载荷(json/xml/ark)的稳定摘要 */
|
|
2328
2409
|
const structuredDigest = (raw) => {
|
|
@@ -2343,9 +2424,9 @@ const normalizeMediaUrl = (raw) => {
|
|
|
2343
2424
|
try {
|
|
2344
2425
|
const url = new URL(raw);
|
|
2345
2426
|
const kept = new URLSearchParams();
|
|
2346
|
-
for (const key of MEDIA_URL_QUERY_KEYS) {
|
|
2347
|
-
const value = url.searchParams.get(key);
|
|
2348
|
-
if (value) kept.set(key, value);
|
|
2427
|
+
for (const key$1 of MEDIA_URL_QUERY_KEYS) {
|
|
2428
|
+
const value = url.searchParams.get(key$1);
|
|
2429
|
+
if (value) kept.set(key$1, value);
|
|
2349
2430
|
}
|
|
2350
2431
|
const query = kept.toString();
|
|
2351
2432
|
return `${url.host}${url.pathname}${query ? `?${query}` : ""}`;
|
|
@@ -2367,7 +2448,7 @@ const mediaDigest = (data) => {
|
|
|
2367
2448
|
if (md5$1) return `h:${md5$1}`;
|
|
2368
2449
|
const sha1 = firstHex(data.sha1, HEX40);
|
|
2369
2450
|
if (sha1) return `h:${sha1}`;
|
|
2370
|
-
for (const key of [
|
|
2451
|
+
for (const key$1 of [
|
|
2371
2452
|
"file_unique",
|
|
2372
2453
|
"file_id",
|
|
2373
2454
|
"fid",
|
|
@@ -2375,19 +2456,19 @@ const mediaDigest = (data) => {
|
|
|
2375
2456
|
"file",
|
|
2376
2457
|
"name"
|
|
2377
2458
|
]) {
|
|
2378
|
-
const hex = firstHex(data[key], HEX32);
|
|
2459
|
+
const hex = firstHex(data[key$1], HEX32);
|
|
2379
2460
|
if (hex) return `h:${hex}`;
|
|
2380
2461
|
}
|
|
2381
2462
|
const url = data.url;
|
|
2382
2463
|
if (typeof url === "string" && url) return `u:${normalizeMediaUrl(url)}`;
|
|
2383
|
-
for (const key of [
|
|
2464
|
+
for (const key$1 of [
|
|
2384
2465
|
"file",
|
|
2385
2466
|
"file_id",
|
|
2386
2467
|
"fid",
|
|
2387
2468
|
"id",
|
|
2388
2469
|
"name"
|
|
2389
2470
|
]) {
|
|
2390
|
-
const value = data[key];
|
|
2471
|
+
const value = data[key$1];
|
|
2391
2472
|
if (typeof value === "string" && value) return `r:${value.toLowerCase()}`;
|
|
2392
2473
|
}
|
|
2393
2474
|
return "";
|
|
@@ -2494,27 +2575,27 @@ var EventCorrelator = class {
|
|
|
2494
2575
|
if (cached) return cached;
|
|
2495
2576
|
const located = this.#locate(event);
|
|
2496
2577
|
if (!located) return null;
|
|
2497
|
-
const { key, ttl } = located;
|
|
2578
|
+
const { key: key$1, ttl } = located;
|
|
2498
2579
|
const now = Date.now();
|
|
2499
2580
|
this.#observed++;
|
|
2500
|
-
let group = this.#groups.get(key);
|
|
2581
|
+
let group = this.#groups.get(key$1);
|
|
2501
2582
|
let duplicate = false;
|
|
2502
2583
|
if (group && group.expiresAt >= now) {
|
|
2503
2584
|
duplicate = true;
|
|
2504
2585
|
this.#duplicates++;
|
|
2505
2586
|
const participant = participantOf(event);
|
|
2506
2587
|
if (!group.participants.some((item) => sameParticipant(item, participant))) group.participants.push(participant);
|
|
2507
|
-
this.#logger?.debug(`去重命中: key=${key} adapter=${participant.adapter} bot=${participant.botId ?? ""} primary=${group.primary.adapter}:${group.primary.botId ?? ""}`);
|
|
2588
|
+
this.#logger?.debug(`去重命中: key=${key$1} adapter=${participant.adapter} bot=${participant.botId ?? ""} primary=${group.primary.adapter}:${group.primary.botId ?? ""}`);
|
|
2508
2589
|
} else {
|
|
2509
2590
|
const participant = participantOf(event);
|
|
2510
2591
|
group = {
|
|
2511
|
-
key,
|
|
2592
|
+
key: key$1,
|
|
2512
2593
|
expiresAt: now + ttl,
|
|
2513
2594
|
firstSeenAt: now,
|
|
2514
2595
|
primary: participant,
|
|
2515
2596
|
participants: [participant]
|
|
2516
2597
|
};
|
|
2517
|
-
this.#groups.set(key, group);
|
|
2598
|
+
this.#groups.set(key$1, group);
|
|
2518
2599
|
this.#inserts++;
|
|
2519
2600
|
if (this.#inserts >= PRUNE_INTERVAL || this.#groups.size > this.#maxSize) {
|
|
2520
2601
|
this.#inserts = 0;
|
|
@@ -2567,12 +2648,12 @@ var EventCorrelator = class {
|
|
|
2567
2648
|
return null;
|
|
2568
2649
|
}
|
|
2569
2650
|
#prune(now) {
|
|
2570
|
-
for (const [key, group] of this.#groups) if (group.expiresAt < now) this.#groups.delete(key);
|
|
2651
|
+
for (const [key$1, group] of this.#groups) if (group.expiresAt < now) this.#groups.delete(key$1);
|
|
2571
2652
|
if (this.#groups.size <= this.#maxSize) return;
|
|
2572
2653
|
const drop = this.#groups.size - this.#maxSize;
|
|
2573
2654
|
let dropped = 0;
|
|
2574
|
-
for (const key of this.#groups.keys()) {
|
|
2575
|
-
this.#groups.delete(key);
|
|
2655
|
+
for (const key$1 of this.#groups.keys()) {
|
|
2656
|
+
this.#groups.delete(key$1);
|
|
2576
2657
|
this.#evicted++;
|
|
2577
2658
|
if (++dropped >= drop) break;
|
|
2578
2659
|
}
|
|
@@ -2691,8 +2772,8 @@ var CommandManager = class {
|
|
|
2691
2772
|
canUseCommand(plugin, command, event) {
|
|
2692
2773
|
const registered = this.#resolveRegistered(plugin, command);
|
|
2693
2774
|
if (registered) return this.#canUse(registered, event);
|
|
2694
|
-
const key = commandKey$1(command);
|
|
2695
|
-
const action = this.#resolveAction(plugin, key, event) ?? this.#resolveAction(plugin, command, event);
|
|
2775
|
+
const key$1 = commandKey$1(command);
|
|
2776
|
+
const action = this.#resolveAction(plugin, key$1, event) ?? this.#resolveAction(plugin, command, event);
|
|
2696
2777
|
return action !== "block";
|
|
2697
2778
|
}
|
|
2698
2779
|
syncMetadata(metadata) {
|
|
@@ -2721,11 +2802,11 @@ var CommandManager = class {
|
|
|
2721
2802
|
const seen = new Set();
|
|
2722
2803
|
const runtimeByKey = new Map(runtime.map((command) => [commandKey$1(command.name), command]));
|
|
2723
2804
|
for (const command of metadata?.config.help?.commands ?? []) {
|
|
2724
|
-
const key = commandKey$1(command.cmd);
|
|
2725
|
-
const runtimeCommand = runtimeByKey.get(key);
|
|
2805
|
+
const key$1 = commandKey$1(command.cmd);
|
|
2806
|
+
const runtimeCommand = runtimeByKey.get(key$1);
|
|
2726
2807
|
if (runtimeCommand) {
|
|
2727
2808
|
const cmd = displayCommand(runtimeCommand, this.#getDefaultPrefix());
|
|
2728
|
-
seen.add(key);
|
|
2809
|
+
seen.add(key$1);
|
|
2729
2810
|
commands.push({
|
|
2730
2811
|
cmd,
|
|
2731
2812
|
id: runtimeCommand.id,
|
|
@@ -2733,8 +2814,8 @@ var CommandManager = class {
|
|
|
2733
2814
|
usage: runtimeCommand.usage ?? command.usage,
|
|
2734
2815
|
role: runtimeCommand.permission
|
|
2735
2816
|
});
|
|
2736
|
-
} else if (!seen.has(key)) {
|
|
2737
|
-
seen.add(key);
|
|
2817
|
+
} else if (!seen.has(key$1)) {
|
|
2818
|
+
seen.add(key$1);
|
|
2738
2819
|
commands.push(command);
|
|
2739
2820
|
}
|
|
2740
2821
|
}
|
|
@@ -2821,11 +2902,17 @@ var CommandManager = class {
|
|
|
2821
2902
|
async dispatch(event) {
|
|
2822
2903
|
const text$1 = String(event.message?.text?.() ?? "").trim();
|
|
2823
2904
|
if (!text$1) return false;
|
|
2824
|
-
const
|
|
2825
|
-
|
|
2826
|
-
|
|
2905
|
+
const matches = this.#findAll(text$1);
|
|
2906
|
+
for (const match$1 of matches) {
|
|
2907
|
+
if (!this.#canUse(match$1.command, event)) return true;
|
|
2908
|
+
if (await this.#run(match$1, event, text$1)) return true;
|
|
2909
|
+
}
|
|
2910
|
+
return false;
|
|
2911
|
+
}
|
|
2912
|
+
/** 执行单个命令,返回它是否认领这条消息 */
|
|
2913
|
+
async #run(match$1, event, text$1) {
|
|
2827
2914
|
try {
|
|
2828
|
-
await match$1.command.handler({
|
|
2915
|
+
const result = await match$1.command.handler({
|
|
2829
2916
|
ctx: match$1.command.context,
|
|
2830
2917
|
event,
|
|
2831
2918
|
command: match$1.command,
|
|
@@ -2834,10 +2921,11 @@ var CommandManager = class {
|
|
|
2834
2921
|
args: match$1.args,
|
|
2835
2922
|
match: match$1.match
|
|
2836
2923
|
});
|
|
2924
|
+
return result !== false;
|
|
2837
2925
|
} catch (error) {
|
|
2838
2926
|
this.#logger?.error(`Command "${match$1.command.plugin}:${match$1.command.id}" failed`, error);
|
|
2927
|
+
return true;
|
|
2839
2928
|
}
|
|
2840
|
-
return true;
|
|
2841
2929
|
}
|
|
2842
2930
|
shouldDispatch(source, event) {
|
|
2843
2931
|
if (!source.startsWith("plugin:")) return true;
|
|
@@ -2849,7 +2937,8 @@ var CommandManager = class {
|
|
|
2849
2937
|
const matches = (metadata.config.accessHooks ?? []).filter((hook) => event.kind === "message" && textHookMatches(text$1, hook.match) || routeMatches(event, hook.event));
|
|
2850
2938
|
return matches.every((hook) => this.#commandAllowed(plugin, hook.id, event));
|
|
2851
2939
|
}
|
|
2852
|
-
#
|
|
2940
|
+
#findAll(text$1) {
|
|
2941
|
+
const matches = [];
|
|
2853
2942
|
for (const command of this.#orderedCommands()) {
|
|
2854
2943
|
const prefixes = parsePrefixes(command.prefixes ?? this.#getDefaultPrefix(), this.#getDefaultPrefix());
|
|
2855
2944
|
const body = commandBody(text$1, prefixes);
|
|
@@ -2862,11 +2951,14 @@ var CommandManager = class {
|
|
|
2862
2951
|
];
|
|
2863
2952
|
for (const candidate of candidates) {
|
|
2864
2953
|
const result = stringMatch(body, candidate);
|
|
2865
|
-
if (result)
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2954
|
+
if (result) {
|
|
2955
|
+
matches.push({
|
|
2956
|
+
command,
|
|
2957
|
+
body,
|
|
2958
|
+
args: result.args
|
|
2959
|
+
});
|
|
2960
|
+
break;
|
|
2961
|
+
}
|
|
2870
2962
|
}
|
|
2871
2963
|
continue;
|
|
2872
2964
|
}
|
|
@@ -2874,21 +2966,21 @@ var CommandManager = class {
|
|
|
2874
2966
|
const matched = body.match(command.matcher);
|
|
2875
2967
|
if (!matched) continue;
|
|
2876
2968
|
const args = matched.length > 1 ? matched.slice(1).filter((item) => item != null) : body.slice(matched[0].length).trim().split(/\s+/).filter(Boolean);
|
|
2877
|
-
|
|
2969
|
+
matches.push({
|
|
2878
2970
|
command,
|
|
2879
2971
|
body,
|
|
2880
2972
|
args,
|
|
2881
2973
|
match: matched
|
|
2882
|
-
};
|
|
2974
|
+
});
|
|
2883
2975
|
}
|
|
2884
|
-
return
|
|
2976
|
+
return matches;
|
|
2885
2977
|
}
|
|
2886
2978
|
#resolveRegistered(plugin, ref) {
|
|
2887
2979
|
const raw = String(ref ?? "").trim();
|
|
2888
2980
|
if (!raw) return void 0;
|
|
2889
|
-
const key = commandKey$1(raw);
|
|
2981
|
+
const key$1 = commandKey$1(raw);
|
|
2890
2982
|
const candidates = this.#commands.filter((item) => item.plugin === plugin);
|
|
2891
|
-
return candidates.find((item) => item.id === raw) ?? candidates.find((item) => item.name === raw) ?? candidates.find((item) => item.aliases.includes(raw)) ?? candidates.find((item) => commandKey$1(item.id) === key) ?? candidates.find((item) => commandKey$1(item.name) === key) ?? candidates.find((item) => item.aliases.some((alias) => commandKey$1(alias) === key));
|
|
2983
|
+
return candidates.find((item) => item.id === raw) ?? candidates.find((item) => item.name === raw) ?? candidates.find((item) => item.aliases.includes(raw)) ?? candidates.find((item) => commandKey$1(item.id) === key$1) ?? candidates.find((item) => commandKey$1(item.name) === key$1) ?? candidates.find((item) => item.aliases.some((alias) => commandKey$1(alias) === key$1));
|
|
2892
2984
|
}
|
|
2893
2985
|
#canUse(command, event) {
|
|
2894
2986
|
const userId = userIdOf(event);
|
|
@@ -2953,8 +3045,8 @@ var CommandManager = class {
|
|
|
2953
3045
|
#admins() {
|
|
2954
3046
|
return this.#configIds("admins");
|
|
2955
3047
|
}
|
|
2956
|
-
#configIds(key) {
|
|
2957
|
-
return [...key === "owners" ? this.#getOwners() : this.#getAdmins()].map(String);
|
|
3048
|
+
#configIds(key$1) {
|
|
3049
|
+
return [...key$1 === "owners" ? this.#getOwners() : this.#getAdmins()].map(String);
|
|
2958
3050
|
}
|
|
2959
3051
|
};
|
|
2960
3052
|
let activeCommandManager;
|
|
@@ -3003,8 +3095,8 @@ async function registerPluginArtifacts(ctx) {
|
|
|
3003
3095
|
title: existing?.title || generated.title,
|
|
3004
3096
|
description: existing?.description || generated.description,
|
|
3005
3097
|
commands: [...existing?.commands ?? [], ...generated.commands.filter((command) => {
|
|
3006
|
-
const key = commandKey(command.cmd);
|
|
3007
|
-
return !(existing?.commands ?? []).some((item) => commandKey(item.cmd) === key);
|
|
3098
|
+
const key$1 = commandKey(command.cmd);
|
|
3099
|
+
return !(existing?.commands ?? []).some((item) => commandKey(item.cmd) === key$1);
|
|
3008
3100
|
})]
|
|
3009
3101
|
} : existing;
|
|
3010
3102
|
if (help) if (helpService) {
|
|
@@ -3242,10 +3334,10 @@ const registerStatusProvider = (target, provider) => {
|
|
|
3242
3334
|
adapter: target,
|
|
3243
3335
|
bot_id: void 0
|
|
3244
3336
|
} : target;
|
|
3245
|
-
const key = providerKey(adapter, bot_id);
|
|
3246
|
-
statusProviders.set(key, provider);
|
|
3337
|
+
const key$1 = providerKey(adapter, bot_id);
|
|
3338
|
+
statusProviders.set(key$1, provider);
|
|
3247
3339
|
return () => {
|
|
3248
|
-
if (statusProviders.get(key) === provider) statusProviders.delete(key);
|
|
3340
|
+
if (statusProviders.get(key$1) === provider) statusProviders.delete(key$1);
|
|
3249
3341
|
};
|
|
3250
3342
|
};
|
|
3251
3343
|
const resolveProvider = (bot) => statusProviders.get(providerKey(bot.adapter, bot.bot_id)) ?? statusProviders.get(providerKey(bot.adapter));
|
|
@@ -3323,7 +3415,7 @@ const STAT_GROUPS = [["📋", [["friends", "好友"], ["groups", "群"]]], ["
|
|
|
3323
3415
|
const formatStats = (stats) => {
|
|
3324
3416
|
const segments = [];
|
|
3325
3417
|
for (const [icon, fields] of STAT_GROUPS) {
|
|
3326
|
-
const parts = fields.filter(([key]) => stats[key] != null).map(([key, label]) => `${label} ${localNum(stats[key])}`);
|
|
3418
|
+
const parts = fields.filter(([key$1]) => stats[key$1] != null).map(([key$1, label]) => `${label} ${localNum(stats[key$1])}`);
|
|
3327
3419
|
if (parts.length) segments.push(`${icon} ${parts.join(" / ")}`);
|
|
3328
3420
|
}
|
|
3329
3421
|
return segments.join(" · ");
|
|
@@ -4362,12 +4454,12 @@ function registerUpdateCommands(ctx) {
|
|
|
4362
4454
|
}
|
|
4363
4455
|
if (arg === "check" || arg === "检查") {
|
|
4364
4456
|
const pending = getPendingMap();
|
|
4365
|
-
const key = conversationKey(event);
|
|
4366
|
-
const existing = pending.get(key);
|
|
4457
|
+
const key$1 = conversationKey(event);
|
|
4458
|
+
const existing = pending.get(key$1);
|
|
4367
4459
|
if (existing) {
|
|
4368
4460
|
existing.disposer();
|
|
4369
4461
|
clearTimeout(existing.timer);
|
|
4370
|
-
pending.delete(key);
|
|
4462
|
+
pending.delete(key$1);
|
|
4371
4463
|
}
|
|
4372
4464
|
let items;
|
|
4373
4465
|
try {
|
|
@@ -4385,15 +4477,15 @@ function registerUpdateCommands(ctx) {
|
|
|
4385
4477
|
const timeoutMs = SELECT_TIMEOUT_MS;
|
|
4386
4478
|
const listenerDispose = ctx.handle("message", async (ev) => {
|
|
4387
4479
|
if (String(ev?.self_id || "") !== selfId) return;
|
|
4388
|
-
if (conversationKey(ev) !== key) return;
|
|
4480
|
+
if (conversationKey(ev) !== key$1) return;
|
|
4389
4481
|
if (!isEventMaster(ev)) return;
|
|
4390
4482
|
const evText = ctx.text(ev)?.trim() || "";
|
|
4391
4483
|
if (evText.startsWith(`${prefix}update`)) return;
|
|
4392
|
-
const sel = pending.get(key);
|
|
4484
|
+
const sel = pending.get(key$1);
|
|
4393
4485
|
if (!sel) return;
|
|
4394
4486
|
clearTimeout(sel.timer);
|
|
4395
4487
|
sel.disposer();
|
|
4396
|
-
pending.delete(key);
|
|
4488
|
+
pending.delete(key$1);
|
|
4397
4489
|
const parsed = parseSelection(evText, sel.items.length);
|
|
4398
4490
|
const chosen = parsed.all ? sel.items : parsed.indices.map((i) => sel.items[i]).filter(Boolean);
|
|
4399
4491
|
if (chosen.length === 0) {
|
|
@@ -4403,13 +4495,13 @@ function registerUpdateCommands(ctx) {
|
|
|
4403
4495
|
await performUpdateAndReport(ctx, event, chosen.map((i) => i.name));
|
|
4404
4496
|
});
|
|
4405
4497
|
const timer = setTimeout(async () => {
|
|
4406
|
-
const sel = pending.get(key);
|
|
4498
|
+
const sel = pending.get(key$1);
|
|
4407
4499
|
if (!sel) return;
|
|
4408
4500
|
sel.disposer();
|
|
4409
|
-
pending.delete(key);
|
|
4501
|
+
pending.delete(key$1);
|
|
4410
4502
|
await replyText(event, "操作超时,已取消更新");
|
|
4411
4503
|
}, timeoutMs);
|
|
4412
|
-
pending.set(key, {
|
|
4504
|
+
pending.set(key$1, {
|
|
4413
4505
|
disposer: listenerDispose,
|
|
4414
4506
|
timer,
|
|
4415
4507
|
items
|
|
@@ -4968,7 +5060,7 @@ const core = definePlugin({
|
|
|
4968
5060
|
const collectBots = () => ctx.bots;
|
|
4969
5061
|
/** 已加载的适配器优先,再补上只在 bot 上出现过的适配器名 */
|
|
4970
5062
|
const collectAdapters = () => {
|
|
4971
|
-
const describe = (name, adapter) => ({
|
|
5063
|
+
const describe$1 = (name, adapter) => ({
|
|
4972
5064
|
name,
|
|
4973
5065
|
version: adapter?.version,
|
|
4974
5066
|
impl: adapter?.impl ? {
|
|
@@ -4976,13 +5068,13 @@ const core = definePlugin({
|
|
|
4976
5068
|
version: adapter.impl.version
|
|
4977
5069
|
} : void 0
|
|
4978
5070
|
});
|
|
4979
|
-
const list = ctx.adapters.map((adapter) => describe(adapter.name, adapter));
|
|
5071
|
+
const list = ctx.adapters.map((adapter) => describe$1(adapter.name, adapter));
|
|
4980
5072
|
const seen = new Set(list.map((adapter) => adapter.name));
|
|
4981
5073
|
for (const bot of ctx.bots) {
|
|
4982
5074
|
const name = String(bot.adapter);
|
|
4983
5075
|
if (seen.has(name)) continue;
|
|
4984
5076
|
seen.add(name);
|
|
4985
|
-
list.push(describe(name, ctx.getAdapter(name)));
|
|
5077
|
+
list.push(describe$1(name, ctx.getAdapter(name)));
|
|
4986
5078
|
}
|
|
4987
5079
|
return list;
|
|
4988
5080
|
};
|
|
@@ -5345,7 +5437,7 @@ const HELP_COMMAND_KEYS = new Set([
|
|
|
5345
5437
|
"role"
|
|
5346
5438
|
]);
|
|
5347
5439
|
function warnUnknownFields(prefix, obj, allowed) {
|
|
5348
|
-
for (const key of Object.keys(obj)) if (!allowed.has(key)) rootLogger.warn(`[plugin-manifest] ${prefix} 含未知字段 "${key}"(将被忽略)`);
|
|
5440
|
+
for (const key$1 of Object.keys(obj)) if (!allowed.has(key$1)) rootLogger.warn(`[plugin-manifest] ${prefix} 含未知字段 "${key$1}"(将被忽略)`);
|
|
5349
5441
|
}
|
|
5350
5442
|
function isPlainObject(value) {
|
|
5351
5443
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -5490,7 +5582,7 @@ const collectDirectDependencyNames = (pkg) => {
|
|
|
5490
5582
|
pkg.optionalDependencies
|
|
5491
5583
|
]) {
|
|
5492
5584
|
if (!map) continue;
|
|
5493
|
-
for (const key of Object.keys(map)) set.add(key);
|
|
5585
|
+
for (const key$1 of Object.keys(map)) set.add(key$1);
|
|
5494
5586
|
}
|
|
5495
5587
|
return Array.from(set);
|
|
5496
5588
|
};
|
|
@@ -5774,10 +5866,10 @@ var MiokuRuntime = class {
|
|
|
5774
5866
|
return this.#bots.pick(bot_id);
|
|
5775
5867
|
}
|
|
5776
5868
|
listPlugins() {
|
|
5777
|
-
return Array.from(this.#enabledPlugins.entries()).map(([key]) => {
|
|
5778
|
-
const colon = key.indexOf(":");
|
|
5779
|
-
const type = key.slice(0, colon);
|
|
5780
|
-
const name = key.slice(colon + 1);
|
|
5869
|
+
return Array.from(this.#enabledPlugins.entries()).map(([key$1]) => {
|
|
5870
|
+
const colon = key$1.indexOf(":");
|
|
5871
|
+
const type = key$1.slice(0, colon);
|
|
5872
|
+
const name = key$1.slice(colon + 1);
|
|
5781
5873
|
const isExternal = type !== "builtin";
|
|
5782
5874
|
const version$2 = isExternal ? getPluginMetadata(name)?.version : void 0;
|
|
5783
5875
|
return {
|
|
@@ -5813,8 +5905,8 @@ var MiokuRuntime = class {
|
|
|
5813
5905
|
throw new Error(`插件 ${name} 不存在`);
|
|
5814
5906
|
}
|
|
5815
5907
|
async disablePlugin(name) {
|
|
5816
|
-
const key = `external:${name}`;
|
|
5817
|
-
const entry = this.#enabledPlugins.get(key);
|
|
5908
|
+
const key$1 = `external:${name}`;
|
|
5909
|
+
const entry = this.#enabledPlugins.get(key$1);
|
|
5818
5910
|
if (!entry) {
|
|
5819
5911
|
if (this.#enabledPlugins.has(`builtin:${name}`)) throw new Error(`内置插件 ${name} 无法禁用`);
|
|
5820
5912
|
throw new Error(`插件 ${name} 不存在或未启用`);
|
|
@@ -5822,7 +5914,7 @@ var MiokuRuntime = class {
|
|
|
5822
5914
|
try {
|
|
5823
5915
|
await entry.cleanup?.();
|
|
5824
5916
|
} finally {
|
|
5825
|
-
this.#enabledPlugins.delete(key);
|
|
5917
|
+
this.#enabledPlugins.delete(key$1);
|
|
5826
5918
|
removePluginMetadata(name);
|
|
5827
5919
|
}
|
|
5828
5920
|
await this.#refreshPluginArtifacts();
|
|
@@ -6261,6 +6353,733 @@ const startRuntime = async (options = {}) => {
|
|
|
6261
6353
|
} };
|
|
6262
6354
|
};
|
|
6263
6355
|
|
|
6356
|
+
//#endregion
|
|
6357
|
+
//#region src/skills/types.ts
|
|
6358
|
+
const SKILL_FILE_NAME = "SKILL.md";
|
|
6359
|
+
/** 规范要求的技能名:小写字母数字,单连字符分隔 */
|
|
6360
|
+
const SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
6361
|
+
const SKILL_NAME_MAX = 64;
|
|
6362
|
+
const SKILL_DESCRIPTION_MAX = 1024;
|
|
6363
|
+
const SKILL_COMPATIBILITY_MAX = 500;
|
|
6364
|
+
/** 规范定义的六个字段加上两个调用控制字段 */
|
|
6365
|
+
const SKILL_KNOWN_KEYS = [
|
|
6366
|
+
"name",
|
|
6367
|
+
"description",
|
|
6368
|
+
"license",
|
|
6369
|
+
"compatibility",
|
|
6370
|
+
"metadata",
|
|
6371
|
+
"allowed-tools",
|
|
6372
|
+
"disable-model-invocation",
|
|
6373
|
+
"user-invocable"
|
|
6374
|
+
];
|
|
6375
|
+
|
|
6376
|
+
//#endregion
|
|
6377
|
+
//#region src/skills/frontmatter.ts
|
|
6378
|
+
const FRONTMATTER_FENCE = "---";
|
|
6379
|
+
function diagnostic(code, message, path$8, level = "warn") {
|
|
6380
|
+
return {
|
|
6381
|
+
level,
|
|
6382
|
+
code,
|
|
6383
|
+
message,
|
|
6384
|
+
path: path$8
|
|
6385
|
+
};
|
|
6386
|
+
}
|
|
6387
|
+
function normalizeText(raw) {
|
|
6388
|
+
return raw.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n");
|
|
6389
|
+
}
|
|
6390
|
+
/** 拆出 `---` 围栏之间的 YAML 与正文 */
|
|
6391
|
+
function splitFrontmatter(text$1) {
|
|
6392
|
+
const lines = text$1.split("\n");
|
|
6393
|
+
if ((lines[0] ?? "").trimEnd() !== FRONTMATTER_FENCE) return void 0;
|
|
6394
|
+
for (let i = 1; i < lines.length; i++) {
|
|
6395
|
+
if (lines[i].trimEnd() !== FRONTMATTER_FENCE) continue;
|
|
6396
|
+
return {
|
|
6397
|
+
yaml: lines.slice(1, i).join("\n"),
|
|
6398
|
+
body: lines.slice(i + 1).join("\n")
|
|
6399
|
+
};
|
|
6400
|
+
}
|
|
6401
|
+
return void 0;
|
|
6402
|
+
}
|
|
6403
|
+
function stringField(source, key$1) {
|
|
6404
|
+
const value = source[key$1];
|
|
6405
|
+
return typeof value === "string" ? value.trim() : "";
|
|
6406
|
+
}
|
|
6407
|
+
function booleanField(value) {
|
|
6408
|
+
if (typeof value === "boolean") return value;
|
|
6409
|
+
if (value === 1 || value === "1") return true;
|
|
6410
|
+
if (value === 0 || value === "0") return false;
|
|
6411
|
+
if (typeof value === "string") {
|
|
6412
|
+
const lowered = value.trim().toLowerCase();
|
|
6413
|
+
if (lowered === "true" || lowered === "yes" || lowered === "on") return true;
|
|
6414
|
+
if (lowered === "false" || lowered === "no" || lowered === "off") return false;
|
|
6415
|
+
}
|
|
6416
|
+
return void 0;
|
|
6417
|
+
}
|
|
6418
|
+
/** 规范允许空格分隔的字符串或 YAML 列表 */
|
|
6419
|
+
function readAllowedTools(value) {
|
|
6420
|
+
const parts = Array.isArray(value) ? value.map((item) => String(item ?? "")) : typeof value === "string" ? value.split(/[\s,]+/) : [];
|
|
6421
|
+
return parts.map((part) => part.trim()).filter(Boolean);
|
|
6422
|
+
}
|
|
6423
|
+
function readMetadata(value) {
|
|
6424
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
6425
|
+
const result = {};
|
|
6426
|
+
for (const [key$1, item] of Object.entries(value)) {
|
|
6427
|
+
if (item === null || item === void 0) continue;
|
|
6428
|
+
result[key$1] = typeof item === "string" ? item : JSON.stringify(item) ?? String(item);
|
|
6429
|
+
}
|
|
6430
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
6431
|
+
}
|
|
6432
|
+
function clamp$1(value, max, label, path$8, diagnostics) {
|
|
6433
|
+
if (value.length <= max) return value;
|
|
6434
|
+
diagnostics.push(diagnostic("UNKNOWN_KEY", `frontmatter ${label} 超过 ${max} 字符,已截断`, path$8));
|
|
6435
|
+
return value.slice(0, max);
|
|
6436
|
+
}
|
|
6437
|
+
/**
|
|
6438
|
+
* 解析并校验一个 `SKILL.md`。
|
|
6439
|
+
* 缺失 `skill` 表示该文件不可用:缺少 frontmatter、YAML 非法、name/description 缺失或 name 非法。
|
|
6440
|
+
*/
|
|
6441
|
+
function parseSkillFile(path$8, raw) {
|
|
6442
|
+
const diagnostics = [];
|
|
6443
|
+
const text$1 = normalizeText(raw);
|
|
6444
|
+
const split = splitFrontmatter(text$1);
|
|
6445
|
+
if (!split) {
|
|
6446
|
+
diagnostics.push(diagnostic("MISSING_FRONTMATTER", "缺少 YAML frontmatter,已忽略", path$8, "error"));
|
|
6447
|
+
return { diagnostics };
|
|
6448
|
+
}
|
|
6449
|
+
let data;
|
|
6450
|
+
try {
|
|
6451
|
+
const parsed = (0, yaml.parse)(split.yaml);
|
|
6452
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
6453
|
+
diagnostics.push(diagnostic("INVALID_YAML", "frontmatter 不是键值映射,已忽略", path$8, "error"));
|
|
6454
|
+
return { diagnostics };
|
|
6455
|
+
}
|
|
6456
|
+
data = parsed;
|
|
6457
|
+
} catch (err) {
|
|
6458
|
+
diagnostics.push(diagnostic("INVALID_YAML", `frontmatter YAML 解析失败:${err}`, path$8, "error"));
|
|
6459
|
+
return { diagnostics };
|
|
6460
|
+
}
|
|
6461
|
+
for (const key$1 of Object.keys(data)) {
|
|
6462
|
+
if (SKILL_KNOWN_KEYS.includes(key$1)) continue;
|
|
6463
|
+
diagnostics.push(diagnostic("UNKNOWN_KEY", `未知 frontmatter 字段 "${key$1}",已忽略`, path$8));
|
|
6464
|
+
}
|
|
6465
|
+
const name = stringField(data, "name");
|
|
6466
|
+
if (!name) {
|
|
6467
|
+
diagnostics.push(diagnostic("MISSING_FIELD", "frontmatter 缺少 name,已忽略", path$8, "error"));
|
|
6468
|
+
return { diagnostics };
|
|
6469
|
+
}
|
|
6470
|
+
if (name.length > SKILL_NAME_MAX || !SKILL_NAME_PATTERN.test(name)) {
|
|
6471
|
+
diagnostics.push(diagnostic("INVALID_NAME", `技能名 "${name}" 不合法(仅小写字母、数字与单个连字符,最长 ${SKILL_NAME_MAX}),已忽略`, path$8, "error"));
|
|
6472
|
+
return { diagnostics };
|
|
6473
|
+
}
|
|
6474
|
+
const rawDescription = stringField(data, "description");
|
|
6475
|
+
if (!rawDescription) {
|
|
6476
|
+
diagnostics.push(diagnostic("MISSING_FIELD", "frontmatter 缺少 description,已忽略", path$8, "error"));
|
|
6477
|
+
return { diagnostics };
|
|
6478
|
+
}
|
|
6479
|
+
const disableModelInvocation = booleanField(data["disable-model-invocation"]) ?? false;
|
|
6480
|
+
const userInvocable = booleanField(data["user-invocable"]) ?? true;
|
|
6481
|
+
const invoke = {
|
|
6482
|
+
modelInvocable: !disableModelInvocation,
|
|
6483
|
+
userInvocable
|
|
6484
|
+
};
|
|
6485
|
+
if (!invoke.modelInvocable && !invoke.userInvocable) diagnostics.push(diagnostic("UNUSABLE_INVOCATION", "disable-model-invocation 与 user-invocable:false 同时设置,技能不可被任何方式调用", path$8));
|
|
6486
|
+
const license = stringField(data, "license");
|
|
6487
|
+
const compatibility = stringField(data, "compatibility");
|
|
6488
|
+
return {
|
|
6489
|
+
skill: {
|
|
6490
|
+
name,
|
|
6491
|
+
description: clamp$1(rawDescription, SKILL_DESCRIPTION_MAX, "description", path$8, diagnostics),
|
|
6492
|
+
...license ? { license } : {},
|
|
6493
|
+
...compatibility ? { compatibility: clamp$1(compatibility, SKILL_COMPATIBILITY_MAX, "compatibility", path$8, diagnostics) } : {},
|
|
6494
|
+
...(() => {
|
|
6495
|
+
const metadata = readMetadata(data.metadata);
|
|
6496
|
+
return metadata ? { metadata } : {};
|
|
6497
|
+
})(),
|
|
6498
|
+
allowedTools: readAllowedTools(data["allowed-tools"]),
|
|
6499
|
+
invoke,
|
|
6500
|
+
content: split.body.trim()
|
|
6501
|
+
},
|
|
6502
|
+
diagnostics
|
|
6503
|
+
};
|
|
6504
|
+
}
|
|
6505
|
+
|
|
6506
|
+
//#endregion
|
|
6507
|
+
//#region src/skills/roots.ts
|
|
6508
|
+
/** 五个标准技能根,按 rank 升序;与 Claude Code / Codex / `npx skills add` 的目录约定一致 */
|
|
6509
|
+
const DEFAULT_SKILL_ROOT_SPECS = [
|
|
6510
|
+
{
|
|
6511
|
+
id: "project-agents",
|
|
6512
|
+
label: ".agents/skills",
|
|
6513
|
+
kind: "project-agents",
|
|
6514
|
+
scope: "project",
|
|
6515
|
+
segments: [".agents", "skills"],
|
|
6516
|
+
rank: 100
|
|
6517
|
+
},
|
|
6518
|
+
{
|
|
6519
|
+
id: "project-claude",
|
|
6520
|
+
label: ".claude/skills",
|
|
6521
|
+
kind: "project-claude",
|
|
6522
|
+
scope: "project",
|
|
6523
|
+
segments: [".claude", "skills"],
|
|
6524
|
+
rank: 200
|
|
6525
|
+
},
|
|
6526
|
+
{
|
|
6527
|
+
id: "user-agents",
|
|
6528
|
+
label: "~/.agents/skills",
|
|
6529
|
+
kind: "user-agents",
|
|
6530
|
+
scope: "user",
|
|
6531
|
+
segments: [".agents", "skills"],
|
|
6532
|
+
rank: 400
|
|
6533
|
+
},
|
|
6534
|
+
{
|
|
6535
|
+
id: "user-claude",
|
|
6536
|
+
label: "~/.claude/skills",
|
|
6537
|
+
kind: "user-claude",
|
|
6538
|
+
scope: "user",
|
|
6539
|
+
segments: [".claude", "skills"],
|
|
6540
|
+
rank: 500
|
|
6541
|
+
},
|
|
6542
|
+
{
|
|
6543
|
+
id: "user-codex",
|
|
6544
|
+
label: "~/.codex/skills",
|
|
6545
|
+
kind: "user-codex",
|
|
6546
|
+
scope: "user",
|
|
6547
|
+
segments: [".codex", "skills"],
|
|
6548
|
+
rank: 600
|
|
6549
|
+
}
|
|
6550
|
+
];
|
|
6551
|
+
const CUSTOM_RANK = 300;
|
|
6552
|
+
/** 展开开头的 `~/` */
|
|
6553
|
+
function expandHomePath(input, home = (0, node_os.homedir)()) {
|
|
6554
|
+
const raw = String(input ?? "").trim();
|
|
6555
|
+
if (raw === "~") return home;
|
|
6556
|
+
if (raw.startsWith("~/") || raw.startsWith("~\\")) return node_path.join(home, raw.slice(2));
|
|
6557
|
+
return raw;
|
|
6558
|
+
}
|
|
6559
|
+
function displayPath(target, home) {
|
|
6560
|
+
const rel = node_path.relative(home, target);
|
|
6561
|
+
if (rel && !rel.startsWith("..") && !node_path.isAbsolute(rel)) return `~/${rel.split(node_path.sep).join("/")}`;
|
|
6562
|
+
return target;
|
|
6563
|
+
}
|
|
6564
|
+
/** 解析出当前机器上的技能根列表,自定义根排在项目根之后、用户根之前 */
|
|
6565
|
+
function resolveSkillRoots(options = {}) {
|
|
6566
|
+
const botRoot = node_path.resolve(options.botRoot ?? process.cwd());
|
|
6567
|
+
const home = node_path.resolve(options.home ?? (0, node_os.homedir)());
|
|
6568
|
+
const roots = [];
|
|
6569
|
+
for (const spec of DEFAULT_SKILL_ROOT_SPECS) {
|
|
6570
|
+
const base = spec.scope === "project" ? botRoot : home;
|
|
6571
|
+
roots.push({
|
|
6572
|
+
id: spec.id,
|
|
6573
|
+
label: spec.label,
|
|
6574
|
+
kind: spec.kind,
|
|
6575
|
+
path: node_path.join(base, ...spec.segments),
|
|
6576
|
+
rank: spec.rank,
|
|
6577
|
+
writable: true
|
|
6578
|
+
});
|
|
6579
|
+
}
|
|
6580
|
+
const extra = (options.extraRoots ?? []).map((item) => expandHomePath(item, home)).filter(Boolean).map((item) => node_path.resolve(item));
|
|
6581
|
+
extra.forEach((target, index) => {
|
|
6582
|
+
roots.push({
|
|
6583
|
+
id: `custom:${index + 1}`,
|
|
6584
|
+
label: displayPath(target, home),
|
|
6585
|
+
kind: "custom",
|
|
6586
|
+
path: target,
|
|
6587
|
+
rank: CUSTOM_RANK,
|
|
6588
|
+
writable: true
|
|
6589
|
+
});
|
|
6590
|
+
});
|
|
6591
|
+
return roots.sort((a, b) => a.rank - b.rank);
|
|
6592
|
+
}
|
|
6593
|
+
function findSkillRoot(roots, id) {
|
|
6594
|
+
return roots.find((root) => root.id === id);
|
|
6595
|
+
}
|
|
6596
|
+
/** 判断路径是否落在某个根内,返回该根 */
|
|
6597
|
+
function rootOfPath(roots, target) {
|
|
6598
|
+
const resolved = node_path.resolve(target);
|
|
6599
|
+
return roots.find((root) => {
|
|
6600
|
+
const rel = node_path.relative(root.path, resolved);
|
|
6601
|
+
return rel !== "" && !rel.startsWith("..") && !node_path.isAbsolute(rel);
|
|
6602
|
+
});
|
|
6603
|
+
}
|
|
6604
|
+
|
|
6605
|
+
//#endregion
|
|
6606
|
+
//#region src/skills/discover.ts
|
|
6607
|
+
const DEFAULT_MAX_RESOURCE_FILES = 200;
|
|
6608
|
+
const DEFAULT_MAX_RESOURCE_DEPTH = 3;
|
|
6609
|
+
const MAX_SKILL_FILE_BYTES = 256 * 1024;
|
|
6610
|
+
const SKIPPED_DIRS$1 = new Set([".git", "node_modules"]);
|
|
6611
|
+
function toPosix(value) {
|
|
6612
|
+
return value.split(node_path.sep).join("/");
|
|
6613
|
+
}
|
|
6614
|
+
function shouldSkipName(name) {
|
|
6615
|
+
return name.startsWith(".") || SKIPPED_DIRS$1.has(name);
|
|
6616
|
+
}
|
|
6617
|
+
async function safeRealpath(target) {
|
|
6618
|
+
try {
|
|
6619
|
+
return await node_fs_promises.realpath(target);
|
|
6620
|
+
} catch {
|
|
6621
|
+
return void 0;
|
|
6622
|
+
}
|
|
6623
|
+
}
|
|
6624
|
+
/** 软链接要跟随:`npx skills add` 与 `.claude/skills -> ../.agents/skills` 都是常见布局 */
|
|
6625
|
+
async function entryKind(full, entry) {
|
|
6626
|
+
if (entry.isDirectory()) return "dir";
|
|
6627
|
+
if (entry.isFile()) return "file";
|
|
6628
|
+
if (!entry.isSymbolicLink()) return "none";
|
|
6629
|
+
try {
|
|
6630
|
+
const stat = await node_fs_promises.stat(full);
|
|
6631
|
+
if (stat.isDirectory()) return "dir";
|
|
6632
|
+
if (stat.isFile()) return "file";
|
|
6633
|
+
} catch {}
|
|
6634
|
+
return "none";
|
|
6635
|
+
}
|
|
6636
|
+
/** 技能目录内的附加文件,深度受限、跳过隐藏与依赖目录 */
|
|
6637
|
+
async function listResources(dir, maxFiles, maxDepth) {
|
|
6638
|
+
const found = [];
|
|
6639
|
+
const queue = [{
|
|
6640
|
+
dir,
|
|
6641
|
+
depth: 0
|
|
6642
|
+
}];
|
|
6643
|
+
while (queue.length > 0 && found.length < maxFiles) {
|
|
6644
|
+
const current = queue.shift();
|
|
6645
|
+
let entries;
|
|
6646
|
+
try {
|
|
6647
|
+
entries = await node_fs_promises.readdir(current.dir, { withFileTypes: true });
|
|
6648
|
+
} catch {
|
|
6649
|
+
continue;
|
|
6650
|
+
}
|
|
6651
|
+
for (const entry of entries) {
|
|
6652
|
+
if (shouldSkipName(entry.name)) continue;
|
|
6653
|
+
const full = node_path.join(current.dir, entry.name);
|
|
6654
|
+
if (entry.isDirectory()) {
|
|
6655
|
+
if (current.depth + 1 <= maxDepth) queue.push({
|
|
6656
|
+
dir: full,
|
|
6657
|
+
depth: current.depth + 1
|
|
6658
|
+
});
|
|
6659
|
+
continue;
|
|
6660
|
+
}
|
|
6661
|
+
if (!entry.isFile()) continue;
|
|
6662
|
+
if (entry.name === SKILL_FILE_NAME) continue;
|
|
6663
|
+
found.push(toPosix(node_path.relative(dir, full)));
|
|
6664
|
+
if (found.length >= maxFiles) break;
|
|
6665
|
+
}
|
|
6666
|
+
}
|
|
6667
|
+
return found.sort();
|
|
6668
|
+
}
|
|
6669
|
+
/** 枚举一个根下的技能候选:`<name>/SKILL.md` 与 `<name>.md` 两种形态 */
|
|
6670
|
+
async function listSkillEntries(root) {
|
|
6671
|
+
let entries;
|
|
6672
|
+
try {
|
|
6673
|
+
entries = await node_fs_promises.readdir(root.path, { withFileTypes: true });
|
|
6674
|
+
} catch {
|
|
6675
|
+
return [];
|
|
6676
|
+
}
|
|
6677
|
+
const found = [];
|
|
6678
|
+
for (const entry of entries) {
|
|
6679
|
+
if (shouldSkipName(entry.name)) continue;
|
|
6680
|
+
const full = node_path.join(root.path, entry.name);
|
|
6681
|
+
const kind = await entryKind(full, entry);
|
|
6682
|
+
if (kind === "dir") {
|
|
6683
|
+
found.push({
|
|
6684
|
+
entryName: entry.name,
|
|
6685
|
+
skillDir: full,
|
|
6686
|
+
skillPath: node_path.join(full, SKILL_FILE_NAME)
|
|
6687
|
+
});
|
|
6688
|
+
continue;
|
|
6689
|
+
}
|
|
6690
|
+
if (kind === "file" && entry.name.toLowerCase().endsWith(".md")) found.push({
|
|
6691
|
+
entryName: entry.name,
|
|
6692
|
+
skillDir: root.path,
|
|
6693
|
+
skillPath: full
|
|
6694
|
+
});
|
|
6695
|
+
}
|
|
6696
|
+
return found;
|
|
6697
|
+
}
|
|
6698
|
+
/** 读盘并解析一个技能候选;缺文件、软链接断链、超大都返回空结果 */
|
|
6699
|
+
async function readSkillEntry(root, entry, options = {}) {
|
|
6700
|
+
const maxResourceFiles = options.maxResourceFiles ?? DEFAULT_MAX_RESOURCE_FILES;
|
|
6701
|
+
const maxResourceDepth = options.maxResourceDepth ?? DEFAULT_MAX_RESOURCE_DEPTH;
|
|
6702
|
+
const realDir = await safeRealpath(entry.skillDir);
|
|
6703
|
+
if (!realDir) return {
|
|
6704
|
+
skills: [],
|
|
6705
|
+
diagnostics: []
|
|
6706
|
+
};
|
|
6707
|
+
let raw;
|
|
6708
|
+
try {
|
|
6709
|
+
raw = await node_fs_promises.readFile(entry.skillPath, "utf-8");
|
|
6710
|
+
} catch {
|
|
6711
|
+
return {
|
|
6712
|
+
skills: [],
|
|
6713
|
+
diagnostics: []
|
|
6714
|
+
};
|
|
6715
|
+
}
|
|
6716
|
+
if (Buffer.byteLength(raw, "utf-8") > MAX_SKILL_FILE_BYTES) return {
|
|
6717
|
+
skills: [],
|
|
6718
|
+
diagnostics: [{
|
|
6719
|
+
level: "error",
|
|
6720
|
+
code: "READ_FAILED",
|
|
6721
|
+
message: `${SKILL_FILE_NAME} 超过 256KB,已忽略`,
|
|
6722
|
+
path: entry.skillPath
|
|
6723
|
+
}]
|
|
6724
|
+
};
|
|
6725
|
+
const parsed = parseSkillFile(entry.skillPath, raw);
|
|
6726
|
+
const diagnostics = [...parsed.diagnostics];
|
|
6727
|
+
if (!parsed.skill) return {
|
|
6728
|
+
skills: [],
|
|
6729
|
+
diagnostics
|
|
6730
|
+
};
|
|
6731
|
+
const expected = entry.entryName.replace(/\.md$/i, "");
|
|
6732
|
+
if (entry.skillDir !== root.path && parsed.skill.name !== expected) diagnostics.push({
|
|
6733
|
+
level: "warn",
|
|
6734
|
+
code: "NAME_MISMATCH",
|
|
6735
|
+
message: `frontmatter name "${parsed.skill.name}" 与目录名 "${expected}" 不一致`,
|
|
6736
|
+
path: entry.skillPath
|
|
6737
|
+
});
|
|
6738
|
+
const resources = entry.skillDir === root.path ? [] : await listResources(realDir, maxResourceFiles, maxResourceDepth);
|
|
6739
|
+
return {
|
|
6740
|
+
skills: [{
|
|
6741
|
+
name: parsed.skill.name,
|
|
6742
|
+
description: parsed.skill.description,
|
|
6743
|
+
invoke: parsed.skill.invoke,
|
|
6744
|
+
rootId: root.id,
|
|
6745
|
+
dir: realDir,
|
|
6746
|
+
path: entry.skillPath,
|
|
6747
|
+
resources
|
|
6748
|
+
}],
|
|
6749
|
+
diagnostics
|
|
6750
|
+
};
|
|
6751
|
+
}
|
|
6752
|
+
/**
|
|
6753
|
+
* 按 rank 合并各组结果;重名时先出现的(rank 小的)获胜,后来者记一条 warn。
|
|
6754
|
+
* `groups` 必须已按 rank 升序排列。
|
|
6755
|
+
*/
|
|
6756
|
+
function mergeSkillGroups(groups, diagnostics) {
|
|
6757
|
+
const winners = new Map();
|
|
6758
|
+
for (const group of groups) for (const summary of group) {
|
|
6759
|
+
const existing = winners.get(summary.name);
|
|
6760
|
+
if (existing) {
|
|
6761
|
+
diagnostics.push({
|
|
6762
|
+
level: "warn",
|
|
6763
|
+
code: "NAME_DUPLICATE",
|
|
6764
|
+
message: `技能名 "${summary.name}" 已被 ${existing.rootId} 占用,${summary.rootId} 的这份被忽略`,
|
|
6765
|
+
path: summary.path
|
|
6766
|
+
});
|
|
6767
|
+
continue;
|
|
6768
|
+
}
|
|
6769
|
+
winners.set(summary.name, summary);
|
|
6770
|
+
}
|
|
6771
|
+
return [...winners.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
6772
|
+
}
|
|
6773
|
+
/** 扫描一个技能根(无缓存) */
|
|
6774
|
+
async function discoverRoot(root, options = {}) {
|
|
6775
|
+
const skills = [];
|
|
6776
|
+
const diagnostics = [];
|
|
6777
|
+
for (const entry of await listSkillEntries(root)) {
|
|
6778
|
+
const result = await readSkillEntry(root, entry, options);
|
|
6779
|
+
skills.push(...result.skills);
|
|
6780
|
+
diagnostics.push(...result.diagnostics);
|
|
6781
|
+
}
|
|
6782
|
+
return {
|
|
6783
|
+
skills,
|
|
6784
|
+
diagnostics
|
|
6785
|
+
};
|
|
6786
|
+
}
|
|
6787
|
+
/** 扫描全部根(无缓存);技能重名时 rank 小的先赢 */
|
|
6788
|
+
async function discoverSkills(roots, options = {}) {
|
|
6789
|
+
const diagnostics = [];
|
|
6790
|
+
const groups = [];
|
|
6791
|
+
for (const root of [...roots].sort((a, b) => a.rank - b.rank)) {
|
|
6792
|
+
const result = await discoverRoot(root, options);
|
|
6793
|
+
diagnostics.push(...result.diagnostics);
|
|
6794
|
+
groups.push(result.skills);
|
|
6795
|
+
}
|
|
6796
|
+
return {
|
|
6797
|
+
skills: mergeSkillGroups(groups, diagnostics),
|
|
6798
|
+
diagnostics
|
|
6799
|
+
};
|
|
6800
|
+
}
|
|
6801
|
+
|
|
6802
|
+
//#endregion
|
|
6803
|
+
//#region src/skills/catalog.ts
|
|
6804
|
+
const DEFAULT_RESCAN_INTERVAL_MS = 2e3;
|
|
6805
|
+
async function statKey(target) {
|
|
6806
|
+
try {
|
|
6807
|
+
const stat = await node_fs_promises.stat(target);
|
|
6808
|
+
return `${stat.mtimeMs}:${stat.size}`;
|
|
6809
|
+
} catch {
|
|
6810
|
+
return "missing";
|
|
6811
|
+
}
|
|
6812
|
+
}
|
|
6813
|
+
/** 技能目录:扫描五个标准根,合并去重,按需读正文 */
|
|
6814
|
+
function createSkillCatalog(options = {}) {
|
|
6815
|
+
const roots = [...options.roots ?? resolveSkillRoots(options)].sort((a, b) => a.rank - b.rank);
|
|
6816
|
+
const ttl = options.rescanIntervalMs ?? DEFAULT_RESCAN_INTERVAL_MS;
|
|
6817
|
+
const discoverOptions = { maxResourceFiles: options.maxResourceFiles };
|
|
6818
|
+
const logger = options.logger;
|
|
6819
|
+
const entries = new Map();
|
|
6820
|
+
let state;
|
|
6821
|
+
async function scanRoot(root, found) {
|
|
6822
|
+
const group = [];
|
|
6823
|
+
for (const entry of found) {
|
|
6824
|
+
const key$1 = await entryStamp(entry);
|
|
6825
|
+
const cached = entries.get(entry.skillPath);
|
|
6826
|
+
if (cached && cached.key === key$1) {
|
|
6827
|
+
group.push(...cached.skills);
|
|
6828
|
+
continue;
|
|
6829
|
+
}
|
|
6830
|
+
const result = await readSkillEntry(root, entry, discoverOptions);
|
|
6831
|
+
entries.set(entry.skillPath, {
|
|
6832
|
+
key: key$1,
|
|
6833
|
+
skills: result.skills,
|
|
6834
|
+
diagnostics: result.diagnostics
|
|
6835
|
+
});
|
|
6836
|
+
group.push(...result.skills);
|
|
6837
|
+
}
|
|
6838
|
+
return group;
|
|
6839
|
+
}
|
|
6840
|
+
async function entryStamp(entry) {
|
|
6841
|
+
const [file, dir] = await Promise.all([statKey(entry.skillPath), statKey(entry.skillDir)]);
|
|
6842
|
+
return `${file}|${dir}`;
|
|
6843
|
+
}
|
|
6844
|
+
function errorSignature(diagnostics) {
|
|
6845
|
+
return diagnostics.filter((item) => item.level === "error").map((item) => `${item.path}:${item.message}`).join("\n");
|
|
6846
|
+
}
|
|
6847
|
+
async function scan() {
|
|
6848
|
+
const diagnostics = [];
|
|
6849
|
+
const seen = new Set();
|
|
6850
|
+
const groups = [];
|
|
6851
|
+
for (const root of roots) {
|
|
6852
|
+
const found = await listSkillEntries(root);
|
|
6853
|
+
for (const entry of found) seen.add(entry.skillPath);
|
|
6854
|
+
groups.push(await scanRoot(root, found));
|
|
6855
|
+
}
|
|
6856
|
+
for (const path$8 of [...entries.keys()]) if (!seen.has(path$8)) entries.delete(path$8);
|
|
6857
|
+
for (const cached of entries.values()) diagnostics.push(...cached.diagnostics);
|
|
6858
|
+
return {
|
|
6859
|
+
at: Date.now(),
|
|
6860
|
+
skills: mergeSkillGroups(groups, diagnostics),
|
|
6861
|
+
diagnostics,
|
|
6862
|
+
errorSignature: errorSignature(diagnostics)
|
|
6863
|
+
};
|
|
6864
|
+
}
|
|
6865
|
+
async function snapshot(opts = {}) {
|
|
6866
|
+
if (!opts.force && state && Date.now() - state.at < ttl) return state.skills;
|
|
6867
|
+
const next = await scan();
|
|
6868
|
+
if (next.errorSignature && next.errorSignature !== state?.errorSignature) {
|
|
6869
|
+
const failed = next.diagnostics.filter((item) => item.level === "error");
|
|
6870
|
+
logger?.warn(`技能扫描有 ${failed.length} 个文件不可用:${failed[0]?.message ?? ""}`);
|
|
6871
|
+
}
|
|
6872
|
+
state = next;
|
|
6873
|
+
return state.skills;
|
|
6874
|
+
}
|
|
6875
|
+
return {
|
|
6876
|
+
roots: () => roots,
|
|
6877
|
+
snapshot,
|
|
6878
|
+
async load(name) {
|
|
6879
|
+
const skills = await snapshot();
|
|
6880
|
+
const summary = skills.find((item) => item.name === name);
|
|
6881
|
+
if (!summary) return void 0;
|
|
6882
|
+
let raw;
|
|
6883
|
+
try {
|
|
6884
|
+
raw = await node_fs_promises.readFile(summary.path, "utf-8");
|
|
6885
|
+
} catch {
|
|
6886
|
+
state = void 0;
|
|
6887
|
+
return void 0;
|
|
6888
|
+
}
|
|
6889
|
+
const parsed = parseSkillFile(summary.path, raw);
|
|
6890
|
+
if (!parsed.skill || parsed.skill.name !== name) {
|
|
6891
|
+
state = void 0;
|
|
6892
|
+
entries.delete(summary.path);
|
|
6893
|
+
return void 0;
|
|
6894
|
+
}
|
|
6895
|
+
return {
|
|
6896
|
+
...summary,
|
|
6897
|
+
name: parsed.skill.name,
|
|
6898
|
+
description: parsed.skill.description,
|
|
6899
|
+
invoke: parsed.skill.invoke,
|
|
6900
|
+
content: parsed.skill.content,
|
|
6901
|
+
allowedTools: parsed.skill.allowedTools,
|
|
6902
|
+
...parsed.skill.license ? { license: parsed.skill.license } : {},
|
|
6903
|
+
...parsed.skill.compatibility ? { compatibility: parsed.skill.compatibility } : {},
|
|
6904
|
+
...parsed.skill.metadata ? { metadata: parsed.skill.metadata } : {}
|
|
6905
|
+
};
|
|
6906
|
+
},
|
|
6907
|
+
diagnostics: () => state?.diagnostics ?? [],
|
|
6908
|
+
invalidate() {
|
|
6909
|
+
entries.clear();
|
|
6910
|
+
state = void 0;
|
|
6911
|
+
}
|
|
6912
|
+
};
|
|
6913
|
+
}
|
|
6914
|
+
|
|
6915
|
+
//#endregion
|
|
6916
|
+
//#region src/skills/render.ts
|
|
6917
|
+
const DEFAULT_DESCRIPTION_MAX = 500;
|
|
6918
|
+
function escapeText(value) {
|
|
6919
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
6920
|
+
}
|
|
6921
|
+
/** 目录行:`- \`name\`: description` */
|
|
6922
|
+
function renderSkillCatalog(skills, options = {}) {
|
|
6923
|
+
const max = options.maxDescriptionLength ?? DEFAULT_DESCRIPTION_MAX;
|
|
6924
|
+
return skills.map((skill) => {
|
|
6925
|
+
const description = skill.description.length > max ? `${skill.description.slice(0, max - 1)}…` : skill.description;
|
|
6926
|
+
return `- \`${skill.name}\`: ${escapeText(description)}`;
|
|
6927
|
+
}).join("\n");
|
|
6928
|
+
}
|
|
6929
|
+
/** 加载结果:伪 XML 包裹的资源清单与正文,模型语料里常见的形状 */
|
|
6930
|
+
function renderSkillContent(skill) {
|
|
6931
|
+
const lines = [`技能目录:${skill.dir}`];
|
|
6932
|
+
if (skill.resources.length > 0) {
|
|
6933
|
+
lines.push("附带文件(相对该目录,用 read 读取、用 bash 执行):");
|
|
6934
|
+
for (const resource of skill.resources) lines.push(`- ${resource}`);
|
|
6935
|
+
} else lines.push("该技能没有附带文件。");
|
|
6936
|
+
if (skill.compatibility) lines.push(`环境要求:${skill.compatibility}`);
|
|
6937
|
+
if (skill.allowedTools.length > 0) lines.push(`该技能声明预授权工具:${skill.allowedTools.join(" ")}`);
|
|
6938
|
+
return [
|
|
6939
|
+
`<skill_content name="${skill.name}">`,
|
|
6940
|
+
"<skill_resources>",
|
|
6941
|
+
...lines.map(escapeText),
|
|
6942
|
+
"</skill_resources>",
|
|
6943
|
+
"",
|
|
6944
|
+
"<skill_instructions>",
|
|
6945
|
+
skill.content,
|
|
6946
|
+
"</skill_instructions>",
|
|
6947
|
+
"</skill_content>"
|
|
6948
|
+
].join("\n");
|
|
6949
|
+
}
|
|
6950
|
+
|
|
6951
|
+
//#endregion
|
|
6952
|
+
//#region src/skills/locate.ts
|
|
6953
|
+
const DEFAULT_MAX_DEPTH = 3;
|
|
6954
|
+
const DEFAULT_MAX_CANDIDATES = 50;
|
|
6955
|
+
const FILE_COUNT_CAP = 500;
|
|
6956
|
+
const SKIPPED_DIRS = new Set([".git", "node_modules"]);
|
|
6957
|
+
function shouldSkip(name) {
|
|
6958
|
+
return name.startsWith(".") || SKIPPED_DIRS.has(name);
|
|
6959
|
+
}
|
|
6960
|
+
async function isFile(target) {
|
|
6961
|
+
try {
|
|
6962
|
+
return (await node_fs_promises.stat(target)).isFile();
|
|
6963
|
+
} catch {
|
|
6964
|
+
return false;
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
async function countFiles(dir) {
|
|
6968
|
+
let total = 0;
|
|
6969
|
+
const queue = [{
|
|
6970
|
+
dir,
|
|
6971
|
+
depth: 0
|
|
6972
|
+
}];
|
|
6973
|
+
while (queue.length > 0 && total < FILE_COUNT_CAP) {
|
|
6974
|
+
const current = queue.shift();
|
|
6975
|
+
let entries;
|
|
6976
|
+
try {
|
|
6977
|
+
entries = await node_fs_promises.readdir(current.dir, { withFileTypes: true });
|
|
6978
|
+
} catch {
|
|
6979
|
+
continue;
|
|
6980
|
+
}
|
|
6981
|
+
for (const entry of entries) {
|
|
6982
|
+
if (shouldSkip(entry.name)) continue;
|
|
6983
|
+
if (entry.isDirectory()) {
|
|
6984
|
+
if (current.depth + 1 <= 3) queue.push({
|
|
6985
|
+
dir: node_path.join(current.dir, entry.name),
|
|
6986
|
+
depth: current.depth + 1
|
|
6987
|
+
});
|
|
6988
|
+
continue;
|
|
6989
|
+
}
|
|
6990
|
+
if (entry.isFile()) total += 1;
|
|
6991
|
+
}
|
|
6992
|
+
}
|
|
6993
|
+
return total;
|
|
6994
|
+
}
|
|
6995
|
+
async function describe(dir, skillPath) {
|
|
6996
|
+
const fallbackName = node_path.basename(dir);
|
|
6997
|
+
const files = await countFiles(dir);
|
|
6998
|
+
let raw;
|
|
6999
|
+
try {
|
|
7000
|
+
raw = await node_fs_promises.readFile(skillPath, "utf-8");
|
|
7001
|
+
} catch {
|
|
7002
|
+
return {
|
|
7003
|
+
name: fallbackName,
|
|
7004
|
+
description: "",
|
|
7005
|
+
dir,
|
|
7006
|
+
path: skillPath,
|
|
7007
|
+
files,
|
|
7008
|
+
valid: false,
|
|
7009
|
+
diagnostics: [{
|
|
7010
|
+
level: "error",
|
|
7011
|
+
code: "READ_FAILED",
|
|
7012
|
+
message: "SKILL.md 无法读取",
|
|
7013
|
+
path: skillPath
|
|
7014
|
+
}]
|
|
7015
|
+
};
|
|
7016
|
+
}
|
|
7017
|
+
const parsed = parseSkillFile(skillPath, raw);
|
|
7018
|
+
if (!parsed.skill) return {
|
|
7019
|
+
name: fallbackName,
|
|
7020
|
+
description: "",
|
|
7021
|
+
dir,
|
|
7022
|
+
path: skillPath,
|
|
7023
|
+
files,
|
|
7024
|
+
valid: false,
|
|
7025
|
+
diagnostics: parsed.diagnostics
|
|
7026
|
+
};
|
|
7027
|
+
return {
|
|
7028
|
+
name: parsed.skill.name,
|
|
7029
|
+
description: parsed.skill.description,
|
|
7030
|
+
dir,
|
|
7031
|
+
path: skillPath,
|
|
7032
|
+
files,
|
|
7033
|
+
valid: true,
|
|
7034
|
+
diagnostics: parsed.diagnostics
|
|
7035
|
+
};
|
|
7036
|
+
}
|
|
7037
|
+
/**
|
|
7038
|
+
* 在下载/解包出来的目录里定位技能:根目录有 SKILL.md 就用它,
|
|
7039
|
+
* 否则向下(深度受限)找所有含 SKILL.md 的目录,供安装时挑选。
|
|
7040
|
+
*/
|
|
7041
|
+
async function locateSkillRoots(root, options = {}) {
|
|
7042
|
+
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
7043
|
+
const maxCandidates = options.maxCandidates ?? DEFAULT_MAX_CANDIDATES;
|
|
7044
|
+
const base = node_path.resolve(root);
|
|
7045
|
+
const rootSkill = node_path.join(base, SKILL_FILE_NAME);
|
|
7046
|
+
if (await isFile(rootSkill)) return [await describe(base, rootSkill)];
|
|
7047
|
+
const found = [];
|
|
7048
|
+
const queue = [{
|
|
7049
|
+
dir: base,
|
|
7050
|
+
depth: 0
|
|
7051
|
+
}];
|
|
7052
|
+
while (queue.length > 0 && found.length < maxCandidates) {
|
|
7053
|
+
const current = queue.shift();
|
|
7054
|
+
let entries;
|
|
7055
|
+
try {
|
|
7056
|
+
entries = await node_fs_promises.readdir(current.dir, { withFileTypes: true });
|
|
7057
|
+
} catch {
|
|
7058
|
+
continue;
|
|
7059
|
+
}
|
|
7060
|
+
for (const entry of entries) {
|
|
7061
|
+
if (!entry.isDirectory() || shouldSkip(entry.name)) continue;
|
|
7062
|
+
const child = node_path.join(current.dir, entry.name);
|
|
7063
|
+
const skillPath = node_path.join(child, SKILL_FILE_NAME);
|
|
7064
|
+
if (await isFile(skillPath)) {
|
|
7065
|
+
found.push({
|
|
7066
|
+
dir: child,
|
|
7067
|
+
path: skillPath
|
|
7068
|
+
});
|
|
7069
|
+
if (found.length >= maxCandidates) break;
|
|
7070
|
+
continue;
|
|
7071
|
+
}
|
|
7072
|
+
if (current.depth + 1 < maxDepth) queue.push({
|
|
7073
|
+
dir: child,
|
|
7074
|
+
depth: current.depth + 1
|
|
7075
|
+
});
|
|
7076
|
+
}
|
|
7077
|
+
}
|
|
7078
|
+
const locations = [];
|
|
7079
|
+
for (const item of found) locations.push(await describe(item.dir, item.path));
|
|
7080
|
+
return locations;
|
|
7081
|
+
}
|
|
7082
|
+
|
|
6264
7083
|
//#endregion
|
|
6265
7084
|
//#region src/types.ts
|
|
6266
7085
|
function normalizeSkillPermissionRole(role) {
|
|
@@ -6369,6 +7188,7 @@ exports.CORE_PLUGINS = CORE_PLUGINS;
|
|
|
6369
7188
|
exports.CapabilityRegistry = CapabilityRegistry;
|
|
6370
7189
|
exports.ChromeUA = ChromeUA;
|
|
6371
7190
|
exports.CommandManager = CommandManager;
|
|
7191
|
+
exports.DEFAULT_SKILL_ROOT_SPECS = DEFAULT_SKILL_ROOT_SPECS;
|
|
6372
7192
|
exports.DriverShutdownError = DriverShutdownError;
|
|
6373
7193
|
exports.EventBus = EventBus;
|
|
6374
7194
|
exports.EventCorrelator = EventCorrelator;
|
|
@@ -6376,6 +7196,12 @@ exports.HttpRequestError = HttpRequestError;
|
|
|
6376
7196
|
exports.MessageSegmentImpl = MessageSegmentImpl;
|
|
6377
7197
|
exports.MiokuContext = MiokuContext;
|
|
6378
7198
|
exports.MiokuRuntime = MiokuRuntime;
|
|
7199
|
+
exports.SKILL_COMPATIBILITY_MAX = SKILL_COMPATIBILITY_MAX;
|
|
7200
|
+
exports.SKILL_DESCRIPTION_MAX = SKILL_DESCRIPTION_MAX;
|
|
7201
|
+
exports.SKILL_FILE_NAME = SKILL_FILE_NAME;
|
|
7202
|
+
exports.SKILL_KNOWN_KEYS = SKILL_KNOWN_KEYS;
|
|
7203
|
+
exports.SKILL_NAME_MAX = SKILL_NAME_MAX;
|
|
7204
|
+
exports.SKILL_NAME_PATTERN = SKILL_NAME_PATTERN;
|
|
6379
7205
|
exports.ServiceManager = ServiceManager;
|
|
6380
7206
|
exports.Services = Services;
|
|
6381
7207
|
exports.SystemMap = SystemMap;
|
|
@@ -6435,6 +7261,7 @@ exports.createImportContext = createImportContext;
|
|
|
6435
7261
|
exports.createMessage = createMessage;
|
|
6436
7262
|
exports.createMiokuLogger = createMiokuLogger;
|
|
6437
7263
|
exports.createRuntime = createRuntime;
|
|
7264
|
+
exports.createSkillCatalog = createSkillCatalog;
|
|
6438
7265
|
exports.createStore = createStore;
|
|
6439
7266
|
Object.defineProperty(exports, 'dayjs', {
|
|
6440
7267
|
enumerable: true,
|
|
@@ -6456,8 +7283,11 @@ exports.defineState = defineState;
|
|
|
6456
7283
|
exports.deleteServiceConfig = deleteServiceConfig;
|
|
6457
7284
|
exports.discoverAdapterCandidates = discoverAdapterCandidates;
|
|
6458
7285
|
exports.discoverPluginCandidates = discoverPluginCandidates;
|
|
7286
|
+
exports.discoverRoot = discoverRoot;
|
|
7287
|
+
exports.discoverSkills = discoverSkills;
|
|
6459
7288
|
exports.displayAdapterId = displayAdapterId;
|
|
6460
7289
|
exports.ensureDataDir = ensureDataDir;
|
|
7290
|
+
exports.expandHomePath = expandHomePath;
|
|
6461
7291
|
Object.defineProperty(exports, 'filesize', {
|
|
6462
7292
|
enumerable: true,
|
|
6463
7293
|
get: function () {
|
|
@@ -6467,6 +7297,7 @@ Object.defineProperty(exports, 'filesize', {
|
|
|
6467
7297
|
exports.filter = filter;
|
|
6468
7298
|
exports.find = find;
|
|
6469
7299
|
exports.findLocalPlugins = findLocalPlugins;
|
|
7300
|
+
exports.findSkillRoot = findSkillRoot;
|
|
6470
7301
|
exports.formatAdapterReport = formatAdapterReport;
|
|
6471
7302
|
exports.formatDuration = formatDuration;
|
|
6472
7303
|
exports.formatMiokuStatus = formatMiokuStatus;
|
|
@@ -6484,6 +7315,7 @@ Object.defineProperty(exports, 'fs', {
|
|
|
6484
7315
|
exports.getActiveCommandManager = getActiveCommandManager;
|
|
6485
7316
|
exports.getAllPluginRuntimeStates = getAllPluginRuntimeStates;
|
|
6486
7317
|
exports.getBuiltinPlugins = getBuiltinPlugins;
|
|
7318
|
+
exports.getConfigDefaults = getConfigDefaults;
|
|
6487
7319
|
exports.getConfigDir = getConfigDir;
|
|
6488
7320
|
exports.getDataDir = getDataDir;
|
|
6489
7321
|
exports.getGTk = getGTk;
|
|
@@ -6534,12 +7366,14 @@ exports.isOwnerOrAdmin = isOwnerOrAdmin;
|
|
|
6534
7366
|
exports.isRequestEvent = isRequestEvent;
|
|
6535
7367
|
exports.isSegment = isSegment;
|
|
6536
7368
|
exports.isString = isString;
|
|
7369
|
+
exports.listSkillEntries = listSkillEntries;
|
|
6537
7370
|
exports.loadAdapterDefinition = loadAdapterDefinition;
|
|
6538
7371
|
exports.loadLocalPlugin = loadLocalPlugin;
|
|
6539
7372
|
exports.loadNpmPlugin = loadNpmPlugin;
|
|
6540
7373
|
exports.localNum = localNum;
|
|
6541
7374
|
exports.localeDate = localeDate;
|
|
6542
7375
|
exports.localeTime = localeTime;
|
|
7376
|
+
exports.locateSkillRoots = locateSkillRoots;
|
|
6543
7377
|
exports.logger = rootLogger;
|
|
6544
7378
|
exports.match = match;
|
|
6545
7379
|
exports.md5 = md5;
|
|
@@ -6550,6 +7384,7 @@ exports.memberPoke = memberPoke;
|
|
|
6550
7384
|
exports.memberSetAdmin = memberSetAdmin;
|
|
6551
7385
|
exports.memberSetCard = memberSetCard;
|
|
6552
7386
|
exports.memberSetTitle = memberSetTitle;
|
|
7387
|
+
exports.mergeSkillGroups = mergeSkillGroups;
|
|
6553
7388
|
exports.messageGet = messageGet;
|
|
6554
7389
|
exports.messageGetForward = messageGetForward;
|
|
6555
7390
|
exports.messageRecall = messageRecall;
|
|
@@ -6565,6 +7400,7 @@ exports.noticeAdmins = noticeAdmins;
|
|
|
6565
7400
|
exports.noticeFriends = noticeFriends;
|
|
6566
7401
|
exports.noticeGroups = noticeGroups;
|
|
6567
7402
|
exports.noticeOwners = noticeOwners;
|
|
7403
|
+
exports.parseSkillFile = parseSkillFile;
|
|
6568
7404
|
Object.defineProperty(exports, 'path', {
|
|
6569
7405
|
enumerable: true,
|
|
6570
7406
|
get: function () {
|
|
@@ -6586,11 +7422,15 @@ exports.randomItems = randomItems;
|
|
|
6586
7422
|
exports.readMiokuConfig = readMiokuConfig;
|
|
6587
7423
|
exports.readPackageJson = readPackageJson;
|
|
6588
7424
|
exports.readPackageJsonSafe = readPackageJsonSafe;
|
|
7425
|
+
exports.readSkillEntry = readSkillEntry;
|
|
7426
|
+
exports.registerConfigDefaults = registerConfigDefaults;
|
|
6589
7427
|
exports.registerPluginArtifacts = registerPluginArtifacts;
|
|
6590
7428
|
exports.registerServiceConfig = registerServiceConfig;
|
|
6591
7429
|
exports.registerStatusProvider = registerStatusProvider;
|
|
6592
7430
|
exports.reloadMiokuConfig = reloadMiokuConfig;
|
|
6593
7431
|
exports.removePluginMetadata = removePluginMetadata;
|
|
7432
|
+
exports.renderSkillCatalog = renderSkillCatalog;
|
|
7433
|
+
exports.renderSkillContent = renderSkillContent;
|
|
6594
7434
|
exports.requireService = requireService;
|
|
6595
7435
|
exports.resetPluginMetadata = resetPluginMetadata;
|
|
6596
7436
|
exports.resetPluginRuntimeState = resetPluginRuntimeState;
|
|
@@ -6598,7 +7438,9 @@ exports.resolveCommand = require_exec.resolveCommand;
|
|
|
6598
7438
|
exports.resolveEntry = resolveEntry;
|
|
6599
7439
|
exports.resolveLocalPluginEntry = resolveLocalPluginEntry;
|
|
6600
7440
|
exports.resolveLocalPluginPath = resolveLocalPluginPath;
|
|
7441
|
+
exports.resolveSkillRoots = resolveSkillRoots;
|
|
6601
7442
|
exports.rootLogger = rootLogger;
|
|
7443
|
+
exports.rootOfPath = rootOfPath;
|
|
6602
7444
|
exports.runCommand = require_exec.runCommand;
|
|
6603
7445
|
exports.runCommandInherit = require_exec.runCommandInherit;
|
|
6604
7446
|
exports.segment = segment;
|
|
@@ -6637,5 +7479,6 @@ exports.updateServiceConfig = updateServiceConfig;
|
|
|
6637
7479
|
exports.uuid = uuid;
|
|
6638
7480
|
exports.version = version$1;
|
|
6639
7481
|
exports.wait = wait;
|
|
7482
|
+
exports.withConfigDefaults = withConfigDefaults;
|
|
6640
7483
|
exports.writePackageJson = writePackageJson;
|
|
6641
7484
|
//# sourceMappingURL=index.cjs.map
|