mcp-docs-scraper 0.1.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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +357 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +20 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/server.d.ts +6 -0
  8. package/dist/server.d.ts.map +1 -0
  9. package/dist/server.js +231 -0
  10. package/dist/server.js.map +1 -0
  11. package/dist/services/cache-manager.d.ts +100 -0
  12. package/dist/services/cache-manager.d.ts.map +1 -0
  13. package/dist/services/cache-manager.js +212 -0
  14. package/dist/services/cache-manager.js.map +1 -0
  15. package/dist/services/content-cleaner.d.ts +48 -0
  16. package/dist/services/content-cleaner.d.ts.map +1 -0
  17. package/dist/services/content-cleaner.js +295 -0
  18. package/dist/services/content-cleaner.js.map +1 -0
  19. package/dist/services/github-detector.d.ts +49 -0
  20. package/dist/services/github-detector.d.ts.map +1 -0
  21. package/dist/services/github-detector.js +276 -0
  22. package/dist/services/github-detector.js.map +1 -0
  23. package/dist/services/github-fetcher.d.ts +94 -0
  24. package/dist/services/github-fetcher.d.ts.map +1 -0
  25. package/dist/services/github-fetcher.js +393 -0
  26. package/dist/services/github-fetcher.js.map +1 -0
  27. package/dist/services/search-index.d.ts +106 -0
  28. package/dist/services/search-index.d.ts.map +1 -0
  29. package/dist/services/search-index.js +210 -0
  30. package/dist/services/search-index.js.map +1 -0
  31. package/dist/services/web-scraper.d.ts +88 -0
  32. package/dist/services/web-scraper.d.ts.map +1 -0
  33. package/dist/services/web-scraper.js +244 -0
  34. package/dist/services/web-scraper.js.map +1 -0
  35. package/dist/tools/clear-cache.d.ts +24 -0
  36. package/dist/tools/clear-cache.d.ts.map +1 -0
  37. package/dist/tools/clear-cache.js +29 -0
  38. package/dist/tools/clear-cache.js.map +1 -0
  39. package/dist/tools/detect-github.d.ts +21 -0
  40. package/dist/tools/detect-github.d.ts.map +1 -0
  41. package/dist/tools/detect-github.js +18 -0
  42. package/dist/tools/detect-github.js.map +1 -0
  43. package/dist/tools/get-content.d.ts +43 -0
  44. package/dist/tools/get-content.d.ts.map +1 -0
  45. package/dist/tools/get-content.js +84 -0
  46. package/dist/tools/get-content.js.map +1 -0
  47. package/dist/tools/get-tree.d.ts +31 -0
  48. package/dist/tools/get-tree.d.ts.map +1 -0
  49. package/dist/tools/get-tree.js +102 -0
  50. package/dist/tools/get-tree.js.map +1 -0
  51. package/dist/tools/index-docs.d.ts +63 -0
  52. package/dist/tools/index-docs.d.ts.map +1 -0
  53. package/dist/tools/index-docs.js +371 -0
  54. package/dist/tools/index-docs.js.map +1 -0
  55. package/dist/tools/index.d.ts +11 -0
  56. package/dist/tools/index.d.ts.map +1 -0
  57. package/dist/tools/index.js +11 -0
  58. package/dist/tools/index.js.map +1 -0
  59. package/dist/tools/list-cached.d.ts +19 -0
  60. package/dist/tools/list-cached.d.ts.map +1 -0
  61. package/dist/tools/list-cached.js +20 -0
  62. package/dist/tools/list-cached.js.map +1 -0
  63. package/dist/tools/search-docs.d.ts +31 -0
  64. package/dist/tools/search-docs.d.ts.map +1 -0
  65. package/dist/tools/search-docs.js +64 -0
  66. package/dist/tools/search-docs.js.map +1 -0
  67. package/dist/types/cache.d.ts +53 -0
  68. package/dist/types/cache.d.ts.map +1 -0
  69. package/dist/types/cache.js +2 -0
  70. package/dist/types/cache.js.map +1 -0
  71. package/dist/types/errors.d.ts +102 -0
  72. package/dist/types/errors.d.ts.map +1 -0
  73. package/dist/types/errors.js +216 -0
  74. package/dist/types/errors.js.map +1 -0
  75. package/dist/types/index.d.ts +6 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/types/index.js +5 -0
  78. package/dist/types/index.js.map +1 -0
  79. package/dist/utils/fs.d.ts +45 -0
  80. package/dist/utils/fs.d.ts.map +1 -0
  81. package/dist/utils/fs.js +113 -0
  82. package/dist/utils/fs.js.map +1 -0
  83. package/dist/utils/rate-limit.d.ts +55 -0
  84. package/dist/utils/rate-limit.d.ts.map +1 -0
  85. package/dist/utils/rate-limit.js +89 -0
  86. package/dist/utils/rate-limit.js.map +1 -0
  87. package/dist/utils/url.d.ts +69 -0
  88. package/dist/utils/url.d.ts.map +1 -0
  89. package/dist/utils/url.js +251 -0
  90. package/dist/utils/url.js.map +1 -0
  91. package/package.json +58 -0
@@ -0,0 +1,371 @@
1
+ /**
2
+ * index_docs tool - Fetches and caches documentation from GitHub repositories or websites.
3
+ */
4
+ import { cacheManager } from "../services/cache-manager.js";
5
+ import { fetchRepoTree, fetchFileContent, } from "../services/github-fetcher.js";
6
+ import { SearchIndex, createIndexableDocument, } from "../services/search-index.js";
7
+ import { crawlWebsite } from "../services/web-scraper.js";
8
+ import { cleanHtml } from "../services/content-cleaner.js";
9
+ import { extractDomain, normalizeUrl } from "../utils/url.js";
10
+ import { detectGitHubRepo } from "../services/github-detector.js";
11
+ import { InvalidUrlError, NoContentError, ScrapingBlockedError, ValidationError, } from "../types/errors.js";
12
+ /**
13
+ * Parses a GitHub URL to extract owner and repo.
14
+ * Supports formats:
15
+ * - https://github.com/owner/repo
16
+ * - https://github.com/owner/repo/tree/branch/path
17
+ * - github.com/owner/repo
18
+ */
19
+ export function parseGitHubUrl(url) {
20
+ // Normalize URL
21
+ let normalized = url.trim();
22
+ if (!normalized.startsWith("http")) {
23
+ normalized = "https://" + normalized;
24
+ }
25
+ try {
26
+ const parsed = new URL(normalized);
27
+ // Must be github.com
28
+ if (!parsed.hostname.endsWith("github.com")) {
29
+ return null;
30
+ }
31
+ // Parse path: /owner/repo[/tree/branch/path]
32
+ const pathParts = parsed.pathname.split("/").filter(Boolean);
33
+ if (pathParts.length < 2) {
34
+ return null;
35
+ }
36
+ const owner = pathParts[0];
37
+ const repo = pathParts[1].replace(/\.git$/, ""); // Remove .git suffix if present
38
+ let branch;
39
+ let path;
40
+ // Check for /tree/branch/path or /blob/branch/path
41
+ if (pathParts.length > 2 &&
42
+ (pathParts[2] === "tree" || pathParts[2] === "blob")) {
43
+ branch = pathParts[3];
44
+ if (pathParts.length > 4) {
45
+ path = pathParts.slice(4).join("/");
46
+ }
47
+ }
48
+ return { owner, repo, branch, path };
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ }
54
+ /**
55
+ * Generates a cache ID from owner and repo.
56
+ */
57
+ function generateCacheId(owner, repo) {
58
+ return `${owner}_${repo}`;
59
+ }
60
+ /**
61
+ * Collects all file paths from a tree structure.
62
+ */
63
+ function collectFilePaths(nodes) {
64
+ const paths = [];
65
+ function walk(nodeList) {
66
+ for (const node of nodeList) {
67
+ if (node.type === "file") {
68
+ paths.push(node.path);
69
+ }
70
+ else if (node.children) {
71
+ walk(node.children);
72
+ }
73
+ }
74
+ }
75
+ walk(nodes);
76
+ return paths;
77
+ }
78
+ /**
79
+ * Indexes documentation from a GitHub repository.
80
+ */
81
+ async function indexFromGitHub(owner, repo, options = {}) {
82
+ const cacheId = generateCacheId(owner, repo);
83
+ const repoString = `${owner}/${repo}`;
84
+ // Check if already cached (unless force refresh)
85
+ if (!options.forceRefresh) {
86
+ const existing = await cacheManager.getMeta("github", cacheId);
87
+ if (existing && !cacheManager.isExpired(existing)) {
88
+ // Return cached data
89
+ return {
90
+ id: existing.id,
91
+ source: "github",
92
+ repo: existing.repo,
93
+ tree: existing.tree,
94
+ stats: {
95
+ pages: existing.page_count,
96
+ total_size_bytes: existing.total_size_bytes,
97
+ indexed_at: existing.indexed_at,
98
+ },
99
+ };
100
+ }
101
+ }
102
+ // Initialize cache
103
+ await cacheManager.initialize();
104
+ // Fetch the tree structure
105
+ const treeResult = await fetchRepoTree(repoString, {
106
+ branch: options.branch,
107
+ path: options.path,
108
+ extensions: [".md", ".mdx", ".markdown"],
109
+ maxDepth: 10,
110
+ });
111
+ // Collect all file paths to download
112
+ const filePaths = collectFilePaths(treeResult.tree);
113
+ // Download all file contents and build search index
114
+ let totalSize = 0;
115
+ let downloadedCount = 0;
116
+ const searchIndex = new SearchIndex();
117
+ for (const filePath of filePaths) {
118
+ try {
119
+ const content = await fetchFileContent(repoString, treeResult.branch, filePath);
120
+ if (content) {
121
+ // Store content in cache
122
+ await cacheManager.storeContent("github", cacheId, filePath, content.content);
123
+ totalSize += content.size;
124
+ downloadedCount++;
125
+ // Add to search index
126
+ const indexDoc = createIndexableDocument(filePath, content.content);
127
+ searchIndex.addDocument(indexDoc);
128
+ }
129
+ }
130
+ catch (error) {
131
+ // Log but continue - some files might fail
132
+ console.error(`Failed to download ${filePath}:`, error);
133
+ }
134
+ }
135
+ // Store search index
136
+ await cacheManager.storeSearchIndex("github", cacheId, searchIndex.toJSON());
137
+ // Store metadata
138
+ const indexedAt = new Date().toISOString();
139
+ await cacheManager.storeMeta({
140
+ id: cacheId,
141
+ source: "github",
142
+ repo: repoString,
143
+ branch: treeResult.branch,
144
+ indexed_at: indexedAt,
145
+ page_count: downloadedCount,
146
+ total_size_bytes: totalSize,
147
+ tree: treeResult.tree,
148
+ });
149
+ return {
150
+ id: cacheId,
151
+ source: "github",
152
+ repo: repoString,
153
+ tree: treeResult.tree,
154
+ stats: {
155
+ pages: downloadedCount,
156
+ total_size_bytes: totalSize,
157
+ indexed_at: indexedAt,
158
+ },
159
+ };
160
+ }
161
+ /**
162
+ * Generates a cache ID from a URL for scraped content.
163
+ */
164
+ function generateScrapedCacheId(url) {
165
+ const domain = extractDomain(url);
166
+ if (!domain) {
167
+ throw new Error(`Invalid URL: ${url}`);
168
+ }
169
+ // Clean up domain for use as ID
170
+ return domain
171
+ .replace(/^www\./, "")
172
+ .replace(/\./g, "_")
173
+ .replace(/[^a-zA-Z0-9_-]/g, "_");
174
+ }
175
+ /**
176
+ * Indexes documentation from a website via scraping.
177
+ */
178
+ async function indexFromScraping(url, options = {}) {
179
+ const normalizedUrl = normalizeUrl(url);
180
+ const cacheId = generateScrapedCacheId(normalizedUrl);
181
+ // Check if already cached (unless force refresh)
182
+ if (!options.forceRefresh) {
183
+ const existing = await cacheManager.getMeta("scraped", cacheId);
184
+ if (existing && !cacheManager.isExpired(existing)) {
185
+ // Return cached data
186
+ return {
187
+ id: existing.id,
188
+ source: "scraped",
189
+ base_url: existing.base_url,
190
+ tree: existing.tree,
191
+ stats: {
192
+ pages: existing.page_count,
193
+ total_size_bytes: existing.total_size_bytes,
194
+ indexed_at: existing.indexed_at,
195
+ },
196
+ };
197
+ }
198
+ }
199
+ // Initialize cache
200
+ await cacheManager.initialize();
201
+ // Crawl the website
202
+ console.error(`[index_docs] Starting crawl of ${normalizedUrl}...`);
203
+ const crawlResult = await crawlWebsite(normalizedUrl, {
204
+ maxDepth: options.depth ?? 2,
205
+ maxPages: 100,
206
+ requestDelay: 500,
207
+ });
208
+ if (crawlResult.pages.length === 0) {
209
+ // Check if crawling was blocked
210
+ if (crawlResult.skipped.some((s) => s.reason.includes("robots.txt") || s.reason.includes("403"))) {
211
+ throw new ScrapingBlockedError(normalizedUrl, "Site blocked automated access");
212
+ }
213
+ throw new NoContentError(normalizedUrl);
214
+ }
215
+ console.error(`[index_docs] Crawled ${crawlResult.pages.length} pages, converting to markdown...`);
216
+ // Process pages: clean HTML to markdown and store
217
+ let totalSize = 0;
218
+ let processedCount = 0;
219
+ const searchIndex = new SearchIndex();
220
+ const treeNodes = [];
221
+ for (const page of crawlResult.pages) {
222
+ try {
223
+ // Clean HTML to markdown
224
+ const cleaned = cleanHtml(page.html, {
225
+ baseUrl: page.url,
226
+ extractMainContent: true,
227
+ });
228
+ // Skip pages with very little content
229
+ if (cleaned.markdown.trim().length < 100) {
230
+ console.error(`[index_docs] Skipping ${page.filename} - too little content`);
231
+ continue;
232
+ }
233
+ // Add title as H1 if not present and we have a title
234
+ let markdown = cleaned.markdown;
235
+ if (cleaned.title && !markdown.startsWith("# ")) {
236
+ markdown = `# ${cleaned.title}\n\n${markdown}`;
237
+ }
238
+ // Store content in cache
239
+ await cacheManager.storeContent("scraped", cacheId, page.filename, markdown);
240
+ const size = Buffer.byteLength(markdown, "utf8");
241
+ totalSize += size;
242
+ processedCount++;
243
+ // Add to tree
244
+ treeNodes.push({
245
+ name: page.filename,
246
+ path: page.filename,
247
+ type: "file",
248
+ size_bytes: size,
249
+ });
250
+ // Add to search index
251
+ const indexDoc = createIndexableDocument(page.filename, markdown);
252
+ searchIndex.addDocument(indexDoc);
253
+ }
254
+ catch (error) {
255
+ console.error(`[index_docs] Failed to process ${page.url}:`, error);
256
+ }
257
+ }
258
+ if (processedCount === 0) {
259
+ throw new NoContentError(normalizedUrl);
260
+ }
261
+ // Sort tree nodes
262
+ treeNodes.sort((a, b) => a.name.localeCompare(b.name));
263
+ // Store search index
264
+ await cacheManager.storeSearchIndex("scraped", cacheId, searchIndex.toJSON());
265
+ // Store metadata
266
+ const indexedAt = new Date().toISOString();
267
+ await cacheManager.storeMeta({
268
+ id: cacheId,
269
+ source: "scraped",
270
+ base_url: normalizedUrl,
271
+ indexed_at: indexedAt,
272
+ page_count: processedCount,
273
+ total_size_bytes: totalSize,
274
+ tree: treeNodes,
275
+ });
276
+ console.error(`[index_docs] Indexed ${processedCount} pages (${(totalSize / 1024).toFixed(1)} KB)`);
277
+ return {
278
+ id: cacheId,
279
+ source: "scraped",
280
+ base_url: normalizedUrl,
281
+ tree: treeNodes,
282
+ stats: {
283
+ pages: processedCount,
284
+ total_size_bytes: totalSize,
285
+ indexed_at: indexedAt,
286
+ },
287
+ };
288
+ }
289
+ /**
290
+ * Main index_docs implementation.
291
+ * Supports GitHub URLs and website scraping.
292
+ */
293
+ export async function indexDocs(input) {
294
+ const { url, type = "auto", depth, force_refresh = false, include_patterns, exclude_patterns, } = input;
295
+ // Validate required parameters
296
+ if (!url) {
297
+ throw new ValidationError("Missing required parameter: url", "url");
298
+ }
299
+ // Parse URL to determine source
300
+ const githubInfo = parseGitHubUrl(url);
301
+ // Handle explicit type requests
302
+ if (type === "github") {
303
+ if (!githubInfo) {
304
+ throw new InvalidUrlError(url, "Expected GitHub URL format: https://github.com/owner/repo");
305
+ }
306
+ return indexFromGitHub(githubInfo.owner, githubInfo.repo, {
307
+ branch: githubInfo.branch,
308
+ path: githubInfo.path,
309
+ forceRefresh: force_refresh,
310
+ });
311
+ }
312
+ if (type === "scrape") {
313
+ return indexFromScraping(url, {
314
+ depth,
315
+ forceRefresh: force_refresh,
316
+ includePatterns: include_patterns,
317
+ excludePatterns: exclude_patterns,
318
+ });
319
+ }
320
+ // Auto mode: prefer GitHub if detected, otherwise scrape
321
+ if (type === "auto") {
322
+ // If URL is already a GitHub URL, use it directly
323
+ if (githubInfo) {
324
+ console.error(`[index_docs] Auto-detected: direct GitHub URL`);
325
+ const result = await indexFromGitHub(githubInfo.owner, githubInfo.repo, {
326
+ branch: githubInfo.branch,
327
+ path: githubInfo.path,
328
+ forceRefresh: force_refresh,
329
+ });
330
+ return { ...result, detection_method: "direct_github_url" };
331
+ }
332
+ // Try to detect GitHub repo from the docs site
333
+ console.error(`[index_docs] Auto-detecting GitHub repo from ${url}...`);
334
+ const detection = await detectGitHubRepo(url);
335
+ if (detection.found && detection.repo && detection.confidence !== "low") {
336
+ console.error(`[index_docs] Found GitHub repo: ${detection.repo} (${detection.confidence} confidence via ${detection.detection_method})`);
337
+ // Parse the detected repo
338
+ const [owner, repo] = detection.repo.split("/");
339
+ if (owner && repo) {
340
+ try {
341
+ const result = await indexFromGitHub(owner, repo, {
342
+ path: detection.docs_path,
343
+ forceRefresh: force_refresh,
344
+ });
345
+ return {
346
+ ...result,
347
+ detection_method: `auto_github_${detection.detection_method}`,
348
+ };
349
+ }
350
+ catch (error) {
351
+ // GitHub fetch failed, fall back to scraping
352
+ console.error(`[index_docs] GitHub fetch failed, falling back to scraping:`, error instanceof Error ? error.message : error);
353
+ }
354
+ }
355
+ }
356
+ else {
357
+ console.error(`[index_docs] No GitHub repo detected (${detection.detection_method}), using scraping`);
358
+ }
359
+ // Fall back to scraping
360
+ const result = await indexFromScraping(url, {
361
+ depth,
362
+ forceRefresh: force_refresh,
363
+ includePatterns: include_patterns,
364
+ excludePatterns: exclude_patterns,
365
+ });
366
+ return { ...result, detection_method: "scraping_fallback" };
367
+ }
368
+ // Should not reach here
369
+ throw new Error(`Invalid type: "${type}". Expected "github", "scrape", or "auto".`);
370
+ }
371
+ //# sourceMappingURL=index-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-docs.js","sourceRoot":"","sources":["../../src/tools/index-docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,aAAa,EACb,gBAAgB,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,WAAW,EACX,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,eAAe,GAEhB,MAAM,oBAAoB,CAAC;AA4C5B;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IAMxC,gBAAgB;IAChB,IAAI,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;IACvC,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAEnC,qBAAqB;QACrB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,6CAA6C;QAC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oBAC7C,OAAO,CAAC,KAAK,CACX,6DAA6D,EAC7D,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAC/C,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,yCAAyC,SAAS,CAAC,gBAAgB,mBAAmB,CACvF,CAAC;QACJ,CAAC;QAED,wBAAwB;QACxB,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,GAAG,EAAE;YAC1C,KAAK;YACL,YAAY,EAAE,aAAa;YAC3B,eAAe,EAAE,gBAAgB;YACjC,eAAe,EAAE,gBAAgB;SAClC,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,MAAM,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAC;IAC9D,CAAC;IAED,wBAAwB;IACxB,MAAM,IAAI,KAAK,CACb,kBAAkB,IAAI,4CAA4C,CACnE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tool registry - exports all tool implementations.
3
+ */
4
+ export { listCachedDocs, type ListCachedDocsOutput } from "./list-cached.js";
5
+ export { clearCache, type ClearCacheInput, type ClearCacheOutput, } from "./clear-cache.js";
6
+ export { indexDocs, parseGitHubUrl, type IndexDocsInput, type IndexDocsOutput, } from "./index-docs.js";
7
+ export { getDocsTree, type GetDocsTreeInput, type GetDocsTreeOutput, } from "./get-tree.js";
8
+ export { getDocsContent, type GetDocsContentInput, type GetDocsContentOutput, type FileContent, } from "./get-content.js";
9
+ export { searchDocs, type SearchDocsInput, type SearchDocsOutput, } from "./search-docs.js";
10
+ export { detectGitHub, type DetectGitHubInput, type DetectGitHubOutput, } from "./detect-github.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tool registry - exports all tool implementations.
3
+ */
4
+ export { listCachedDocs } from "./list-cached.js";
5
+ export { clearCache, } from "./clear-cache.js";
6
+ export { indexDocs, parseGitHubUrl, } from "./index-docs.js";
7
+ export { getDocsTree, } from "./get-tree.js";
8
+ export { getDocsContent, } from "./get-content.js";
9
+ export { searchDocs, } from "./search-docs.js";
10
+ export { detectGitHub, } from "./detect-github.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAA6B,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,GAGZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,GAIf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Output type for list_cached_docs tool.
3
+ */
4
+ export interface ListCachedDocsOutput {
5
+ docs: Array<{
6
+ id: string;
7
+ source: "github" | "scraped";
8
+ repo?: string;
9
+ base_url?: string;
10
+ indexed_at: string;
11
+ page_count: number;
12
+ total_size_bytes: number;
13
+ }>;
14
+ }
15
+ /**
16
+ * Lists all documentation sets in the local cache.
17
+ */
18
+ export declare function listCachedDocs(): Promise<ListCachedDocsOutput>;
19
+ //# sourceMappingURL=list-cached.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-cached.d.ts","sourceRoot":"","sources":["../../src/tools/list-cached.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,KAAK,CAAC;QACV,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAepE"}
@@ -0,0 +1,20 @@
1
+ import { cacheManager } from "../services/cache-manager.js";
2
+ /**
3
+ * Lists all documentation sets in the local cache.
4
+ */
5
+ export async function listCachedDocs() {
6
+ await cacheManager.initialize();
7
+ const entries = await cacheManager.listEntries();
8
+ return {
9
+ docs: entries.map((entry) => ({
10
+ id: entry.id,
11
+ source: entry.source,
12
+ repo: entry.repo,
13
+ base_url: entry.base_url,
14
+ indexed_at: entry.indexed_at,
15
+ page_count: entry.page_count,
16
+ total_size_bytes: entry.total_size_bytes,
17
+ })),
18
+ };
19
+ }
20
+ //# sourceMappingURL=list-cached.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-cached.js","sourceRoot":"","sources":["../../src/tools/list-cached.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAiB5D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,YAAY,CAAC,UAAU,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,WAAW,EAAE,CAAC;IAEjD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC5B,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;SACzC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * search_docs tool - Full-text search within cached documentation.
3
+ */
4
+ import { type SearchResult } from "../services/search-index.js";
5
+ /**
6
+ * Input for the search_docs tool.
7
+ */
8
+ export interface SearchDocsInput {
9
+ /** The docs ID from index_docs response */
10
+ docs_id: string;
11
+ /** Search query */
12
+ query: string;
13
+ /** Max results to return (default: 10) */
14
+ limit?: number;
15
+ }
16
+ /**
17
+ * Output for the search_docs tool.
18
+ */
19
+ export interface SearchDocsOutput {
20
+ /** The docs ID that was searched */
21
+ docs_id: string;
22
+ /** The query that was executed */
23
+ query: string;
24
+ /** Search results with snippets */
25
+ results: SearchResult[];
26
+ }
27
+ /**
28
+ * Searches within cached documentation using full-text search.
29
+ */
30
+ export declare function searchDocs(input: SearchDocsInput): Promise<SearchDocsOutput>;
31
+ //# sourceMappingURL=search-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-docs.d.ts","sourceRoot":"","sources":["../../src/tools/search-docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG7E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAYD;;GAEG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAoD3B"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * search_docs tool - Full-text search within cached documentation.
3
+ */
4
+ import { cacheManager } from "../services/cache-manager.js";
5
+ import { SearchIndex } from "../services/search-index.js";
6
+ import { CacheNotFoundError, ValidationError, DocsError } from "../types/errors.js";
7
+ /**
8
+ * Default limit for search results.
9
+ */
10
+ const DEFAULT_LIMIT = 10;
11
+ /**
12
+ * Maximum allowed limit for search results.
13
+ */
14
+ const MAX_LIMIT = 50;
15
+ /**
16
+ * Searches within cached documentation using full-text search.
17
+ */
18
+ export async function searchDocs(input) {
19
+ const { docs_id, query, limit = DEFAULT_LIMIT } = input;
20
+ // Validate required parameters
21
+ if (!docs_id) {
22
+ throw new ValidationError("Missing required parameter: docs_id", "docs_id");
23
+ }
24
+ if (!query || typeof query !== "string") {
25
+ throw new ValidationError("Missing required parameter: query", "query");
26
+ }
27
+ // Validate limit
28
+ const effectiveLimit = Math.min(Math.max(1, limit), MAX_LIMIT);
29
+ // Find the cached docs entry to determine source type
30
+ const meta = await cacheManager.findById(docs_id);
31
+ if (!meta) {
32
+ throw new CacheNotFoundError(docs_id);
33
+ }
34
+ // Load the search index
35
+ const indexJson = await cacheManager.getSearchIndex(meta.source, docs_id);
36
+ if (!indexJson) {
37
+ throw new DocsError("CACHE_NOT_FOUND", `Search index not found for "${docs_id}"`, {
38
+ userMessage: `Search index not found for "${docs_id}". Please re-index the documentation.`,
39
+ suggestions: ["Run index_docs with force_refresh: true to rebuild the search index"],
40
+ context: { docs_id },
41
+ });
42
+ }
43
+ // Parse and search
44
+ let searchIndex;
45
+ try {
46
+ searchIndex = SearchIndex.fromJSON(indexJson);
47
+ }
48
+ catch (error) {
49
+ throw new DocsError("PARSE_ERROR", "Failed to load search index", {
50
+ userMessage: "Search index is corrupted. Please re-index the documentation.",
51
+ suggestions: ["Run index_docs with force_refresh: true to rebuild the search index"],
52
+ context: { docs_id },
53
+ cause: error instanceof Error ? error : undefined,
54
+ });
55
+ }
56
+ // Perform the search
57
+ const results = searchIndex.search(query, effectiveLimit);
58
+ return {
59
+ docs_id,
60
+ query,
61
+ results,
62
+ };
63
+ }
64
+ //# sourceMappingURL=search-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-docs.js","sourceRoot":"","sources":["../../src/tools/search-docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA0BpF;;GAEG;AACH,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;GAEG;AACH,MAAM,SAAS,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C;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,SAAS,CAAC,aAAa,EAAE,6BAA6B,EAAE;YAChE,WAAW,EAAE,+DAA+D;YAC5E,WAAW,EAAE,CAAC,qEAAqE,CAAC;YACpF,OAAO,EAAE,EAAE,OAAO,EAAE;YACpB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SAClD,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB;IACrB,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAE1D,OAAO;QACL,OAAO;QACP,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Represents a node in the documentation tree structure.
3
+ */
4
+ export interface DocsTreeNode {
5
+ /** File or folder name */
6
+ name: string;
7
+ /** Full path from root */
8
+ path: string;
9
+ /** Node type */
10
+ type: "file" | "folder";
11
+ /** File size in bytes (for files only) */
12
+ size_bytes?: number;
13
+ /** Child nodes (for folders only) */
14
+ children?: DocsTreeNode[];
15
+ }
16
+ /**
17
+ * Metadata stored for each cached documentation set.
18
+ */
19
+ export interface CacheMeta {
20
+ /** Unique identifier for this docs set */
21
+ id: string;
22
+ /** Source type */
23
+ source: "github" | "scraped";
24
+ /** Repository in "owner/repo" format */
25
+ repo?: string;
26
+ /** Branch name */
27
+ branch?: string;
28
+ /** Base URL of the scraped documentation */
29
+ base_url?: string;
30
+ /** ISO timestamp when docs were indexed */
31
+ indexed_at: string;
32
+ /** ISO timestamp when cache expires */
33
+ expires_at: string;
34
+ /** Number of pages/files in the docs */
35
+ page_count: number;
36
+ /** Total size of all content in bytes */
37
+ total_size_bytes: number;
38
+ /** Hierarchical file tree */
39
+ tree: DocsTreeNode[];
40
+ }
41
+ /**
42
+ * Summary information about a cached docs entry (for listing).
43
+ */
44
+ export interface CacheEntrySummary {
45
+ id: string;
46
+ source: "github" | "scraped";
47
+ repo?: string;
48
+ base_url?: string;
49
+ indexed_at: string;
50
+ page_count: number;
51
+ total_size_bytes: number;
52
+ }
53
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/types/cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB;IAClB,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;IAG7B,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,gBAAgB,EAAE,MAAM,CAAC;IAEzB,6BAA6B;IAC7B,IAAI,EAAE,YAAY,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/types/cache.ts"],"names":[],"mappings":""}