@afterxleep/doc-bot 1.4.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 -114
- package/bin/doc-bot.js +16 -14
- package/package.json +5 -2
- package/src/index.js +325 -112
- 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,103 +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
|
-
|
|
121
|
-
### 🔄 Automatic Integration
|
|
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
|
|
125
|
-
- **Contextual rules**: Applied when working with matching files/patterns
|
|
126
|
-
- **Multiple touchpoints**: Rules enforced at every interaction level
|
|
127
|
-
|
|
128
|
-
### ⚠️ Compliance Warnings
|
|
129
|
-
All tool responses include explicit warnings that rules are:
|
|
130
|
-
- **NON-NEGOTIABLE**: Must be followed without exception
|
|
131
|
-
- **MANDATORY**: Violation will result in rejection
|
|
132
|
-
- **CRITICAL**: Require acknowledgment before proceeding
|
|
133
|
-
|
|
134
|
-
This multi-layered approach makes rule violations virtually impossible to ignore.
|
|
105
|
+
## Frontmatter-Based Configuration
|
|
135
106
|
|
|
136
|
-
|
|
107
|
+
doc-bot uses frontmatter in your markdown files to automatically detect and categorize rules - **no manifest.json required!**
|
|
137
108
|
|
|
138
|
-
|
|
109
|
+
### Frontmatter Fields:
|
|
139
110
|
|
|
140
|
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
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
|
-
|
|
157
|
-
## The manifest file
|
|
158
|
-
|
|
159
|
-
The `doc-bot/manifest.json` file controls how your documentation works:
|
|
160
|
-
|
|
161
|
-
```json
|
|
162
|
-
{
|
|
163
|
-
"name": "My Project Documentation",
|
|
164
|
-
"version": "1.0.0",
|
|
165
|
-
"description": "AI-powered documentation for My Project",
|
|
166
|
-
"globalRules": [
|
|
167
|
-
"core/coding-standards.md",
|
|
168
|
-
"core/security.md"
|
|
169
|
-
],
|
|
170
|
-
"contextualRules": {
|
|
171
|
-
"*.test.js": ["guides/testing.md"],
|
|
172
|
-
"*.spec.js": ["guides/testing.md"],
|
|
173
|
-
"src/components/*": ["guides/react-components.md"],
|
|
174
|
-
"src/api/*": ["guides/api-development.md"]
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
```
|
|
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
|
|
178
116
|
|
|
179
|
-
###
|
|
117
|
+
### 🎯 Automatic Intelligence
|
|
180
118
|
|
|
181
|
-
-
|
|
182
|
-
- **`contextualRules`**: Documents triggered by specific file patterns (e.g., test files → testing guide)
|
|
119
|
+
doc-bot automatically analyzes your documentation to provide smart suggestions:
|
|
183
120
|
|
|
184
|
-
|
|
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
|
|
185
125
|
|
|
186
|
-
|
|
126
|
+
### Writing effective documentation
|
|
187
127
|
|
|
188
|
-
|
|
189
|
-
- **Detects technical terms** in your documentation content
|
|
190
|
-
- **Recognizes code patterns** in code blocks (React hooks, SQL commands, etc.)
|
|
191
|
-
- **Identifies frameworks** mentioned in your docs
|
|
192
|
-
- **Indexes file extensions** referenced in documentation
|
|
193
|
-
|
|
194
|
-
Just write good documentation with descriptive frontmatter, and doc-bot handles the rest!
|
|
195
|
-
|
|
196
|
-
### Writing documentation for best results
|
|
197
|
-
|
|
198
|
-
To maximize the automatic inference capabilities, include frontmatter in your markdown files:
|
|
128
|
+
For best results, include descriptive frontmatter:
|
|
199
129
|
|
|
200
130
|
```markdown
|
|
201
131
|
---
|
|
132
|
+
alwaysApply: false
|
|
202
133
|
title: "React Component Guidelines"
|
|
203
134
|
description: "Best practices for building React components"
|
|
204
135
|
keywords: ["react", "components", "hooks", "jsx"]
|
|
205
|
-
|
|
206
|
-
category: "guides"
|
|
136
|
+
filePatterns: ["*.js"]
|
|
207
137
|
---
|
|
208
138
|
|
|
209
139
|
# React Component Guidelines
|
|
@@ -211,8 +141,6 @@ category: "guides"
|
|
|
211
141
|
Your documentation content here...
|
|
212
142
|
```
|
|
213
143
|
|
|
214
|
-
The automatic indexing will use this metadata along with analyzing your content to provide intelligent suggestions.
|
|
215
|
-
|
|
216
144
|
## Development setup
|
|
217
145
|
|
|
218
146
|
### Running locally
|
|
@@ -228,21 +156,28 @@ The automatic indexing will use this metadata along with analyzing your content
|
|
|
228
156
|
npm install
|
|
229
157
|
```
|
|
230
158
|
|
|
231
|
-
3. **Run the server:**
|
|
159
|
+
3. **Run the server (uses built-in doc-bot/ folder):**
|
|
232
160
|
```bash
|
|
233
161
|
npm start
|
|
234
162
|
```
|
|
235
163
|
|
|
236
|
-
4. **Run
|
|
164
|
+
4. **Run with file watching (recommended for development):**
|
|
237
165
|
```bash
|
|
238
|
-
npm
|
|
166
|
+
npm run dev
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
5. **Run with examples documentation:**
|
|
170
|
+
```bash
|
|
171
|
+
npm run start:examples
|
|
239
172
|
```
|
|
240
173
|
|
|
241
|
-
|
|
174
|
+
6. **Run tests:**
|
|
242
175
|
```bash
|
|
243
|
-
npm
|
|
176
|
+
npm test
|
|
244
177
|
```
|
|
245
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
|
+
|
|
246
181
|
### Testing your setup
|
|
247
182
|
|
|
248
183
|
Ask your AI assistant something like "What documentation is available?" to test that doc-bot is working.
|
|
@@ -254,13 +189,82 @@ doc-bot [options]
|
|
|
254
189
|
|
|
255
190
|
Options:
|
|
256
191
|
-d, --docs <path> Path to docs folder (required)
|
|
257
|
-
-c, --config <path> Path to manifest file (
|
|
258
|
-
-p, --port <port> Port to run server on (default: 3000)
|
|
192
|
+
-c, --config <path> Path to manifest file (optional, for backward compatibility)
|
|
259
193
|
-v, --verbose Enable verbose logging
|
|
260
194
|
-w, --watch Watch for file changes
|
|
261
195
|
-h, --help Show help
|
|
262
196
|
```
|
|
263
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
|
+
|
|
264
268
|
## License
|
|
265
269
|
|
|
266
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",
|