@afterxleep/doc-bot 1.2.0 → 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.
Files changed (3) hide show
  1. package/README.md +17 -5
  2. package/package.json +1 -1
  3. package/src/index.js +65 -7
package/README.md CHANGED
@@ -111,13 +111,25 @@ Run tests with: `npm test`
111
111
 
112
112
  ## Rule Enforcement
113
113
 
114
- Doc-bot ensures your rules are **always considered** through MCP system prompt injection:
114
+ Doc-bot ensures your rules are **always considered** through multiple enforcement mechanisms:
115
115
 
116
- - **Global Rules**: Automatically injected into the agent's system prompt as critical requirements
117
- - **Contextual Rules**: Applied when working with matching files/patterns
118
- - **Automatic Compliance**: Agent must check rules before generating any code
116
+ ### 🚨 Mandatory Rule Checking
117
+ - **`check_project_rules` tool**: Must be called before ANY code generation
118
+ - **Aggressive descriptions**: All tools emphasize mandatory rule compliance
119
+ - **Rule reminders**: Every tool response includes compliance warnings
119
120
 
120
- The `docs://system-prompt` resource delivers your global rules directly to the agent's context, making rule violations impossible to ignore.
121
+ ### šŸ”„ Automatic Integration
122
+ - **System prompt injection**: Global rules injected into agent's system context via `docs://system-prompt`
123
+ - **Contextual rules**: Applied when working with matching files/patterns
124
+ - **Multiple touchpoints**: Rules enforced at every interaction level
125
+
126
+ ### āš ļø Compliance Warnings
127
+ All tool responses include explicit warnings that rules are:
128
+ - **NON-NEGOTIABLE**: Must be followed without exception
129
+ - **MANDATORY**: Violation will result in rejection
130
+ - **CRITICAL**: Require acknowledgment before proceeding
131
+
132
+ This multi-layered approach makes rule violations virtually impossible to ignore.
121
133
 
122
134
  ## The manifest file
123
135
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterxleep/doc-bot",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Generic MCP server for intelligent documentation access in any project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -133,6 +133,20 @@ class DocsServer {
133
133
  this.server.setRequestHandler(ListToolsRequestSchema, async () => {
134
134
  return {
135
135
  tools: [
136
+ {
137
+ name: 'check_project_rules',
138
+ description: 'āš ļø MANDATORY: Must be called before generating ANY code. Returns critical project rules and coding standards that MUST be followed.',
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ task: {
143
+ type: 'string',
144
+ description: 'Brief description of the coding task about to be performed'
145
+ }
146
+ },
147
+ required: ['task']
148
+ }
149
+ },
136
150
  {
137
151
  name: 'search_documentation',
138
152
  description: 'Search documentation by query',
@@ -149,7 +163,7 @@ class DocsServer {
149
163
  },
150
164
  {
151
165
  name: 'get_relevant_docs',
152
- description: 'Get context-aware documentation suggestions',
166
+ description: 'Get context-aware documentation suggestions including project rules that must be followed',
153
167
  inputSchema: {
154
168
  type: 'object',
155
169
  properties: {
@@ -168,7 +182,7 @@ class DocsServer {
168
182
  },
169
183
  {
170
184
  name: 'get_global_rules',
171
- description: 'Get always-apply documentation rules',
185
+ description: 'Get critical project rules that must ALWAYS be followed when writing code',
172
186
  inputSchema: {
173
187
  type: 'object',
174
188
  properties: {}
@@ -198,6 +212,16 @@ class DocsServer {
198
212
 
199
213
  try {
200
214
  switch (name) {
215
+ case 'check_project_rules':
216
+ const task = args?.task || 'code generation';
217
+ const mandatoryRules = await this.getMandatoryRules(task);
218
+ return {
219
+ content: [{
220
+ type: 'text',
221
+ text: mandatoryRules
222
+ }]
223
+ };
224
+
201
225
  case 'search_documentation':
202
226
  const query = args?.query;
203
227
  if (!query) {
@@ -300,6 +324,9 @@ class DocsServer {
300
324
  output += `\n${doc.content}\n\n---\n\n`;
301
325
  });
302
326
 
327
+ // Add rule reminder to all search results
328
+ output += '\nāš ļø REMINDER: Before implementing any code, use the check_project_rules tool to ensure compliance.\n';
329
+
303
330
  return output;
304
331
  }
305
332
 
@@ -334,22 +361,29 @@ class DocsServer {
334
361
  output += `**Confidence:** ${relevant.confidence.toFixed(2)}\n\n`;
335
362
  }
336
363
 
364
+ // Add rule reminder for contextual docs
365
+ output += '\nāš ļø CRITICAL: These rules are MANDATORY and must be followed before generating code.\n';
366
+
337
367
  return output;
338
368
  }
339
369
 
340
370
  formatGlobalRules(globalRules) {
341
371
  if (!globalRules || globalRules.length === 0) {
342
- return 'No global rules defined.';
372
+ return 'āŒ WARNING: No global rules defined. Consider adding project rules for code consistency.';
343
373
  }
344
374
 
345
- let output = '# Global Rules (Always Apply)\n\n';
346
- output += 'These rules should be applied to all interactions:\n\n';
375
+ let output = '🚨 MANDATORY Global Rules (ALWAYS Apply) 🚨\n\n';
376
+ output += 'āš ļø CRITICAL: These rules are NON-NEGOTIABLE and must be followed in ALL code generation:\n\n';
347
377
 
348
- globalRules.forEach(rule => {
349
- output += `## ${rule.metadata?.title || rule.fileName}\n`;
378
+ globalRules.forEach((rule, index) => {
379
+ output += `## ${index + 1}. ${rule.metadata?.title || rule.fileName}\n`;
350
380
  output += `${rule.content}\n\n`;
381
+ output += '---\n\n';
351
382
  });
352
383
 
384
+ output += 'āœ… ACKNOWLEDGMENT REQUIRED: You must confirm compliance with these rules before proceeding.\n';
385
+ output += 'āŒ VIOLATION: Any code that violates these rules will be rejected.\n';
386
+
353
387
  return output;
354
388
  }
355
389
 
@@ -387,6 +421,30 @@ class DocsServer {
387
421
 
388
422
  return prompt;
389
423
  }
424
+
425
+ async getMandatoryRules(task) {
426
+ const globalRules = await this.docService.getGlobalRules();
427
+
428
+ if (!globalRules || globalRules.length === 0) {
429
+ return 'āŒ WARNING: No project rules defined. Proceeding without guidelines.';
430
+ }
431
+
432
+ let output = '🚨 MANDATORY PROJECT RULES - MUST FOLLOW BEFORE CODING 🚨\n\n';
433
+ output += `Task: ${task}\n\n`;
434
+ output += 'āš ļø CRITICAL: These rules are NON-NEGOTIABLE and must be followed:\n\n';
435
+
436
+ globalRules.forEach((rule, index) => {
437
+ output += `## ${index + 1}. ${rule.metadata?.title || rule.fileName}\n`;
438
+ output += `${rule.content}\n\n`;
439
+ output += '---\n\n';
440
+ });
441
+
442
+ output += 'āœ… CONFIRMATION REQUIRED: You MUST acknowledge these rules before generating code.\n';
443
+ output += 'āŒ VIOLATION: Any code that violates these rules will be rejected.\n\n';
444
+ output += 'šŸ”„ Next step: Generate code that strictly follows ALL the above rules.\n';
445
+
446
+ return output;
447
+ }
390
448
 
391
449
  async start() {
392
450
  // Initialize services