@arabold/docs-mcp-server 1.2.1 → 1.3.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.
|
@@ -1279,6 +1279,17 @@ var VersionNotFoundError = class extends ToolError {
|
|
|
1279
1279
|
return this.availableVersions.sort((a, b) => semver.compare(b.version, a.version))[0];
|
|
1280
1280
|
}
|
|
1281
1281
|
};
|
|
1282
|
+
var LibraryNotFoundError = class extends ToolError {
|
|
1283
|
+
constructor(requestedLibrary, suggestions = []) {
|
|
1284
|
+
let message = `Library '${requestedLibrary}' not found.`;
|
|
1285
|
+
if (suggestions.length > 0) {
|
|
1286
|
+
message += ` Did you mean one of these: ${suggestions.join(", ")}?`;
|
|
1287
|
+
}
|
|
1288
|
+
super(message, "SearchTool");
|
|
1289
|
+
this.requestedLibrary = requestedLibrary;
|
|
1290
|
+
this.suggestions = suggestions;
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1282
1293
|
|
|
1283
1294
|
// src/tools/SearchTool.ts
|
|
1284
1295
|
var SearchTool = class {
|
|
@@ -1292,6 +1303,7 @@ var SearchTool = class {
|
|
|
1292
1303
|
`\u{1F50D} Searching ${library}@${version} for: ${query}${exactMatch ? " (exact match)" : ""}`
|
|
1293
1304
|
);
|
|
1294
1305
|
try {
|
|
1306
|
+
await this.docService.validateLibraryExists(library);
|
|
1295
1307
|
let versionToSearch = version;
|
|
1296
1308
|
if (!exactMatch) {
|
|
1297
1309
|
const versionResult = await this.docService.findBestVersion(library, version);
|
|
@@ -1306,6 +1318,16 @@ var SearchTool = class {
|
|
|
1306
1318
|
logger.info(`\u2705 Found ${results.length} matching results`);
|
|
1307
1319
|
return { results };
|
|
1308
1320
|
} catch (error) {
|
|
1321
|
+
if (error instanceof LibraryNotFoundError) {
|
|
1322
|
+
logger.info(`\u2139\uFE0F Library not found: ${error.message}`);
|
|
1323
|
+
return {
|
|
1324
|
+
results: [],
|
|
1325
|
+
error: {
|
|
1326
|
+
message: error.message,
|
|
1327
|
+
suggestions: error.suggestions
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1309
1331
|
if (error instanceof VersionNotFoundError) {
|
|
1310
1332
|
logger.info(`\u2139\uFE0F Version not found: ${error.message}`);
|
|
1311
1333
|
return {
|
|
@@ -1659,6 +1681,7 @@ var RemoveTool = class {
|
|
|
1659
1681
|
// src/store/DocumentManagementService.ts
|
|
1660
1682
|
import { mkdirSync } from "node:fs";
|
|
1661
1683
|
import path3 from "node:path";
|
|
1684
|
+
import Fuse from "fuse.js";
|
|
1662
1685
|
import semver3 from "semver";
|
|
1663
1686
|
|
|
1664
1687
|
// src/splitter/SemanticMarkdownSplitter.ts
|
|
@@ -11264,16 +11287,53 @@ var DocumentManagementService = class {
|
|
|
11264
11287
|
);
|
|
11265
11288
|
this.splitter = greedySplitter;
|
|
11266
11289
|
}
|
|
11290
|
+
/**
|
|
11291
|
+
* Initializes the underlying document store.
|
|
11292
|
+
*/
|
|
11267
11293
|
async initialize() {
|
|
11268
11294
|
await this.store.initialize();
|
|
11269
11295
|
}
|
|
11296
|
+
/**
|
|
11297
|
+
* Shuts down the underlying document store.
|
|
11298
|
+
*/
|
|
11270
11299
|
async shutdown() {
|
|
11271
11300
|
logger.info("\u{1F50C} Shutting down store manager");
|
|
11272
11301
|
await this.store.shutdown();
|
|
11273
11302
|
}
|
|
11274
11303
|
/**
|
|
11275
|
-
*
|
|
11276
|
-
*
|
|
11304
|
+
* Validates if a library exists in the store (either versioned or unversioned).
|
|
11305
|
+
* Throws LibraryNotFoundError with suggestions if the library is not found.
|
|
11306
|
+
* @param library The name of the library to validate.
|
|
11307
|
+
* @throws {LibraryNotFoundError} If the library does not exist.
|
|
11308
|
+
*/
|
|
11309
|
+
async validateLibraryExists(library) {
|
|
11310
|
+
logger.info(`\u{1F50E} Validating existence of library: ${library}`);
|
|
11311
|
+
const normalizedLibrary = library.toLowerCase();
|
|
11312
|
+
const versions = await this.listVersions(normalizedLibrary);
|
|
11313
|
+
const hasUnversioned = await this.exists(normalizedLibrary, "");
|
|
11314
|
+
if (versions.length === 0 && !hasUnversioned) {
|
|
11315
|
+
logger.warn(`\u26A0\uFE0F Library '${library}' not found.`);
|
|
11316
|
+
const allLibraries = await this.listLibraries();
|
|
11317
|
+
const libraryNames = allLibraries.map((lib) => lib.library);
|
|
11318
|
+
let suggestions = [];
|
|
11319
|
+
if (libraryNames.length > 0) {
|
|
11320
|
+
const fuse = new Fuse(libraryNames, {
|
|
11321
|
+
// Configure fuse.js options if needed (e.g., threshold)
|
|
11322
|
+
// isCaseSensitive: false, // Handled by normalizing library names
|
|
11323
|
+
// includeScore: true,
|
|
11324
|
+
threshold: 0.4
|
|
11325
|
+
// Adjust threshold for desired fuzziness (0=exact, 1=match anything)
|
|
11326
|
+
});
|
|
11327
|
+
const results = fuse.search(normalizedLibrary);
|
|
11328
|
+
suggestions = results.slice(0, 3).map((result) => result.item);
|
|
11329
|
+
logger.info(`\u{1F50D} Found suggestions: ${suggestions.join(", ")}`);
|
|
11330
|
+
}
|
|
11331
|
+
throw new LibraryNotFoundError(library, suggestions);
|
|
11332
|
+
}
|
|
11333
|
+
logger.info(`\u2705 Library '${library}' confirmed to exist.`);
|
|
11334
|
+
}
|
|
11335
|
+
/**
|
|
11336
|
+
* Returns a list of all available semantic versions for a library.
|
|
11277
11337
|
*/
|
|
11278
11338
|
async listVersions(library) {
|
|
11279
11339
|
const versions = await this.store.queryUniqueVersions(library);
|
|
@@ -11438,4 +11498,4 @@ export {
|
|
|
11438
11498
|
RemoveTool,
|
|
11439
11499
|
DocumentManagementService
|
|
11440
11500
|
};
|
|
11441
|
-
//# sourceMappingURL=chunk-
|
|
11501
|
+
//# sourceMappingURL=chunk-75KNYK47.js.map
|