qmd-autosearch 0.1.1 → 0.1.2
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/index.js +24 -18
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -201,25 +201,31 @@ export function apply(ctx, config) {
|
|
|
201
201
|
return resolve(p);
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
|
-
let
|
|
204
|
+
let rootsLoading = null;
|
|
205
|
+
// 懒加载触发路径池:失败时不置位,下次触发自动重试(QMD 暂时不可用不会导致永久静默)
|
|
205
206
|
const loadTriggerRoots = async () => {
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
207
|
+
if (triggerRoots.length > 0) return;
|
|
208
|
+
if (rootsLoading !== null) return rootsLoading;
|
|
209
|
+
rootsLoading = (async () => {
|
|
210
|
+
try {
|
|
211
|
+
const { sessionId } = await mcpRequest(qmdUrl, null, "initialize", {
|
|
212
|
+
protocolVersion: "2025-03-26",
|
|
213
|
+
capabilities: {},
|
|
214
|
+
clientInfo: { name: "qmd-autosearch", version: "0.1.0" }
|
|
215
|
+
});
|
|
216
|
+
const { result } = await mcpRequest(qmdUrl, sessionId, "tools/call", {
|
|
217
|
+
name: "status",
|
|
218
|
+
arguments: {}
|
|
219
|
+
});
|
|
220
|
+
triggerRoots = parseCollectionRoots(extractText(result));
|
|
221
|
+
ctx.logger.info("qmd-autosearch: 触发路径池(来自 QMD 集合)%d 个", triggerRoots.length);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
ctx.logger.warn("qmd-autosearch: 解析 QMD 集合路径失败(下次触发将重试): %o", error);
|
|
224
|
+
} finally {
|
|
225
|
+
rootsLoading = null;
|
|
226
|
+
}
|
|
227
|
+
})();
|
|
228
|
+
return rootsLoading;
|
|
223
229
|
};
|
|
224
230
|
|
|
225
231
|
const isOurs = (message) => message.source?.kind === "plugin" && message.source?.plugin === name;
|