@afterxleep/doc-bot 1.7.10 → 1.7.11

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.
@@ -53,6 +53,15 @@ Blocking: FALSE
53
53
  Timeout: 15s
54
54
  ```
55
55
 
56
+ **CLASS E: DOCUMENTATION_CREATION**
57
+ ```
58
+ Trigger Pattern: /\b(document|create rule|add rule|save knowledge|capture pattern|remember|note this|new rule)\b/i
59
+ Context Pattern: /\b(we should document|this should be a rule|add to documentation|create guideline)\b/i
60
+ Required Action: MANDATORY_CALL(create_or_update_rule, extract_rule_params())
61
+ Blocking: FALSE
62
+ Timeout: 30s
63
+ ```
64
+
56
65
  **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
66
 
58
67
  ## PHASE 3: EXECUTION ENFORCEMENT
@@ -126,6 +135,7 @@ IF response_generated() WITHOUT tool_execution():
126
135
  - "How do I implement auth?" → search_documentation("authentication")
127
136
  - "Create a new component" → check_project_rules("create component")
128
137
  - "Working on src/utils.js" → search_documentation("src/utils.js utils")
138
+ - "We should document this pattern" → create_or_update_rule({fileName: "pattern-name.md", title: "Pattern Name", content: "...", alwaysApply: false})
129
139
 
130
140
  **Expected Behavior**: Tool execution within 2 seconds, no general knowledge responses.
131
141
 
package/README.md CHANGED
@@ -134,6 +134,7 @@ Traditional AI assistants use static rule files (like Cursor Rules or Copilot's
134
134
  4. **Ensure Agent Compliance** (Essential): Add the expert-engineered integration protocol to guarantee your agent uses doc-bot:
135
135
 
136
136
  **⚡ Setup**: Copy the rule from [`AGENT_INTEGRATION_RULE.txt`](./AGENT_INTEGRATION_RULE.txt) into your agent configuration.
137
+ **🎯 Why This Matters**: Without this rule, agents may default to general knowledge instead of your doc-bot documentation.
137
138
 
138
139
  **Platform-Specific Instructions**:
139
140
  - **Claude Code**: Add rule to your global `CLAUDE.md`
@@ -141,7 +142,7 @@ Traditional AI assistants use static rule files (like Cursor Rules or Copilot's
141
142
  - **GitHub Copilot**: Add rule to `.github/copilot-instructions.md`
142
143
  - **Continue.dev**: Add rule to system prompt configuration
143
144
 
144
- **🎯 Why This Matters**: Without this rule, agents may default to general knowledge instead of your doc-bot documentation.
145
+
145
146
 
146
147
  ## How to organize your documentation
147
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterxleep/doc-bot",
3
- "version": "1.7.10",
3
+ "version": "1.7.11",
4
4
  "description": "Generic MCP server for intelligent documentation access in any project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -14,6 +14,8 @@
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
16
  | `read_specific_document` | Document access | Full content needs | Execute after search results |
17
+ | `create_or_update_rule` | Rule creation/learning | New knowledge capture | Execute to document patterns/rules |
18
+ | `refresh_documentation` | Manual refresh | File detection issues | Execute after manual file additions |
17
19
 
18
20
  ## KEYWORD MAPPING:
19
21
 
@@ -35,6 +37,16 @@
35
37
  **Keywords**: working on, this file, specific file, directory, component path
36
38
  **Action**: Execute `search_documentation` with file name and context keywords
37
39
 
40
+ ### Documentation Creation Triggers:
41
+ **Keywords**: document, create rule, add rule, save knowledge, capture pattern, remember, note this, new rule
42
+ **Context Indicators**: "we should document", "this should be a rule", "add to documentation", "create guideline"
43
+ **Action**: Execute `create_or_update_rule` to capture new knowledge
44
+
45
+ ### Documentation Refresh Triggers:
46
+ **Keywords**: refresh, reload, update index, detect files, manual files, can't find, document not found
47
+ **Context Indicators**: "added files manually", "files not showing up", "refresh documentation", "reload docs"
48
+ **Action**: Execute `refresh_documentation` to reindex files
49
+
38
50
  ## EXECUTION ALGORITHM:
39
51
 
40
52
  1. **Input Analysis**: Extract keywords and context from user query
@@ -73,6 +85,16 @@ Input: "I'm working on src/components/Header.js"
73
85
  Analysis: Contains "working on" + file path (file context trigger)
74
86
  Action: search_documentation("src/components/Header.js component")
75
87
  Reason: File-specific context search requirement
88
+
89
+ Input: "We should document this pattern - always use TypeScript interfaces for API responses"
90
+ Analysis: Contains "should document" + "pattern" (documentation creation trigger)
91
+ Action: create_or_update_rule({fileName: "api-patterns.md", title: "API Response Patterns", content: "Always use TypeScript interfaces for API responses", alwaysApply: true})
92
+ Reason: New knowledge capture requirement
93
+
94
+ Input: "I added files manually but they're not showing up in search"
95
+ Analysis: Contains "added files manually" + "not showing up" (refresh trigger)
96
+ Action: refresh_documentation()
97
+ Reason: Manual file detection issue
76
98
  ```
77
99
 
78
100
  ## COMPLIANCE PROTOCOL:
package/src/index.js CHANGED
@@ -223,6 +223,50 @@ class DocsServer {
223
223
  },
224
224
  required: ['fileName']
225
225
  }
226
+ },
227
+ {
228
+ name: 'create_or_update_rule',
229
+ description: 'Create a new documentation rule or update an existing one. Use this to add new project knowledge or update existing documentation based on learnings.',
230
+ inputSchema: {
231
+ type: 'object',
232
+ properties: {
233
+ fileName: {
234
+ type: 'string',
235
+ description: 'File name for the rule (e.g., "react-patterns.md"). If file exists, it will be updated.'
236
+ },
237
+ title: {
238
+ type: 'string',
239
+ description: 'Title of the documentation rule'
240
+ },
241
+ description: {
242
+ type: 'string',
243
+ description: 'Brief description of what this rule covers'
244
+ },
245
+ keywords: {
246
+ type: 'array',
247
+ items: { type: 'string' },
248
+ description: 'Keywords for search indexing (e.g., ["react", "patterns", "components"])'
249
+ },
250
+ alwaysApply: {
251
+ type: 'boolean',
252
+ description: 'Whether this rule should always apply (true for global rules, false for contextual)'
253
+ },
254
+ content: {
255
+ type: 'string',
256
+ description: 'The markdown content of the rule'
257
+ }
258
+ },
259
+ required: ['fileName', 'title', 'content', 'alwaysApply']
260
+ }
261
+ },
262
+ {
263
+ name: 'refresh_documentation',
264
+ description: 'Manually refresh the documentation index to detect new or changed files. Use this after manually adding files to the docs folder.',
265
+ inputSchema: {
266
+ type: 'object',
267
+ properties: {},
268
+ additionalProperties: false
269
+ }
226
270
  }
227
271
  ]
228
272
  };
@@ -294,6 +338,40 @@ class DocsServer {
294
338
  text: await this.formatSingleDocument(doc)
295
339
  }]
296
340
  };
341
+
342
+ case 'create_or_update_rule':
343
+ const { fileName: ruleFileName, title, description, keywords, alwaysApply, content } = args || {};
344
+
345
+ if (!ruleFileName || !title || !content || alwaysApply === undefined) {
346
+ throw new Error('fileName, title, content, and alwaysApply parameters are required');
347
+ }
348
+
349
+ const result = await this.createOrUpdateRule({
350
+ fileName: ruleFileName,
351
+ title,
352
+ description,
353
+ keywords,
354
+ alwaysApply,
355
+ content
356
+ });
357
+
358
+ return {
359
+ content: [{
360
+ type: 'text',
361
+ text: result
362
+ }]
363
+ };
364
+
365
+ case 'refresh_documentation':
366
+ await this.docService.reload();
367
+ const docCount = this.docService.documents.size;
368
+
369
+ return {
370
+ content: [{
371
+ type: 'text',
372
+ text: `✅ Documentation refreshed successfully!\n\n**Files indexed:** ${docCount}\n**Last updated:** ${new Date().toLocaleString()}\n\n💡 All manually added files should now be available for search and reading.`
373
+ }]
374
+ };
297
375
 
298
376
  default:
299
377
  throw new Error(`Unknown tool: ${name}`);
@@ -476,6 +554,55 @@ class DocsServer {
476
554
  return output;
477
555
  }
478
556
 
557
+ async createOrUpdateRule({ fileName, title, description, keywords, alwaysApply, content }) {
558
+ const fs = require('fs-extra');
559
+ const path = require('path');
560
+
561
+ try {
562
+ // Ensure the docs directory exists
563
+ await fs.ensureDir(this.options.docsPath);
564
+
565
+ // Create the full file path
566
+ const filePath = path.join(this.options.docsPath, fileName);
567
+
568
+ // Build frontmatter
569
+ let frontmatter = '---\n';
570
+ frontmatter += `alwaysApply: ${alwaysApply}\n`;
571
+ frontmatter += `title: "${title}"\n`;
572
+ if (description) {
573
+ frontmatter += `description: "${description}"\n`;
574
+ }
575
+ if (keywords && keywords.length > 0) {
576
+ frontmatter += `keywords: [${keywords.map(k => `"${k}"`).join(', ')}]\n`;
577
+ }
578
+ frontmatter += '---\n\n';
579
+
580
+ // Combine frontmatter and content
581
+ const fullContent = frontmatter + content;
582
+
583
+ // Check if file exists to determine if this is create or update
584
+ const fileExists = await fs.pathExists(filePath);
585
+ const action = fileExists ? 'updated' : 'created';
586
+
587
+ // Write the file
588
+ await fs.writeFile(filePath, fullContent, 'utf8');
589
+
590
+ // Reload the documentation service to pick up the new/updated file
591
+ await this.docService.reload();
592
+
593
+ return `✅ Documentation rule ${action} successfully: ${fileName}\n\n` +
594
+ `**Title**: ${title}\n` +
595
+ `**Type**: ${alwaysApply ? 'Global Rule (always applies)' : 'Contextual Rule (applies when relevant)'}\n` +
596
+ `**File**: ${fileName}\n` +
597
+ (description ? `**Description**: ${description}\n` : '') +
598
+ (keywords && keywords.length > 0 ? `**Keywords**: ${keywords.join(', ')}\n` : '') +
599
+ `\n**Content**:\n${content}`;
600
+
601
+ } catch (error) {
602
+ throw new Error(`Failed to ${fileName.includes('/') ? 'create' : 'update'} rule: ${error.message}`);
603
+ }
604
+ }
605
+
479
606
  async generateSystemPrompt() {
480
607
  const globalRules = await this.docService.getGlobalRules();
481
608
  const allDocs = await this.docService.getAllDocuments();