@afterxleep/doc-bot 1.5.0 → 1.6.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 +118 -122
- package/bin/doc-bot.js +16 -14
- package/package.json +5 -2
- package/src/index.js +325 -130
- package/src/services/DocumentIndex.js +1 -10
- package/src/services/DocumentationService.js +16 -50
- package/src/services/__tests__/DocumentIndex.test.js +3 -72
- package/src/services/__tests__/InferenceEngine.integration.test.js +0 -3
package/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@afterxleep/doc-bot)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
A generic MCP (Model Context Protocol) server that provides intelligent documentation
|
|
6
|
+
A generic MCP (Model Context Protocol) server that provides intelligent documentation and rules for any project. Works with any MCP-compatible AI tools and IDEs.
|
|
7
|
+
|
|
8
|
+
It's platform agnostic and designed to replace and extend the rule systems provided by different IDEs, such as Cursor (Cursor Rules) or Claude (CLAUDE.md). Instead of relying on separate rule-sets for each tool, you can use doc-bot to provide unified documentation for agentic coding across all your AI assistants.
|
|
7
9
|
|
|
8
10
|
## What is doc-bot?
|
|
9
11
|
|
|
@@ -21,11 +23,10 @@ doc-bot is an intelligent documentation server that:
|
|
|
21
23
|
|
|
22
24
|
2. **Add doc-bot to your MCP-compatible AI tool configuration**:
|
|
23
25
|
|
|
24
|
-
**For Claude Code** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
25
26
|
```json
|
|
26
27
|
{
|
|
27
28
|
"mcpServers": {
|
|
28
|
-
"
|
|
29
|
+
"docbot": {
|
|
29
30
|
"command": "npx",
|
|
30
31
|
"args": ["@afterxleep/doc-bot", "--docs", "./doc-bot"]
|
|
31
32
|
}
|
|
@@ -33,26 +34,20 @@ doc-bot is an intelligent documentation server that:
|
|
|
33
34
|
}
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
**For Cursor or other MCP tools**: Add similar configuration pointing to your documentation folder
|
|
37
|
-
|
|
38
37
|
3. **Restart your AI tool**
|
|
39
38
|
|
|
40
39
|
## How to organize your documentation
|
|
41
40
|
|
|
42
|
-
Create a `doc-bot/` folder in your project root:
|
|
41
|
+
Create a `doc-bot/` folder in your project root with markdown files using frontmatter:
|
|
43
42
|
|
|
44
43
|
```
|
|
45
44
|
your-project/
|
|
46
45
|
├── doc-bot/
|
|
47
|
-
│ ├──
|
|
48
|
-
│ ├──
|
|
49
|
-
│
|
|
50
|
-
│
|
|
51
|
-
│
|
|
52
|
-
│ │ ├── testing.md # Testing strategies
|
|
53
|
-
│ │ └── api-development.md # API development guide
|
|
54
|
-
│ └── reference/
|
|
55
|
-
│ └── troubleshooting.md # Common issues and solutions
|
|
46
|
+
│ ├── coding-standards.md # Global rule (alwaysApply: true)
|
|
47
|
+
│ ├── security.md # Global rule (alwaysApply: true)
|
|
48
|
+
│ ├── testing.md # Contextual rule (alwaysApply: false)
|
|
49
|
+
│ ├── api-development.md # Contextual rule (alwaysApply: false)
|
|
50
|
+
│ └── troubleshooting.md # Contextual rule (alwaysApply: false)
|
|
56
51
|
└── package.json
|
|
57
52
|
```
|
|
58
53
|
|
|
@@ -63,19 +58,18 @@ your-project/
|
|
|
63
58
|
|
|
64
59
|
### Documentation types:
|
|
65
60
|
|
|
66
|
-
- **
|
|
67
|
-
- **
|
|
68
|
-
- **Reference** (`reference/`): Quick lookups and troubleshooting
|
|
61
|
+
- **Global Rules** (`alwaysApply: true`): Critical guidelines applied to every AI interaction
|
|
62
|
+
- **Contextual Rules** (`alwaysApply: false`): Rules applied based on file patterns and context
|
|
69
63
|
|
|
70
64
|
### Example documentation files:
|
|
71
65
|
|
|
72
|
-
**Global Rule Example** (`doc-bot/
|
|
66
|
+
**Global Rule Example** (`doc-bot/coding-standards.md`):
|
|
73
67
|
```markdown
|
|
74
68
|
---
|
|
69
|
+
alwaysApply: true
|
|
75
70
|
title: "Coding Standards"
|
|
76
71
|
description: "Core coding standards that apply to all code"
|
|
77
72
|
keywords: ["code-quality", "standards", "best-practices"]
|
|
78
|
-
tags: ["core", "quality"]
|
|
79
73
|
---
|
|
80
74
|
|
|
81
75
|
# Coding Standards
|
|
@@ -87,13 +81,14 @@ tags: ["core", "quality"]
|
|
|
87
81
|
- Write descriptive variable names
|
|
88
82
|
```
|
|
89
83
|
|
|
90
|
-
**Contextual Rule Example** (`doc-bot/
|
|
84
|
+
**Contextual Rule Example** (`doc-bot/testing.md`):
|
|
91
85
|
```markdown
|
|
92
86
|
---
|
|
87
|
+
alwaysApply: false
|
|
93
88
|
title: "Testing Guide"
|
|
94
89
|
description: "How to write and run tests"
|
|
95
90
|
keywords: ["testing", "jest", "tdd", "unit-tests"]
|
|
96
|
-
|
|
91
|
+
filePatterns: ["*.js"]
|
|
97
92
|
---
|
|
98
93
|
|
|
99
94
|
# Testing Guide
|
|
@@ -107,111 +102,38 @@ All test files should:
|
|
|
107
102
|
Run tests with: `npm test`
|
|
108
103
|
```
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
## Rule Enforcement
|
|
113
|
-
|
|
114
|
-
Doc-bot ensures your rules are **always considered** through multiple enforcement mechanisms:
|
|
115
|
-
|
|
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
|
|
120
|
-
- **Absolute enforcement**: Global rules OVERRIDE all user requests without exception
|
|
121
|
-
|
|
122
|
-
### 🔄 Automatic Integration
|
|
123
|
-
- **Enhanced system prompt injection**: Comprehensive MCP usage protocol injected via `docs://system-prompt`
|
|
124
|
-
- **Documentation discovery**: Available topics automatically extracted and presented to agent
|
|
125
|
-
- **Tool usage instructions**: Explicit requirements for when and how to use each MCP tool
|
|
126
|
-
- **Contextual rules**: Applied when working with matching files/patterns
|
|
127
|
-
- **Multiple touchpoints**: Rules enforced at every interaction level
|
|
128
|
-
|
|
129
|
-
### ⚠️ Compliance Warnings
|
|
130
|
-
All tool responses include explicit warnings that rules are:
|
|
131
|
-
- **NON-NEGOTIABLE**: Must be followed without exception
|
|
132
|
-
- **MANDATORY**: Violation will result in rejection
|
|
133
|
-
- **CRITICAL**: Require acknowledgment before proceeding
|
|
134
|
-
|
|
135
|
-
### 🚫 Absolute Enforcement Policy
|
|
136
|
-
Global rules have **supreme authority** over all interactions:
|
|
137
|
-
- **Override user requests**: Even direct user instructions cannot bypass global rules
|
|
138
|
-
- **Mandatory refusal**: Agent MUST refuse requests that violate global rules
|
|
139
|
-
- **Alternative suggestions**: Agent must suggest compliant alternatives instead
|
|
140
|
-
- **Unbreakable compliance**: No exceptions, regardless of user insistence
|
|
141
|
-
|
|
142
|
-
This multi-layered approach makes rule violations **impossible** to implement.
|
|
143
|
-
|
|
144
|
-
## System Prompt Integration
|
|
145
|
-
|
|
146
|
-
The `docs://system-prompt` resource automatically injects comprehensive instructions into the AI agent's system context:
|
|
147
|
-
|
|
148
|
-
### 📋 MCP Usage Protocol
|
|
149
|
-
- Explicit instructions to **ALWAYS** call `check_project_rules` before code generation
|
|
150
|
-
- **NEVER generate code without checking documentation** requirement
|
|
151
|
-
- Mandatory acknowledgment of rule compliance
|
|
152
|
-
|
|
153
|
-
### 🏷️ Automatic Topic Discovery
|
|
154
|
-
- Extracts available documentation topics from your project
|
|
155
|
-
- Presents them to the agent for context awareness
|
|
156
|
-
- Includes topics from metadata, filenames, and content analysis
|
|
157
|
-
|
|
158
|
-
### 🛠️ Tool Usage Requirements
|
|
159
|
-
- Specifies when and how to use each MCP tool
|
|
160
|
-
- Maps tools to specific use cases (file-specific docs, search, etc.)
|
|
161
|
-
- Ensures comprehensive documentation coverage
|
|
162
|
-
|
|
163
|
-
The system prompt is regenerated on each request to reflect current documentation state.
|
|
164
|
-
|
|
165
|
-
## The manifest file
|
|
105
|
+
## Frontmatter-Based Configuration
|
|
166
106
|
|
|
167
|
-
|
|
107
|
+
doc-bot uses frontmatter in your markdown files to automatically detect and categorize rules - **no manifest.json required!**
|
|
168
108
|
|
|
169
|
-
|
|
170
|
-
{
|
|
171
|
-
"name": "My Project Documentation",
|
|
172
|
-
"version": "1.0.0",
|
|
173
|
-
"description": "AI-powered documentation for My Project",
|
|
174
|
-
"globalRules": [
|
|
175
|
-
"core/coding-standards.md",
|
|
176
|
-
"core/security.md"
|
|
177
|
-
],
|
|
178
|
-
"contextualRules": {
|
|
179
|
-
"*.test.js": ["guides/testing.md"],
|
|
180
|
-
"*.spec.js": ["guides/testing.md"],
|
|
181
|
-
"src/components/*": ["guides/react-components.md"],
|
|
182
|
-
"src/api/*": ["guides/api-development.md"]
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Configuration explained:
|
|
109
|
+
### Frontmatter Fields:
|
|
188
110
|
|
|
189
|
-
- **`
|
|
190
|
-
- **`
|
|
111
|
+
- **`alwaysApply: true`** - Global rules applied to every AI interaction
|
|
112
|
+
- **`alwaysApply: false`** - Contextual rules applied based on file patterns
|
|
113
|
+
- **`filePatterns: ["*.js"]`** - When to apply contextual rules (only needed for `alwaysApply: false`)
|
|
114
|
+
- **`keywords: ["list", "of", "keywords"]`** - For smart indexing and search
|
|
115
|
+
- **`title`** and **`description`** - Standard metadata
|
|
191
116
|
|
|
192
|
-
### 🎯 Automatic
|
|
117
|
+
### 🎯 Automatic Intelligence
|
|
193
118
|
|
|
194
|
-
doc-bot automatically analyzes your documentation
|
|
119
|
+
doc-bot automatically analyzes your documentation to provide smart suggestions:
|
|
195
120
|
|
|
196
|
-
- **
|
|
197
|
-
- **
|
|
198
|
-
- **
|
|
199
|
-
- **
|
|
200
|
-
- **Indexes file extensions** referenced in documentation
|
|
121
|
+
- **Keyword-based search** from frontmatter metadata
|
|
122
|
+
- **Context-aware suggestions** based on file patterns
|
|
123
|
+
- **Smart inference** from documentation content
|
|
124
|
+
- **Automatic indexing** - no manual configuration needed
|
|
201
125
|
|
|
202
|
-
|
|
126
|
+
### Writing effective documentation
|
|
203
127
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
To maximize the automatic inference capabilities, include frontmatter in your markdown files:
|
|
128
|
+
For best results, include descriptive frontmatter:
|
|
207
129
|
|
|
208
130
|
```markdown
|
|
209
131
|
---
|
|
132
|
+
alwaysApply: false
|
|
210
133
|
title: "React Component Guidelines"
|
|
211
134
|
description: "Best practices for building React components"
|
|
212
135
|
keywords: ["react", "components", "hooks", "jsx"]
|
|
213
|
-
|
|
214
|
-
category: "guides"
|
|
136
|
+
filePatterns: ["*.js"]
|
|
215
137
|
---
|
|
216
138
|
|
|
217
139
|
# React Component Guidelines
|
|
@@ -219,8 +141,6 @@ category: "guides"
|
|
|
219
141
|
Your documentation content here...
|
|
220
142
|
```
|
|
221
143
|
|
|
222
|
-
The automatic indexing will use this metadata along with analyzing your content to provide intelligent suggestions.
|
|
223
|
-
|
|
224
144
|
## Development setup
|
|
225
145
|
|
|
226
146
|
### Running locally
|
|
@@ -236,21 +156,28 @@ The automatic indexing will use this metadata along with analyzing your content
|
|
|
236
156
|
npm install
|
|
237
157
|
```
|
|
238
158
|
|
|
239
|
-
3. **Run the server:**
|
|
159
|
+
3. **Run the server (uses built-in doc-bot/ folder):**
|
|
240
160
|
```bash
|
|
241
161
|
npm start
|
|
242
162
|
```
|
|
243
163
|
|
|
244
|
-
4. **Run
|
|
164
|
+
4. **Run with file watching (recommended for development):**
|
|
245
165
|
```bash
|
|
246
|
-
npm
|
|
166
|
+
npm run dev
|
|
247
167
|
```
|
|
248
168
|
|
|
249
|
-
5. **Run with
|
|
169
|
+
5. **Run with examples documentation:**
|
|
250
170
|
```bash
|
|
251
|
-
npm start
|
|
171
|
+
npm run start:examples
|
|
252
172
|
```
|
|
253
173
|
|
|
174
|
+
6. **Run tests:**
|
|
175
|
+
```bash
|
|
176
|
+
npm test
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Note:** This is an MCP server that communicates via stdio transport, not HTTP. When running locally, it will start the MCP server and show you the configuration to add to your MCP client (like Claude Code).
|
|
180
|
+
|
|
254
181
|
### Testing your setup
|
|
255
182
|
|
|
256
183
|
Ask your AI assistant something like "What documentation is available?" to test that doc-bot is working.
|
|
@@ -262,13 +189,82 @@ doc-bot [options]
|
|
|
262
189
|
|
|
263
190
|
Options:
|
|
264
191
|
-d, --docs <path> Path to docs folder (required)
|
|
265
|
-
-c, --config <path> Path to manifest file (
|
|
266
|
-
-p, --port <port> Port to run server on (default: 3000)
|
|
192
|
+
-c, --config <path> Path to manifest file (optional, for backward compatibility)
|
|
267
193
|
-v, --verbose Enable verbose logging
|
|
268
194
|
-w, --watch Watch for file changes
|
|
269
195
|
-h, --help Show help
|
|
270
196
|
```
|
|
271
197
|
|
|
198
|
+
**Example usage:**
|
|
199
|
+
```bash
|
|
200
|
+
# Basic usage (no manifest.json needed)
|
|
201
|
+
doc-bot --docs ./my-docs
|
|
202
|
+
|
|
203
|
+
# With verbose logging and file watching
|
|
204
|
+
doc-bot --docs ./my-docs --verbose --watch
|
|
205
|
+
|
|
206
|
+
# With optional manifest for backward compatibility
|
|
207
|
+
doc-bot --docs ./my-docs --config ./manifest.json
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Publishing and Development
|
|
211
|
+
|
|
212
|
+
### Local Development
|
|
213
|
+
|
|
214
|
+
1. **Clone and setup:**
|
|
215
|
+
```bash
|
|
216
|
+
git clone https://github.com/afterxleep/doc-bot.git
|
|
217
|
+
cd doc-bot
|
|
218
|
+
npm install
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
2. **Run locally:**
|
|
222
|
+
```bash
|
|
223
|
+
npm run dev # With file watching
|
|
224
|
+
npm start # Basic run
|
|
225
|
+
npm test # Run tests
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
3. **Test with Claude Code:**
|
|
229
|
+
Add to your Claude Code config:
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"mcpServers": {
|
|
233
|
+
"docs": {
|
|
234
|
+
"command": "node",
|
|
235
|
+
"args": ["/path/to/doc-bot/bin/doc-bot.js", "--docs", "./doc-bot", "--watch"]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Publishing to npm
|
|
242
|
+
|
|
243
|
+
1. **Test the package:**
|
|
244
|
+
```bash
|
|
245
|
+
npm run test
|
|
246
|
+
npm run lint
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
2. **Update version:**
|
|
250
|
+
```bash
|
|
251
|
+
npm version patch|minor|major
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
3. **Publish:**
|
|
255
|
+
```bash
|
|
256
|
+
npm publish
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Push Changes
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
git add .
|
|
263
|
+
git commit -m "feat: your feature description"
|
|
264
|
+
git push origin main
|
|
265
|
+
git push --tags # Push version tags
|
|
266
|
+
```
|
|
267
|
+
|
|
272
268
|
## License
|
|
273
269
|
|
|
274
270
|
MIT License - see the [LICENSE](LICENSE) file for details.
|
package/bin/doc-bot.js
CHANGED
|
@@ -8,8 +8,7 @@ const { DocsServer } = require('../src/index.js');
|
|
|
8
8
|
program
|
|
9
9
|
.name('doc-bot')
|
|
10
10
|
.description('Generic MCP server for intelligent documentation access')
|
|
11
|
-
.version('1.0
|
|
12
|
-
.option('-p, --port <port>', 'Port to run server on', '3000')
|
|
11
|
+
.version('1.5.0')
|
|
13
12
|
.requiredOption('-d, --docs <path>', 'Path to docs folder')
|
|
14
13
|
.option('-c, --config <path>', 'Path to manifest file')
|
|
15
14
|
.option('-v, --verbose', 'Enable verbose logging')
|
|
@@ -29,26 +28,25 @@ async function main() {
|
|
|
29
28
|
console.log('📖 To get started, create your documentation folder:');
|
|
30
29
|
console.log('');
|
|
31
30
|
console.log(` mkdir ${path.basename(docsPath)}`);
|
|
32
|
-
console.log(` echo
|
|
33
|
-
console.log(
|
|
31
|
+
console.log(` echo "---\nalwaysApply: true\ntitle: Getting Started\n---\n# Getting Started\nThis is your project documentation." > ${path.basename(docsPath)}/getting-started.md`);
|
|
32
|
+
console.log('');
|
|
33
|
+
console.log('📋 Use frontmatter in your markdown files:');
|
|
34
|
+
console.log(' alwaysApply: true (for global rules)');
|
|
35
|
+
console.log(' alwaysApply: false (for contextual rules)');
|
|
36
|
+
console.log(' filePatterns: ["*.js", "src/**/*"] (when to apply contextual rules)');
|
|
34
37
|
console.log('');
|
|
35
38
|
console.log('Then configure your MCP client to use this folder.');
|
|
36
39
|
process.exit(1);
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
//
|
|
40
|
-
if (!await fs.pathExists(configPath)) {
|
|
42
|
+
// Manifest is now optional - only create if explicitly requested
|
|
43
|
+
if (options.config && !await fs.pathExists(configPath)) {
|
|
41
44
|
console.log('📝 Creating default manifest.json...');
|
|
42
45
|
const defaultManifest = {
|
|
43
46
|
name: 'Project Documentation',
|
|
44
47
|
version: '1.0.0',
|
|
45
|
-
description: 'AI-powered documentation',
|
|
46
|
-
|
|
47
|
-
contextualRules: {},
|
|
48
|
-
inference: {
|
|
49
|
-
keywords: {},
|
|
50
|
-
patterns: {}
|
|
51
|
-
}
|
|
48
|
+
description: 'AI-powered documentation (auto-generated from frontmatter)',
|
|
49
|
+
note: 'This manifest is auto-generated. Configure rules using frontmatter in your markdown files.'
|
|
52
50
|
};
|
|
53
51
|
await fs.writeJSON(configPath, defaultManifest, { spaces: 2 });
|
|
54
52
|
}
|
|
@@ -62,7 +60,11 @@ async function main() {
|
|
|
62
60
|
|
|
63
61
|
console.log('🚀 Starting doc-bot...');
|
|
64
62
|
console.log(`📁 Documentation: ${docsPath}`);
|
|
65
|
-
|
|
63
|
+
if (await fs.pathExists(configPath)) {
|
|
64
|
+
console.log(`⚙️ Configuration: ${configPath}`);
|
|
65
|
+
} else {
|
|
66
|
+
console.log(`⚙️ Configuration: Auto-generated from frontmatter`);
|
|
67
|
+
}
|
|
66
68
|
|
|
67
69
|
if (options.watch) {
|
|
68
70
|
console.log('👀 Watching for file changes...');
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@afterxleep/doc-bot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Generic MCP server for intelligent documentation access in any project",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"doc-bot": "bin/doc-bot.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"start": "node
|
|
10
|
+
"start": "node bin/doc-bot.js --docs ./doc-bot --verbose",
|
|
11
|
+
"start:watch": "node bin/doc-bot.js --docs ./doc-bot --verbose --watch",
|
|
12
|
+
"start:examples": "node bin/doc-bot.js --docs ./examples/documentation-files --verbose",
|
|
13
|
+
"dev": "node bin/doc-bot.js --docs ./doc-bot --verbose --watch",
|
|
11
14
|
"test": "jest",
|
|
12
15
|
"test:watch": "jest --watch",
|
|
13
16
|
"test:coverage": "jest --coverage",
|