@afterxleep/doc-bot 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -61,7 +61,11 @@ STEP 6: validation(response, project_rules)
|
|
|
61
61
|
### Fallback Response:
|
|
62
62
|
1. **Context Check**: Verify if response requires project knowledge
|
|
63
63
|
2. **Tool Selection**: Use search_documentation if uncertain
|
|
64
|
-
3. **
|
|
64
|
+
3. **Search Limit**: If documentation search yields no results after 2-3 attempts, fall back to web search
|
|
65
|
+
4. **Web Search Guidance**: When instructed to use web search after failed documentation searches:
|
|
66
|
+
- Use web search for official documentation, tutorials, and examples
|
|
67
|
+
- Combine project context with external knowledge when appropriate
|
|
68
|
+
5. **Generic Response**: Only if certain no project context needed
|
|
65
69
|
|
|
66
70
|
## VALIDATION REQUIREMENTS:
|
|
67
71
|
|
|
@@ -37,4 +37,9 @@
|
|
|
37
37
|
- **Mandatory**: Use MCP tools for any project-related query
|
|
38
38
|
- **Precedence**: Tool responses override general knowledge
|
|
39
39
|
- **Accuracy**: Verify information against documentation
|
|
40
|
-
- **Completeness**: Don't add assumptions beyond tool output
|
|
40
|
+
- **Completeness**: Don't add assumptions beyond tool output
|
|
41
|
+
- **Search Limits**: If documentation searches yield no results after 2-3 attempts, follow web search fallback
|
|
42
|
+
- **Fallback Protocol**: When instructed to use web search:
|
|
43
|
+
- Acknowledge the documentation search limitation
|
|
44
|
+
- Use web search for external resources
|
|
45
|
+
- Combine findings with any available project context
|
|
@@ -62,6 +62,11 @@
|
|
|
62
62
|
- **Accuracy**: Do not add information beyond tool output
|
|
63
63
|
- **Completeness**: Use tools for all project-related queries
|
|
64
64
|
- **Validation**: Verify code compliance with project rules
|
|
65
|
+
- **Search Fallback**: If documentation searches fail after 2-3 attempts, the system will recommend web search
|
|
66
|
+
- **Web Search Usage**: When instructed to use web search after failed documentation searches:
|
|
67
|
+
- Use web search for official documentation, community resources, and examples
|
|
68
|
+
- Combine external knowledge with project context appropriately
|
|
69
|
+
- Prioritize authoritative sources for technical information
|
|
65
70
|
|
|
66
71
|
## OPERATIONAL EXAMPLES:
|
|
67
72
|
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,9 @@ class DocsServer {
|
|
|
27
27
|
// Cache for prompt templates
|
|
28
28
|
this.promptTemplates = {};
|
|
29
29
|
|
|
30
|
+
// Track search attempts per session/query pattern
|
|
31
|
+
this.searchAttempts = new Map();
|
|
32
|
+
|
|
30
33
|
this.server = new Server({
|
|
31
34
|
name: 'doc-bot',
|
|
32
35
|
version: '1.0.0',
|
|
@@ -618,8 +621,44 @@ class DocsServer {
|
|
|
618
621
|
}
|
|
619
622
|
|
|
620
623
|
async formatUnifiedSearchResults(results, query) {
|
|
624
|
+
// Track search attempts for this query pattern
|
|
625
|
+
const queryKey = query.toLowerCase().trim();
|
|
626
|
+
const attemptData = this.searchAttempts.get(queryKey) || { count: 0, timestamp: Date.now() };
|
|
627
|
+
attemptData.count += 1;
|
|
628
|
+
attemptData.timestamp = Date.now();
|
|
629
|
+
this.searchAttempts.set(queryKey, attemptData);
|
|
630
|
+
|
|
621
631
|
if (!results || results.length === 0) {
|
|
622
|
-
|
|
632
|
+
// Check if we've tried multiple times
|
|
633
|
+
if (attemptData.count >= 3) {
|
|
634
|
+
// Clear the counter after suggesting fallback
|
|
635
|
+
this.searchAttempts.delete(queryKey);
|
|
636
|
+
|
|
637
|
+
return `No documentation found for query: "${query}" in any source after ${attemptData.count} attempts.
|
|
638
|
+
|
|
639
|
+
## 🌐 Fallback Recommendation:
|
|
640
|
+
Since the documentation search hasn't yielded results after multiple attempts, **consider using web search** to find information about "${query}". Web searches can provide:
|
|
641
|
+
|
|
642
|
+
- Latest API documentation from official sources
|
|
643
|
+
- Community tutorials and examples
|
|
644
|
+
- Stack Overflow solutions
|
|
645
|
+
- Blog posts and articles
|
|
646
|
+
|
|
647
|
+
**Suggested action:** Use web search with queries like:
|
|
648
|
+
- "${query} documentation"
|
|
649
|
+
- "${query} API reference"
|
|
650
|
+
- "${query} example code"
|
|
651
|
+
- "${query} tutorial"
|
|
652
|
+
|
|
653
|
+
This will help you find the most current information beyond the local documentation.`;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return `No documentation found for query: "${query}" in any source.
|
|
657
|
+
|
|
658
|
+
Try:
|
|
659
|
+
- Using different search terms or keywords
|
|
660
|
+
- Searching for related concepts
|
|
661
|
+
- Checking if the correct docset is installed with \`list_docsets\``;
|
|
623
662
|
}
|
|
624
663
|
|
|
625
664
|
let output = `# Search Results for "${query}"\n\n`;
|
|
@@ -1266,6 +1305,17 @@ class DocsServer {
|
|
|
1266
1305
|
await this.docService.initialize();
|
|
1267
1306
|
await this.inferenceEngine.initialize();
|
|
1268
1307
|
|
|
1308
|
+
// Set up periodic cleanup of search attempts (every 5 minutes)
|
|
1309
|
+
this.searchCleanupInterval = setInterval(() => {
|
|
1310
|
+
// Clear search attempts older than 10 minutes
|
|
1311
|
+
const now = Date.now();
|
|
1312
|
+
for (const [key, value] of this.searchAttempts.entries()) {
|
|
1313
|
+
if (typeof value === 'object' && value.timestamp && (now - value.timestamp) > 600000) {
|
|
1314
|
+
this.searchAttempts.delete(key);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}, 300000);
|
|
1318
|
+
|
|
1269
1319
|
// Initialize docset services
|
|
1270
1320
|
try {
|
|
1271
1321
|
await this.docsetService.initialize();
|
|
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { createWriteStream } from 'fs';
|
|
4
4
|
import axios from 'axios';
|
|
5
|
-
import tar from 'tar';
|
|
5
|
+
import * as tar from 'tar';
|
|
6
6
|
import AdmZip from 'adm-zip';
|
|
7
7
|
import plist from 'plist';
|
|
8
8
|
import crypto from 'crypto';
|