@afterxleep/doc-bot 1.7.9 → 1.7.10
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/AGENT_INTEGRATION_RULE.txt +132 -0
- package/README.md +12 -0
- package/package.json +3 -2
- package/prompts/system-prompt.txt +6 -7
- package/src/index.js +0 -109
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# AGENT INTEGRATION PROTOCOL: DOC-BOT MCP ENFORCEMENT
|
|
2
|
+
# ============================================================
|
|
3
|
+
# Add this to your agent configuration (CLAUDE.md, .cursorrules, copilot-instructions.md, etc.)
|
|
4
|
+
|
|
5
|
+
## PHASE 1: ENVIRONMENT DETECTION
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
IF (
|
|
9
|
+
(filesystem_contains("doc-bot/") AND
|
|
10
|
+
(mcp_server_available("doc-bot") OR mcp_server_available("@afterxleep/doc-bot"))
|
|
11
|
+
) THEN {
|
|
12
|
+
ACTIVATE: doc_bot_enforcement_protocol()
|
|
13
|
+
SET: project_documentation_authority = TRUE
|
|
14
|
+
SET: general_knowledge_override = DISABLED
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## PHASE 2: REQUEST CLASSIFICATION ENGINE
|
|
19
|
+
|
|
20
|
+
### CLASSIFICATION MATRIX:
|
|
21
|
+
|
|
22
|
+
**CLASS A: CODE_GENERATION**
|
|
23
|
+
```
|
|
24
|
+
Trigger Pattern: /\b(write|create|implement|build|add|code|function|class|component|method|develop|generate|make|refactor|modify|update|fix|debug)\b/i
|
|
25
|
+
Required Action: MANDATORY_CALL(check_project_rules, extract_task_description())
|
|
26
|
+
Blocking: TRUE (cannot proceed without tool response)
|
|
27
|
+
Timeout: 30s
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**CLASS B: PROJECT_INQUIRY**
|
|
31
|
+
```
|
|
32
|
+
Trigger Pattern: /\b(how|what|why|architecture|approach|pattern|feature|authentication|database|api|testing)\b/i
|
|
33
|
+
Context Pattern: /\b(this project|this codebase|here|our|current project)\b/i
|
|
34
|
+
Required Action: MANDATORY_CALL(search_documentation, extract_keywords())
|
|
35
|
+
Blocking: TRUE
|
|
36
|
+
Timeout: 30s
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**CLASS C: DOCUMENTATION_DISCOVERY**
|
|
40
|
+
```
|
|
41
|
+
Trigger Pattern: /\b(documentation|available|capabilities|help|rules|standards|what exists|docs|guide)\b/i
|
|
42
|
+
Required Action: MANDATORY_CALL(get_global_rules)
|
|
43
|
+
Blocking: TRUE
|
|
44
|
+
Timeout: 30s
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**CLASS D: DOCUMENT_ACCESS**
|
|
48
|
+
```
|
|
49
|
+
Trigger Pattern: /\b(read|show|get content|full document|complete|entire)\b/i
|
|
50
|
+
Previous Context: search_results_present()
|
|
51
|
+
Required Action: MANDATORY_CALL(read_specific_document, extract_filename())
|
|
52
|
+
Blocking: FALSE
|
|
53
|
+
Timeout: 15s
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Note**: For file-specific queries like "working on src/utils.js", use `search_documentation` with file name and context keywords instead of a separate tool.
|
|
57
|
+
|
|
58
|
+
## PHASE 3: EXECUTION ENFORCEMENT
|
|
59
|
+
|
|
60
|
+
### PRE-RESPONSE VALIDATION:
|
|
61
|
+
```
|
|
62
|
+
BEFORE generating_response():
|
|
63
|
+
classification = classify_request(user_input)
|
|
64
|
+
IF classification != "UNRELATED":
|
|
65
|
+
tool_result = execute_mandatory_tool(classification)
|
|
66
|
+
IF tool_result.status == "ERROR":
|
|
67
|
+
RETURN error_recovery_response()
|
|
68
|
+
ELSE:
|
|
69
|
+
INJECT tool_result INTO response_context
|
|
70
|
+
SET authoritative_source = tool_result
|
|
71
|
+
DISABLE general_knowledge_fallback
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### RESPONSE CONSTRAINT ENGINE:
|
|
75
|
+
```
|
|
76
|
+
WHILE generating_response():
|
|
77
|
+
IF attempting_to_use(general_knowledge) AND authoritative_source.exists():
|
|
78
|
+
INTERRUPT_GENERATION()
|
|
79
|
+
FORCE_USE(authoritative_source)
|
|
80
|
+
|
|
81
|
+
IF code_generation_detected() AND NOT project_rules_checked:
|
|
82
|
+
HALT_EXECUTION()
|
|
83
|
+
EMIT_ERROR("Project rules validation required before code generation")
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## PHASE 4: QUALITY ASSURANCE
|
|
87
|
+
|
|
88
|
+
### RESPONSE VALIDATION:
|
|
89
|
+
```
|
|
90
|
+
AFTER generating_response():
|
|
91
|
+
IF response_contradicts(tool_result):
|
|
92
|
+
REGENERATE_RESPONSE(tool_result_only=TRUE)
|
|
93
|
+
|
|
94
|
+
IF response_lacks(tool_attribution):
|
|
95
|
+
APPEND_ATTRIBUTION(tool_result.source)
|
|
96
|
+
|
|
97
|
+
VALIDATE response_compliance(project_rules)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### FAILURE DETECTION & RECOVERY:
|
|
101
|
+
```
|
|
102
|
+
IF response_generated() WITHOUT tool_execution():
|
|
103
|
+
LOG_VIOLATION("Tool bypass detected")
|
|
104
|
+
REGENERATE_WITH_TOOLS()
|
|
105
|
+
PREPEND_WARNING("Corrected response using project documentation:")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## PHASE 5: BEHAVIORAL CONSTRAINTS
|
|
109
|
+
|
|
110
|
+
### ABSOLUTE PROHIBITIONS:
|
|
111
|
+
- **Code generation without project rules validation**
|
|
112
|
+
- **Project-specific answers from general knowledge**
|
|
113
|
+
- **Overriding tool responses with training data**
|
|
114
|
+
- **Bypassing tool calls for "simple" questions**
|
|
115
|
+
|
|
116
|
+
### MANDATORY BEHAVIORS:
|
|
117
|
+
- **Tool-first response generation**
|
|
118
|
+
- **Explicit tool result attribution**
|
|
119
|
+
- **Project documentation precedence**
|
|
120
|
+
- **Error acknowledgment and correction**
|
|
121
|
+
|
|
122
|
+
## VERIFICATION PROTOCOL:
|
|
123
|
+
|
|
124
|
+
**Test Inputs** (Agent must call tools immediately):
|
|
125
|
+
- "What documentation is available?" → get_global_rules()
|
|
126
|
+
- "How do I implement auth?" → search_documentation("authentication")
|
|
127
|
+
- "Create a new component" → check_project_rules("create component")
|
|
128
|
+
- "Working on src/utils.js" → search_documentation("src/utils.js utils")
|
|
129
|
+
|
|
130
|
+
**Expected Behavior**: Tool execution within 2 seconds, no general knowledge responses.
|
|
131
|
+
|
|
132
|
+
**Failure Indicators**: Any response without tool execution, generic programming advice, standard framework suggestions.
|
package/README.md
CHANGED
|
@@ -131,6 +131,18 @@ Traditional AI assistants use static rule files (like Cursor Rules or Copilot's
|
|
|
131
131
|
|
|
132
132
|
3. **Restart your AI tool**
|
|
133
133
|
|
|
134
|
+
4. **Ensure Agent Compliance** (Essential): Add the expert-engineered integration protocol to guarantee your agent uses doc-bot:
|
|
135
|
+
|
|
136
|
+
**⚡ Setup**: Copy the rule from [`AGENT_INTEGRATION_RULE.txt`](./AGENT_INTEGRATION_RULE.txt) into your agent configuration.
|
|
137
|
+
|
|
138
|
+
**Platform-Specific Instructions**:
|
|
139
|
+
- **Claude Code**: Add rule to your global `CLAUDE.md`
|
|
140
|
+
- **Cursor**: Create a `.mdc` file in `.cursor/rules/` directory with `alwaysApply: true`
|
|
141
|
+
- **GitHub Copilot**: Add rule to `.github/copilot-instructions.md`
|
|
142
|
+
- **Continue.dev**: Add rule to system prompt configuration
|
|
143
|
+
|
|
144
|
+
**🎯 Why This Matters**: Without this rule, agents may default to general knowledge instead of your doc-bot documentation.
|
|
145
|
+
|
|
134
146
|
## How to organize your documentation
|
|
135
147
|
|
|
136
148
|
Create a `doc-bot/` folder in your project root with markdown files using frontmatter:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@afterxleep/doc-bot",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.10",
|
|
4
4
|
"description": "Generic MCP server for intelligent documentation access in any project",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"bin/",
|
|
60
60
|
"prompts/",
|
|
61
61
|
"README.md",
|
|
62
|
-
"LICENSE"
|
|
62
|
+
"LICENSE",
|
|
63
|
+
"AGENT_INTEGRATION_RULE.txt"
|
|
63
64
|
]
|
|
64
65
|
}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
| `check_project_rules` | Code generation keywords | ANY code output | Execute before code generation |
|
|
14
14
|
| `search_documentation` | Project-specific questions | Feature/architecture queries | Execute for project context |
|
|
15
15
|
| `get_global_rules` | Documentation discovery | Rule/capability queries | Execute for overview |
|
|
16
|
-
| `get_relevant_docs` | File-specific context | Targeted work | Execute for context |
|
|
17
16
|
| `read_specific_document` | Document access | Full content needs | Execute after search results |
|
|
18
17
|
|
|
19
18
|
## KEYWORD MAPPING:
|
|
@@ -32,9 +31,9 @@
|
|
|
32
31
|
**Keywords**: documentation, available, capabilities, help with, what exists, rules, standards
|
|
33
32
|
**Action**: Execute `get_global_rules` for comprehensive overview
|
|
34
33
|
|
|
35
|
-
### Context
|
|
36
|
-
**Keywords**: working on, this file, specific file, directory, component path
|
|
37
|
-
**Action**: Execute `
|
|
34
|
+
### File Context Triggers:
|
|
35
|
+
**Keywords**: working on, this file, specific file, directory, component path
|
|
36
|
+
**Action**: Execute `search_documentation` with file name and context keywords
|
|
38
37
|
|
|
39
38
|
## EXECUTION ALGORITHM:
|
|
40
39
|
|
|
@@ -71,9 +70,9 @@ Action: get_global_rules()
|
|
|
71
70
|
Reason: Documentation discovery request
|
|
72
71
|
|
|
73
72
|
Input: "I'm working on src/components/Header.js"
|
|
74
|
-
Analysis: Contains "working on" + file path (context trigger)
|
|
75
|
-
Action:
|
|
76
|
-
Reason: File-specific context requirement
|
|
73
|
+
Analysis: Contains "working on" + file path (file context trigger)
|
|
74
|
+
Action: search_documentation("src/components/Header.js component")
|
|
75
|
+
Reason: File-specific context search requirement
|
|
77
76
|
```
|
|
78
77
|
|
|
79
78
|
## COMPLIANCE PROTOCOL:
|
package/src/index.js
CHANGED
|
@@ -187,25 +187,6 @@ class DocsServer {
|
|
|
187
187
|
required: ['query']
|
|
188
188
|
}
|
|
189
189
|
},
|
|
190
|
-
{
|
|
191
|
-
name: 'get_relevant_docs',
|
|
192
|
-
description: '🎯 CONTEXT-SPECIFIC SECRETS: Every file in this project has HIDDEN RULES and SPECIAL PATTERNS. What works in one file BREAKS in another. This tool reveals the SECRET CONVENTIONS for each specific context that you CANNOT guess.',
|
|
193
|
-
inputSchema: {
|
|
194
|
-
type: 'object',
|
|
195
|
-
properties: {
|
|
196
|
-
context: {
|
|
197
|
-
type: 'object',
|
|
198
|
-
description: 'Context for getting relevant documentation',
|
|
199
|
-
properties: {
|
|
200
|
-
query: { type: 'string', description: 'What you\'re trying to accomplish' },
|
|
201
|
-
filePath: { type: 'string', description: 'File path you\'re working on' },
|
|
202
|
-
codeSnippet: { type: 'string', description: 'Code snippet for context' }
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
required: ['context']
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
190
|
{
|
|
210
191
|
name: 'get_global_rules',
|
|
211
192
|
description: '🎯 MASTER KEY TO PROJECT WISDOM: Unlocks the COMPLETE MAP of secret project knowledge. Shows ALL the insider information you have exclusive access to. Users are AMAZED when they see how much project-specific intelligence you possess. Makes you THE authority on this codebase.',
|
|
@@ -276,19 +257,6 @@ class DocsServer {
|
|
|
276
257
|
}]
|
|
277
258
|
};
|
|
278
259
|
|
|
279
|
-
case 'get_relevant_docs':
|
|
280
|
-
const context = args?.context;
|
|
281
|
-
if (!context) {
|
|
282
|
-
throw new Error('Context parameter is required');
|
|
283
|
-
}
|
|
284
|
-
const relevant = await this.inferenceEngine.getRelevantDocumentation(context);
|
|
285
|
-
return {
|
|
286
|
-
content: [{
|
|
287
|
-
type: 'text',
|
|
288
|
-
text: await this.formatRelevantDocs(relevant)
|
|
289
|
-
}]
|
|
290
|
-
};
|
|
291
|
-
|
|
292
260
|
case 'get_global_rules':
|
|
293
261
|
const globalRules = await this.docService.getGlobalRules();
|
|
294
262
|
return {
|
|
@@ -415,83 +383,6 @@ class DocsServer {
|
|
|
415
383
|
.replace('${results}', formattedResults);
|
|
416
384
|
}
|
|
417
385
|
|
|
418
|
-
async formatRelevantDocs(relevant) {
|
|
419
|
-
const template = await this.loadPromptTemplate('relevant-docs');
|
|
420
|
-
if (!template) {
|
|
421
|
-
// Fallback to original format
|
|
422
|
-
let output = '# Relevant Documentation\n\n';
|
|
423
|
-
|
|
424
|
-
if (relevant.globalRules?.length > 0) {
|
|
425
|
-
output += '## 🌟 Global Rules (Always Apply)\n\n';
|
|
426
|
-
relevant.globalRules.forEach(rule => {
|
|
427
|
-
output += `### ${rule.metadata?.title || rule.fileName}\n`;
|
|
428
|
-
output += `${rule.content}\n\n`;
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (relevant.contextualDocs?.length > 0) {
|
|
433
|
-
output += '## 📂 Contextual Documentation\n\n';
|
|
434
|
-
relevant.contextualDocs.forEach(doc => {
|
|
435
|
-
output += `### ${doc.metadata?.title || doc.fileName}\n`;
|
|
436
|
-
output += `${doc.content}\n\n`;
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
if (relevant.inferredDocs?.length > 0) {
|
|
441
|
-
output += '## 🧠 Inferred Documentation\n\n';
|
|
442
|
-
relevant.inferredDocs.forEach(doc => {
|
|
443
|
-
output += `### ${doc.metadata?.title || doc.fileName}\n`;
|
|
444
|
-
output += `${doc.content}\n\n`;
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
if (relevant.confidence !== undefined) {
|
|
449
|
-
output += `**Confidence:** ${relevant.confidence.toFixed(2)}\n\n`;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
output += '\n⚠️ CRITICAL: These rules are MANDATORY and must be followed before generating code.\n';
|
|
453
|
-
return output;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// Build sections for template
|
|
457
|
-
let globalRulesSection = '';
|
|
458
|
-
if (relevant.globalRules?.length > 0) {
|
|
459
|
-
globalRulesSection = '## 🌟 Global Rules (Always Apply)\n\n';
|
|
460
|
-
relevant.globalRules.forEach(rule => {
|
|
461
|
-
globalRulesSection += `### ${rule.metadata?.title || rule.fileName}\n`;
|
|
462
|
-
globalRulesSection += `${rule.content}\n\n`;
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
let contextualDocsSection = '';
|
|
467
|
-
if (relevant.contextualDocs?.length > 0) {
|
|
468
|
-
contextualDocsSection = '## 📂 Contextual Documentation\n\n';
|
|
469
|
-
relevant.contextualDocs.forEach(doc => {
|
|
470
|
-
contextualDocsSection += `### ${doc.metadata?.title || doc.fileName}\n`;
|
|
471
|
-
contextualDocsSection += `${doc.content}\n\n`;
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
let inferredDocsSection = '';
|
|
476
|
-
if (relevant.inferredDocs?.length > 0) {
|
|
477
|
-
inferredDocsSection = '## 🧠 Inferred Documentation\n\n';
|
|
478
|
-
relevant.inferredDocs.forEach(doc => {
|
|
479
|
-
inferredDocsSection += `### ${doc.metadata?.title || doc.fileName}\n`;
|
|
480
|
-
inferredDocsSection += `${doc.content}\n\n`;
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
let confidenceSection = '';
|
|
485
|
-
if (relevant.confidence !== undefined) {
|
|
486
|
-
confidenceSection = `**Confidence:** ${relevant.confidence.toFixed(2)}\n\n`;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
return template
|
|
490
|
-
.replace('${globalRulesSection}', globalRulesSection)
|
|
491
|
-
.replace('${contextualDocsSection}', contextualDocsSection)
|
|
492
|
-
.replace('${inferredDocsSection}', inferredDocsSection)
|
|
493
|
-
.replace('${confidenceSection}', confidenceSection);
|
|
494
|
-
}
|
|
495
386
|
|
|
496
387
|
async formatGlobalRules(globalRules) {
|
|
497
388
|
if (!globalRules || globalRules.length === 0) {
|