@afterxleep/doc-bot 1.3.0 → 1.4.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/README.md +24 -1
- package/package.json +1 -1
- package/src/index.js +101 -9
package/README.md
CHANGED
|
@@ -119,7 +119,9 @@ Doc-bot ensures your rules are **always considered** through multiple enforcemen
|
|
|
119
119
|
- **Rule reminders**: Every tool response includes compliance warnings
|
|
120
120
|
|
|
121
121
|
### 🔄 Automatic Integration
|
|
122
|
-
- **
|
|
122
|
+
- **Enhanced system prompt injection**: Comprehensive MCP usage protocol injected via `docs://system-prompt`
|
|
123
|
+
- **Documentation discovery**: Available topics automatically extracted and presented to agent
|
|
124
|
+
- **Tool usage instructions**: Explicit requirements for when and how to use each MCP tool
|
|
123
125
|
- **Contextual rules**: Applied when working with matching files/patterns
|
|
124
126
|
- **Multiple touchpoints**: Rules enforced at every interaction level
|
|
125
127
|
|
|
@@ -131,6 +133,27 @@ All tool responses include explicit warnings that rules are:
|
|
|
131
133
|
|
|
132
134
|
This multi-layered approach makes rule violations virtually impossible to ignore.
|
|
133
135
|
|
|
136
|
+
## System Prompt Integration
|
|
137
|
+
|
|
138
|
+
The `docs://system-prompt` resource automatically injects comprehensive instructions into the AI agent's system context:
|
|
139
|
+
|
|
140
|
+
### 📋 MCP Usage Protocol
|
|
141
|
+
- Explicit instructions to **ALWAYS** call `check_project_rules` before code generation
|
|
142
|
+
- **NEVER generate code without checking documentation** requirement
|
|
143
|
+
- Mandatory acknowledgment of rule compliance
|
|
144
|
+
|
|
145
|
+
### 🏷️ Automatic Topic Discovery
|
|
146
|
+
- Extracts available documentation topics from your project
|
|
147
|
+
- Presents them to the agent for context awareness
|
|
148
|
+
- Includes topics from metadata, filenames, and content analysis
|
|
149
|
+
|
|
150
|
+
### 🛠️ Tool Usage Requirements
|
|
151
|
+
- Specifies when and how to use each MCP tool
|
|
152
|
+
- Maps tools to specific use cases (file-specific docs, search, etc.)
|
|
153
|
+
- Ensures comprehensive documentation coverage
|
|
154
|
+
|
|
155
|
+
The system prompt is regenerated on each request to reflect current documentation state.
|
|
156
|
+
|
|
134
157
|
## The manifest file
|
|
135
158
|
|
|
136
159
|
The `doc-bot/manifest.json` file controls how your documentation works:
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -404,22 +404,114 @@ class DocsServer {
|
|
|
404
404
|
|
|
405
405
|
async generateSystemPrompt() {
|
|
406
406
|
const globalRules = await this.docService.getGlobalRules();
|
|
407
|
+
const allDocs = await this.docService.getAllDocuments();
|
|
408
|
+
|
|
409
|
+
let prompt = '# CRITICAL: Project Documentation and MCP Server Integration\n\n';
|
|
410
|
+
|
|
411
|
+
// Add MCP server usage instructions
|
|
412
|
+
prompt += '## 🔧 MANDATORY: MCP Server Usage Protocol\n\n';
|
|
413
|
+
prompt += 'You have access to a doc-bot MCP server with the following MANDATORY requirements:\n\n';
|
|
414
|
+
prompt += '### 🚨 BEFORE ANY CODE GENERATION:\n';
|
|
415
|
+
prompt += '1. **ALWAYS** call `check_project_rules` tool first to get critical project rules\n';
|
|
416
|
+
prompt += '2. **NEVER generate code without checking project documentation**\n';
|
|
417
|
+
prompt += '3. **REQUIRED** to acknowledge rule compliance before proceeding\n\n';
|
|
418
|
+
|
|
419
|
+
prompt += '### 📚 Available Documentation Resources:\n';
|
|
420
|
+
if (allDocs && allDocs.length > 0) {
|
|
421
|
+
const docTopics = this.extractDocumentationTopics(allDocs);
|
|
422
|
+
prompt += 'This project has documentation covering:\n';
|
|
423
|
+
docTopics.forEach(topic => {
|
|
424
|
+
prompt += `- ${topic}\n`;
|
|
425
|
+
});
|
|
426
|
+
prompt += '\n';
|
|
427
|
+
}
|
|
407
428
|
|
|
408
|
-
|
|
409
|
-
|
|
429
|
+
prompt += '### 🛠️ Required MCP Tool Usage:\n';
|
|
430
|
+
prompt += '- Use `check_project_rules` before ANY code generation\n';
|
|
431
|
+
prompt += '- Use `get_relevant_docs` when working with specific files/patterns\n';
|
|
432
|
+
prompt += '- Use `search_documentation` to find specific guidance\n';
|
|
433
|
+
prompt += '- Use `get_global_rules` for comprehensive rule review\n\n';
|
|
434
|
+
|
|
435
|
+
// Add project-specific rules
|
|
436
|
+
if (globalRules && globalRules.length > 0) {
|
|
437
|
+
prompt += '## 📋 Project-Specific Rules (NON-NEGOTIABLE)\n\n';
|
|
438
|
+
prompt += 'IMPORTANT: You MUST follow these rules before generating ANY code:\n\n';
|
|
439
|
+
|
|
440
|
+
globalRules.forEach((rule, index) => {
|
|
441
|
+
prompt += `### Rule ${index + 1}: ${rule.metadata?.title || rule.fileName}\n`;
|
|
442
|
+
prompt += `${rule.content}\n\n`;
|
|
443
|
+
});
|
|
410
444
|
}
|
|
411
445
|
|
|
412
|
-
|
|
413
|
-
prompt += '
|
|
446
|
+
prompt += '---\n\n';
|
|
447
|
+
prompt += '⚠️ **CRITICAL COMPLIANCE REQUIREMENTS:**\n';
|
|
448
|
+
prompt += '- VIOLATION OF THESE RULES IS NOT ACCEPTABLE\n';
|
|
449
|
+
prompt += '- ALWAYS use MCP tools before coding\n';
|
|
450
|
+
prompt += '- ACKNOWLEDGE rule compliance before responding\n';
|
|
451
|
+
prompt += '- NEVER assume - always check documentation\n';
|
|
414
452
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
453
|
+
return prompt;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
extractDocumentationTopics(docs) {
|
|
457
|
+
const topics = new Set();
|
|
458
|
+
|
|
459
|
+
docs.forEach(doc => {
|
|
460
|
+
// Add topics from metadata
|
|
461
|
+
if (doc.metadata?.topics) {
|
|
462
|
+
doc.metadata.topics.forEach(topic => topics.add(topic));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Add topics from keywords
|
|
466
|
+
if (doc.metadata?.keywords) {
|
|
467
|
+
doc.metadata.keywords.forEach(keyword => topics.add(keyword));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// Add filename-based topics
|
|
471
|
+
const fileName = doc.fileName.replace(/\.(md|txt)$/, '');
|
|
472
|
+
const fileTopics = fileName.split(/[-_]/).map(part =>
|
|
473
|
+
part.charAt(0).toUpperCase() + part.slice(1)
|
|
474
|
+
);
|
|
475
|
+
fileTopics.forEach(topic => topics.add(topic));
|
|
476
|
+
|
|
477
|
+
// Add content-based topics (simple heuristic)
|
|
478
|
+
if (doc.content) {
|
|
479
|
+
const contentTopics = this.extractContentTopics(doc.content);
|
|
480
|
+
contentTopics.forEach(topic => topics.add(topic));
|
|
481
|
+
}
|
|
418
482
|
});
|
|
419
483
|
|
|
420
|
-
|
|
484
|
+
return Array.from(topics).slice(0, 10); // Limit to top 10 topics
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
extractContentTopics(content) {
|
|
488
|
+
const topics = new Set();
|
|
489
|
+
|
|
490
|
+
// Extract from headers
|
|
491
|
+
const headers = content.match(/^#+\s+(.+)$/gm);
|
|
492
|
+
if (headers) {
|
|
493
|
+
headers.forEach(header => {
|
|
494
|
+
const topic = header.replace(/^#+\s+/, '').trim();
|
|
495
|
+
if (topic.length > 3 && topic.length < 50) {
|
|
496
|
+
topics.add(topic);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
421
500
|
|
|
422
|
-
|
|
501
|
+
// Extract common programming topics
|
|
502
|
+
const programmingPatterns = [
|
|
503
|
+
'Swift', 'SwiftUI', 'iOS', 'macOS', 'Architecture', 'Testing',
|
|
504
|
+
'Performance', 'Security', 'Privacy', 'Patterns', 'Components',
|
|
505
|
+
'API', 'Database', 'UI', 'UX', 'Analytics', 'Configuration'
|
|
506
|
+
];
|
|
507
|
+
|
|
508
|
+
programmingPatterns.forEach(pattern => {
|
|
509
|
+
if (content.toLowerCase().includes(pattern.toLowerCase())) {
|
|
510
|
+
topics.add(pattern);
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
return Array.from(topics);
|
|
423
515
|
}
|
|
424
516
|
|
|
425
517
|
async getMandatoryRules(task) {
|