@afterxleep/doc-bot 1.5.0 → 1.7.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 CHANGED
@@ -3,7 +3,9 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@afterxleep/doc-bot)](https://www.npmjs.com/package/@afterxleep/doc-bot)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- A generic MCP (Model Context Protocol) server that provides intelligent documentation access for any project. Works with any MCP-compatible AI tools and IDEs.
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
 
@@ -15,17 +17,85 @@ doc-bot is an intelligent documentation server that:
15
17
  - 🤖 **Detects** code patterns, frameworks, and keywords automatically
16
18
  - 🔄 **Updates** automatically when docs change
17
19
 
20
+ ## Why MCP Instead of Static Rules?
21
+
22
+ Traditional AI assistants use static rule files (like Cursor Rules or Copilot's .github/copilot-instructions.md) that have significant limitations. doc-bot's MCP approach offers powerful advantages:
23
+
24
+ ### 🚀 Dynamic Search vs Static Rules
25
+
26
+ **Static Systems:**
27
+ - All rules must fit in a single file or limited token window
28
+ - AI reads everything, even irrelevant rules
29
+ - No way to search or filter documentation
30
+ - Rules compete for precious context space
31
+
32
+ **MCP with doc-bot:**
33
+ - AI searches for exactly what it needs
34
+ - Unlimited documentation size - only relevant parts are retrieved
35
+ - Smart keyword and pattern matching
36
+ - Context window used efficiently
37
+
38
+ ### 🧠 Contextual Intelligence
39
+
40
+ **Static Systems:**
41
+ - Same rules applied everywhere
42
+ - No awareness of what you're working on
43
+ - Can't provide specific help for your current task
44
+
45
+ **MCP with doc-bot:**
46
+ - AI searches for relevant documentation based on your query
47
+ - Context-aware suggestions from your actual questions
48
+ - Different documentation retrieved for different tasks
49
+ - Intelligent inference from keywords and search terms
50
+
51
+ ### 📈 Scalability Without Limits
52
+
53
+ **Static Systems:**
54
+ - Limited by token count (typically 2-4k tokens)
55
+ - Adding more rules means removing others
56
+ - Documentation competes with your actual code for context
57
+
58
+ **MCP with doc-bot:**
59
+ - Store thousands of documentation files
60
+ - No token limit - documentation lives outside the context
61
+ - AI retrieves only what's needed
62
+ - Your context window stays free for actual work
63
+
64
+ ### 🔄 Live Updates
65
+
66
+ **Static Systems:**
67
+ - Changes require restarting your AI/IDE
68
+ - No way to know if rules are current
69
+ - Manual synchronization across tools
70
+
71
+ **MCP with doc-bot:**
72
+ - Hot reload on documentation changes
73
+ - Always serves the latest version
74
+ - Single source of truth for all AI tools
75
+
76
+ ### 🎯 Smart Discovery
77
+
78
+ **Static Systems:**
79
+ - AI doesn't know what documentation exists
80
+ - Users must know to ask specific questions
81
+ - No exploration or discovery capabilities
82
+
83
+ **MCP with doc-bot:**
84
+ - AI can list all available documentation
85
+ - Discovers relevant docs automatically
86
+ - Suggests documentation based on context
87
+ - Searchable knowledge base
88
+
18
89
  ## Installation
19
90
 
20
91
  1. **Create your documentation folder** in your project root (see organization section below)
21
92
 
22
93
  2. **Add doc-bot to your MCP-compatible AI tool configuration**:
23
94
 
24
- **For Claude Code** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
25
95
  ```json
26
96
  {
27
97
  "mcpServers": {
28
- "docs": {
98
+ "docbot": {
29
99
  "command": "npx",
30
100
  "args": ["@afterxleep/doc-bot", "--docs", "./doc-bot"]
31
101
  }
@@ -33,26 +103,20 @@ doc-bot is an intelligent documentation server that:
33
103
  }
34
104
  ```
35
105
 
36
- **For Cursor or other MCP tools**: Add similar configuration pointing to your documentation folder
37
-
38
106
  3. **Restart your AI tool**
39
107
 
40
108
  ## How to organize your documentation
41
109
 
42
- Create a `doc-bot/` folder in your project root:
110
+ Create a `doc-bot/` folder in your project root with markdown files using frontmatter:
43
111
 
44
112
  ```
45
113
  your-project/
46
114
  ├── doc-bot/
47
- │ ├── manifest.json # Configuration file
48
- │ ├── core/
49
- ├── coding-standards.md # Always-apply coding standards
50
- │ └── security.md # Security guidelines
51
- ├── guides/
52
- │ │ ├── testing.md # Testing strategies
53
- │ │ └── api-development.md # API development guide
54
- │ └── reference/
55
- │ └── troubleshooting.md # Common issues and solutions
115
+ │ ├── coding-standards.md # Global rule (alwaysApply: true)
116
+ │ ├── security.md # Global rule (alwaysApply: true)
117
+ │ ├── testing.md # Contextual rule (alwaysApply: false)
118
+ ├── api-development.md # Contextual rule (alwaysApply: false)
119
+ └── troubleshooting.md # Contextual rule (alwaysApply: false)
56
120
  └── package.json
57
121
  ```
58
122
 
@@ -63,19 +127,18 @@ your-project/
63
127
 
64
128
  ### Documentation types:
65
129
 
66
- - **Core docs** (`core/`): Critical guidelines that should always be considered
67
- - **Guides** (`guides/`): Step-by-step instructions for specific tasks
68
- - **Reference** (`reference/`): Quick lookups and troubleshooting
130
+ - **Global Rules** (`alwaysApply: true`): Critical guidelines applied to every AI interaction
131
+ - **Contextual Rules** (`alwaysApply: false`): Rules applied based on file patterns and context
69
132
 
70
133
  ### Example documentation files:
71
134
 
72
- **Global Rule Example** (`doc-bot/core/coding-standards.md`):
135
+ **Global Rule Example** (`doc-bot/coding-standards.md`):
73
136
  ```markdown
74
137
  ---
138
+ alwaysApply: true
75
139
  title: "Coding Standards"
76
140
  description: "Core coding standards that apply to all code"
77
141
  keywords: ["code-quality", "standards", "best-practices"]
78
- tags: ["core", "quality"]
79
142
  ---
80
143
 
81
144
  # Coding Standards
@@ -87,13 +150,13 @@ tags: ["core", "quality"]
87
150
  - Write descriptive variable names
88
151
  ```
89
152
 
90
- **Contextual Rule Example** (`doc-bot/guides/testing.md`):
153
+ **Contextual Rule Example** (`doc-bot/testing.md`):
91
154
  ```markdown
92
155
  ---
156
+ alwaysApply: false
93
157
  title: "Testing Guide"
94
158
  description: "How to write and run tests"
95
159
  keywords: ["testing", "jest", "tdd", "unit-tests"]
96
- tags: ["testing", "quality"]
97
160
  ---
98
161
 
99
162
  # Testing Guide
@@ -107,111 +170,36 @@ All test files should:
107
170
  Run tests with: `npm test`
108
171
  ```
109
172
 
110
- **👀 See `examples/` folder for complete example files with proper frontmatter and content structure.**
111
-
112
- ## Rule Enforcement
173
+ ## Frontmatter-Based Configuration
113
174
 
114
- Doc-bot ensures your rules are **always considered** through multiple enforcement mechanisms:
175
+ doc-bot uses frontmatter in your markdown files to automatically detect and categorize rules - **no manifest.json required!**
115
176
 
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
177
+ ### Frontmatter Fields:
121
178
 
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
179
+ - **`alwaysApply: true`** - Global rules applied to every AI interaction
180
+ - **`alwaysApply: false`** - Contextual rules searched and applied based on relevance
181
+ - **`keywords: ["list", "of", "keywords"]`** - For smart indexing and search
182
+ - **`title`** and **`description`** - Standard metadata
128
183
 
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
184
+ ### 🎯 Automatic Intelligence
134
185
 
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
186
+ doc-bot automatically analyzes your documentation to provide smart suggestions:
141
187
 
142
- This multi-layered approach makes rule violations **impossible** to implement.
188
+ - **Keyword-based search** from frontmatter metadata
189
+ - **Multi-term search** with fuzzy matching capabilities
190
+ - **Smart inference** from documentation content
191
+ - **Automatic indexing** - no manual configuration needed
143
192
 
144
- ## System Prompt Integration
193
+ ### Writing effective documentation
145
194
 
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
166
-
167
- The `doc-bot/manifest.json` file controls how your documentation works:
168
-
169
- ```json
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:
188
-
189
- - **`globalRules`**: Documents that apply to every AI interaction
190
- - **`contextualRules`**: Documents triggered by specific file patterns (e.g., test files → testing guide)
191
-
192
- ### 🎯 Automatic Inference (New!)
193
-
194
- doc-bot automatically analyzes your documentation content to build smart indexes. No more manual keyword mappings! It automatically:
195
-
196
- - **Extracts keywords** from document metadata (frontmatter)
197
- - **Detects technical terms** in your documentation content
198
- - **Recognizes code patterns** in code blocks (React hooks, SQL commands, etc.)
199
- - **Identifies frameworks** mentioned in your docs
200
- - **Indexes file extensions** referenced in documentation
201
-
202
- Just write good documentation with descriptive frontmatter, and doc-bot handles the rest!
203
-
204
- ### Writing documentation for best results
205
-
206
- To maximize the automatic inference capabilities, include frontmatter in your markdown files:
195
+ For best results, include descriptive frontmatter:
207
196
 
208
197
  ```markdown
209
198
  ---
199
+ alwaysApply: false
210
200
  title: "React Component Guidelines"
211
201
  description: "Best practices for building React components"
212
202
  keywords: ["react", "components", "hooks", "jsx"]
213
- tags: ["frontend", "development"]
214
- category: "guides"
215
203
  ---
216
204
 
217
205
  # React Component Guidelines
@@ -219,8 +207,6 @@ category: "guides"
219
207
  Your documentation content here...
220
208
  ```
221
209
 
222
- The automatic indexing will use this metadata along with analyzing your content to provide intelligent suggestions.
223
-
224
210
  ## Development setup
225
211
 
226
212
  ### Running locally
@@ -236,21 +222,28 @@ The automatic indexing will use this metadata along with analyzing your content
236
222
  npm install
237
223
  ```
238
224
 
239
- 3. **Run the server:**
225
+ 3. **Run the server (uses built-in doc-bot/ folder):**
240
226
  ```bash
241
227
  npm start
242
228
  ```
243
229
 
244
- 4. **Run tests:**
230
+ 4. **Run with file watching (recommended for development):**
245
231
  ```bash
246
- npm test
232
+ npm run dev
233
+ ```
234
+
235
+ 5. **Run with examples documentation:**
236
+ ```bash
237
+ npm run start:examples
247
238
  ```
248
239
 
249
- 5. **Run with file watching:**
240
+ 6. **Run tests:**
250
241
  ```bash
251
- npm start -- --watch
242
+ npm test
252
243
  ```
253
244
 
245
+ **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).
246
+
254
247
  ### Testing your setup
255
248
 
256
249
  Ask your AI assistant something like "What documentation is available?" to test that doc-bot is working.
@@ -262,13 +255,82 @@ doc-bot [options]
262
255
 
263
256
  Options:
264
257
  -d, --docs <path> Path to docs folder (required)
265
- -c, --config <path> Path to manifest file (default: <docs-path>/manifest.json)
266
- -p, --port <port> Port to run server on (default: 3000)
258
+ -c, --config <path> Path to manifest file (optional, for backward compatibility)
267
259
  -v, --verbose Enable verbose logging
268
260
  -w, --watch Watch for file changes
269
261
  -h, --help Show help
270
262
  ```
271
263
 
264
+ **Example usage:**
265
+ ```bash
266
+ # Basic usage (no manifest.json needed)
267
+ doc-bot --docs ./my-docs
268
+
269
+ # With verbose logging and file watching
270
+ doc-bot --docs ./my-docs --verbose --watch
271
+
272
+ # With optional manifest for backward compatibility
273
+ doc-bot --docs ./my-docs --config ./manifest.json
274
+ ```
275
+
276
+ ## Publishing and Development
277
+
278
+ ### Local Development
279
+
280
+ 1. **Clone and setup:**
281
+ ```bash
282
+ git clone https://github.com/afterxleep/doc-bot.git
283
+ cd doc-bot
284
+ npm install
285
+ ```
286
+
287
+ 2. **Run locally:**
288
+ ```bash
289
+ npm run dev # With file watching
290
+ npm start # Basic run
291
+ npm test # Run tests
292
+ ```
293
+
294
+ 3. **Test with Claude Code:**
295
+ Add to your Claude Code config:
296
+ ```json
297
+ {
298
+ "mcpServers": {
299
+ "docs": {
300
+ "command": "node",
301
+ "args": ["/path/to/doc-bot/bin/doc-bot.js", "--docs", "./doc-bot", "--watch"]
302
+ }
303
+ }
304
+ }
305
+ ```
306
+
307
+ ### Publishing to npm
308
+
309
+ 1. **Test the package:**
310
+ ```bash
311
+ npm run test
312
+ npm run lint
313
+ ```
314
+
315
+ 2. **Update version:**
316
+ ```bash
317
+ npm version patch|minor|major
318
+ ```
319
+
320
+ 3. **Publish:**
321
+ ```bash
322
+ npm publish
323
+ ```
324
+
325
+ ### Push Changes
326
+
327
+ ```bash
328
+ git add .
329
+ git commit -m "feat: your feature description"
330
+ git push origin main
331
+ git push --tags # Push version tags
332
+ ```
333
+
272
334
  ## License
273
335
 
274
336
  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.2')
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 '{"name": "My Project Documentation", "globalRules": []}' > ${path.basename(docsPath)}/manifest.json`);
33
- console.log(` echo "# Getting Started" > ${path.basename(docsPath)}/README.md`);
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
- // Check if manifest exists, create default if not
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
- globalRules: [],
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
- console.log(`⚙️ Configuration: ${configPath}`);
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.5.0",
3
+ "version": "1.7.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 src/index.js",
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",