@afterxleep/doc-bot 1.23.1 → 2.0.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 (92) hide show
  1. package/README.md +53 -18
  2. package/bin/doc-bot.js +10 -4
  3. package/package.json +2 -3
  4. package/src/index.js +232 -501
  5. package/src/index.test.js +6 -6
  6. package/src/services/DocumentationService.js +10 -25
  7. package/src/services/InferenceEngine.js +1 -4
  8. package/src/services/__tests__/InferenceEngine.integration.test.js +3 -8
  9. package/src/services/__tests__/PaginationService.integration.test.js +20 -40
  10. package/src/services/docset/__tests__/DocsetDatabase.test.js +4 -5
  11. package/src/services/docset/__tests__/DocsetService.test.js +3 -4
  12. package/AGENT_INTEGRATION_RULE.txt +0 -79
  13. package/src/__tests__/temp-docs-1752689978225/test.md +0 -5
  14. package/src/__tests__/temp-docs-1752689978235/test.md +0 -5
  15. package/src/__tests__/temp-docs-1752689978241/test.md +0 -5
  16. package/src/__tests__/temp-docs-1752689978243/test.md +0 -5
  17. package/src/__tests__/temp-docs-1752689978244/test.md +0 -5
  18. package/src/__tests__/temp-docs-1756129972061/test.md +0 -5
  19. package/src/__tests__/temp-docs-1756129972071/test.md +0 -5
  20. package/src/__tests__/temp-docs-1756129972075/test.md +0 -5
  21. package/src/__tests__/temp-docs-1756129972077/test.md +0 -5
  22. package/src/__tests__/temp-docs-1756129972079/test.md +0 -5
  23. package/src/__tests__/temp-docs-1756130189361/test.md +0 -5
  24. package/src/__tests__/temp-docs-1756130189372/test.md +0 -5
  25. package/src/__tests__/temp-docs-1756130189375/test.md +0 -5
  26. package/src/__tests__/temp-docs-1756130189378/test.md +0 -5
  27. package/src/__tests__/temp-docs-1756130189379/test.md +0 -5
  28. package/src/__tests__/temp-docs-1756130271128/test.md +0 -5
  29. package/src/__tests__/temp-docs-1756130271139/test.md +0 -5
  30. package/src/__tests__/temp-docs-1756130271142/test.md +0 -5
  31. package/src/__tests__/temp-docs-1756130271145/test.md +0 -5
  32. package/src/__tests__/temp-docs-1756130271146/test.md +0 -5
  33. package/src/__tests__/temp-docs-1756130687030/test.md +0 -5
  34. package/src/__tests__/temp-docs-1756130687044/test.md +0 -5
  35. package/src/__tests__/temp-docs-1756130687048/test.md +0 -5
  36. package/src/__tests__/temp-docs-1756130687051/test.md +0 -5
  37. package/src/__tests__/temp-docs-1756130687053/test.md +0 -5
  38. package/src/__tests__/temp-docs-1756131694925/test.md +0 -5
  39. package/src/__tests__/temp-docs-1756131694937/test.md +0 -5
  40. package/src/__tests__/temp-docs-1756131694941/test.md +0 -5
  41. package/src/__tests__/temp-docs-1756131694944/test.md +0 -5
  42. package/src/__tests__/temp-docs-1756131694946/test.md +0 -5
  43. package/src/__tests__/temp-docs-1756133998710/test.md +0 -5
  44. package/src/__tests__/temp-docs-1756133998721/test.md +0 -5
  45. package/src/__tests__/temp-docs-1756133998724/test.md +0 -5
  46. package/src/__tests__/temp-docs-1756133998727/test.md +0 -5
  47. package/src/__tests__/temp-docs-1756133998729/test.md +0 -5
  48. package/src/__tests__/temp-docs-1756134345935/test.md +0 -5
  49. package/src/__tests__/temp-docs-1756134345948/test.md +0 -5
  50. package/src/__tests__/temp-docs-1756134345952/test.md +0 -5
  51. package/src/__tests__/temp-docs-1756134345954/test.md +0 -5
  52. package/src/__tests__/temp-docs-1756134345957/test.md +0 -5
  53. package/src/__tests__/temp-docsets-1752689978244/7e2cbc65/Mock.docset/Contents/Info.plist +0 -10
  54. package/src/__tests__/temp-docsets-1752689978244/7e2cbc65/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  55. package/src/__tests__/temp-docsets-1752689978244/Mock.docset/Contents/Info.plist +0 -10
  56. package/src/__tests__/temp-docsets-1752689978244/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  57. package/src/__tests__/temp-docsets-1752689978244/docsets.json +0 -10
  58. package/src/__tests__/temp-docsets-1756129972079/2e443167/Mock.docset/Contents/Info.plist +0 -10
  59. package/src/__tests__/temp-docsets-1756129972079/2e443167/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  60. package/src/__tests__/temp-docsets-1756129972079/Mock.docset/Contents/Info.plist +0 -10
  61. package/src/__tests__/temp-docsets-1756129972079/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  62. package/src/__tests__/temp-docsets-1756129972079/docsets.json +0 -10
  63. package/src/__tests__/temp-docsets-1756130189379/Mock.docset/Contents/Info.plist +0 -10
  64. package/src/__tests__/temp-docsets-1756130189379/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  65. package/src/__tests__/temp-docsets-1756130189379/a4934c14/Mock.docset/Contents/Info.plist +0 -10
  66. package/src/__tests__/temp-docsets-1756130189379/a4934c14/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  67. package/src/__tests__/temp-docsets-1756130189379/docsets.json +0 -10
  68. package/src/__tests__/temp-docsets-1756130271146/3f8acbb2/Mock.docset/Contents/Info.plist +0 -10
  69. package/src/__tests__/temp-docsets-1756130271146/3f8acbb2/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  70. package/src/__tests__/temp-docsets-1756130271146/Mock.docset/Contents/Info.plist +0 -10
  71. package/src/__tests__/temp-docsets-1756130271146/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  72. package/src/__tests__/temp-docsets-1756130271146/docsets.json +0 -10
  73. package/src/__tests__/temp-docsets-1756130687053/6810e6bd/Mock.docset/Contents/Info.plist +0 -10
  74. package/src/__tests__/temp-docsets-1756130687053/6810e6bd/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  75. package/src/__tests__/temp-docsets-1756130687053/Mock.docset/Contents/Info.plist +0 -10
  76. package/src/__tests__/temp-docsets-1756130687053/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  77. package/src/__tests__/temp-docsets-1756130687053/docsets.json +0 -10
  78. package/src/__tests__/temp-docsets-1756131694946/Mock.docset/Contents/Info.plist +0 -10
  79. package/src/__tests__/temp-docsets-1756131694946/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  80. package/src/__tests__/temp-docsets-1756131694946/dd703046/Mock.docset/Contents/Info.plist +0 -10
  81. package/src/__tests__/temp-docsets-1756131694946/dd703046/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  82. package/src/__tests__/temp-docsets-1756131694946/docsets.json +0 -10
  83. package/src/__tests__/temp-docsets-1756133998729/9e061136/Mock.docset/Contents/Info.plist +0 -10
  84. package/src/__tests__/temp-docsets-1756133998729/9e061136/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  85. package/src/__tests__/temp-docsets-1756133998729/Mock.docset/Contents/Info.plist +0 -10
  86. package/src/__tests__/temp-docsets-1756133998729/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  87. package/src/__tests__/temp-docsets-1756133998729/docsets.json +0 -10
  88. package/src/__tests__/temp-docsets-1756134345957/03e730af/Mock.docset/Contents/Info.plist +0 -10
  89. package/src/__tests__/temp-docsets-1756134345957/03e730af/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  90. package/src/__tests__/temp-docsets-1756134345957/Mock.docset/Contents/Info.plist +0 -10
  91. package/src/__tests__/temp-docsets-1756134345957/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  92. package/src/__tests__/temp-docsets-1756134345957/docsets.json +0 -10
package/README.md CHANGED
@@ -9,16 +9,17 @@ An intelligent MCP (Model Context Protocol) server that gives AI assistants like
9
9
 
10
10
  doc-bot is a documentation server that enhances AI coding assistants by providing:
11
11
  - 🧠 **Smart search** through your project documentation
12
- - 📖 **Contextual rules** that apply based on what you're working on
12
+ - 📖 **Contextual docs** that surface guidance based on what you're working on
13
13
  - 🔄 **Live updates** as your documentation changes
14
14
  - 📚 **API references** from official documentation (via Docsets)
15
15
  - 🤖 **MCP tools** for AI agents to query and understand your project
16
+ - ✍️ **Agent-driven updates** so new knowledge is captured in docs
16
17
 
17
18
  ## Why doc-bot?
18
19
 
19
20
  Traditional AI assistants have limited context windows and no understanding of your specific project. doc-bot solves this by:
20
21
 
21
- 1. **Providing project-specific knowledge** - Your conventions, patterns, and rules
22
+ 1. **Providing project-specific knowledge** - Your conventions, patterns, and decisions
22
23
  2. **Searching intelligently** - AI finds exactly what it needs without cluttering context
23
24
  3. **Scaling infinitely** - Thousands of docs without token limits
24
25
  4. **Staying current** - Live reload ensures AI always has latest information
@@ -32,10 +33,10 @@ Your Project Documentation → doc-bot → MCP Protocol → AI Assistant (Claude
32
33
  ```
33
34
 
34
35
  When you ask your AI assistant to write code, it can:
35
- 1. Check your project's coding standards
36
- 2. Search for relevant documentation
36
+ 1. Search for relevant documentation
37
+ 2. Read project docs for patterns and examples
37
38
  3. Find API references and examples
38
- 4. Follow your team's specific patterns
39
+ 4. Update documentation when new patterns are discovered
39
40
 
40
41
  ## Quick Start
41
42
 
@@ -78,18 +79,48 @@ your-project/
78
79
  └── package.json
79
80
  ```
80
81
 
81
- ### 3. Add the custom Agent Rule
82
+ ### 3. Test it!
82
83
 
83
- Replace all rules and instructions for your Agent (cursor.mdc, CLAUDE.md, etc) with Doc Bot Core Rule [AGENT INTEGRATION RULE](https://github.com/afterxleep/doc-bot/blob/main/AGENT_INTEGRATION_RULE.txt).
84
+ Ask your AI assistant: "What are the coding standards for this project?"
84
85
 
85
- ### 4. Test it!
86
+ ## Versioning and Compatibility
86
87
 
87
- Ask your AI assistant: "What are the coding standards for this project?"
88
+ doc-bot 2.0 is a breaking change. Rule enforcement and `alwaysApply` behavior are removed in favor of documentation-first guidance.
89
+
90
+ - If you need the legacy rule enforcement flow, pin to `@afterxleep/doc-bot@1` or build from the `1.x` branch.
91
+ - New installs should use the latest 2.x line (`@afterxleep/doc-bot@latest`).
88
92
 
89
93
  ## Project Documentation
90
94
 
91
95
  doc-bot treats your project documentation as a searchable knowledge base for AI assistants.
92
96
 
97
+ ### Agent-Driven Updates
98
+
99
+ doc-bot is designed for agents to keep documentation current as they work. When an assistant discovers a new pattern or a change, it can add or update docs directly:
100
+
101
+ ```json
102
+ {
103
+ "fileName": "auth-flow.md",
104
+ "title": "Auth Flow",
105
+ "description": "OAuth flow and token handling",
106
+ "keywords": ["auth", "oauth", "tokens"],
107
+ "filePatterns": ["src/auth/**"],
108
+ "content": "# Auth Flow\n\nDocument the new flow here."
109
+ }
110
+ ```
111
+
112
+ ### Agent Documentation Loop
113
+
114
+ Use this fast loop to extend project knowledge and keep docs current:
115
+
116
+ 1. **Orient quickly**: call `doc_bot(task)` or `get_document_index()` when the project is unfamiliar.
117
+ 2. **Find specifics**: use `search_documentation` with concrete terms (API names, class names, errors).
118
+ 3. **Read the full context**: open matches with `read_specific_document` or `get_file_docs`.
119
+ 4. **Capture new knowledge**: when behavior changes or new patterns emerge, write it with `create_or_update_rule`.
120
+ 5. **Refresh when needed**: if docs are edited manually, run `refresh_documentation()`.
121
+
122
+ Keep docs short, scoped, and searchable with clear titles, keywords, and `filePatterns`.
123
+
93
124
  ### Documentation Format
94
125
 
95
126
  Create markdown files with frontmatter metadata:
@@ -116,7 +147,7 @@ keywords: ["react", "components", "frontend", "jsx"]
116
147
  | `title` | string | Document title (required) | "API Guidelines" |
117
148
  | `description` | string | Brief description | "REST API design patterns" |
118
149
  | `keywords` | array | Search keywords | ["api", "rest", "http"] |
119
- | `alwaysApply` | boolean | Apply to all queries | true/false |
150
+ | `topics` | array | Optional topical tags | ["architecture", "backend"] |
120
151
  | `filePatterns` | array | Apply to specific files | ["*.test.js", "**/*.spec.ts"] |
121
152
 
122
153
  ### How Search Works
@@ -126,15 +157,16 @@ keywords: ["react", "components", "frontend", "jsx"]
126
157
  3. **Relevance Scoring** - Results ranked by relevance (exact matches score highest)
127
158
  4. **Context Extraction** - Returns snippets showing matched content
128
159
 
160
+ doc-bot surfaces documentation for agents; it does not enforce rules. Agents should update docs when new patterns or changes appear.
161
+
129
162
  ### Types of Documentation
130
163
 
131
- #### Global Rules (Always Apply)
164
+ #### General Documentation
132
165
  ```markdown
133
166
  ---
134
167
  title: "Coding Standards"
135
- alwaysApply: true
136
168
  ---
137
- Rules that apply to every file in your project
169
+ Project-wide guidance and conventions
138
170
  ```
139
171
 
140
172
  #### Contextual Documentation
@@ -227,10 +259,13 @@ doc-bot provides these tools to AI assistants:
227
259
 
228
260
  | Tool | Purpose | Example Use |
229
261
  |------|---------|-------------|
230
- | `check_project_rules` | Get rules before writing code | "What patterns should I follow?" |
262
+ | `doc_bot` | Get documentation guidance | "How should I approach auth?" |
231
263
  | `search_documentation` | Search all documentation | "How do I implement auth?" |
232
- | `get_global_rules` | Get always-apply rules | "What are the coding standards?" |
233
- | `get_file_docs` | Get file-specific docs | "Rules for Button.test.jsx" |
264
+ | `get_file_docs` | Get file-specific docs | "Docs for Button.test.jsx" |
265
+ | `read_specific_document` | Read full docs by file name | "Open coding-standards.md" |
266
+ | `get_document_index` | List all docs | "Show documentation index" |
267
+ | `create_or_update_rule` | Add/update documentation | "Capture auth flow update" |
268
+ | `refresh_documentation` | Reload docs from disk | "Refresh the doc store" |
234
269
  | `explore_api` | Explore API documentation | "Show me URLSession methods" |
235
270
  | `add_docset` | Install new docset | "Add Swift docs from URL" |
236
271
  | `remove_docset` | Remove installed docset | "Remove docset abc123" |
@@ -291,7 +326,7 @@ Options:
291
326
  ---
292
327
  ```
293
328
 
294
- 2. **Apply rules contextually**
329
+ 2. **Use file patterns for contextual docs**
295
330
  ```markdown
296
331
  ---
297
332
  filePatterns: ["**/auth/**", "*.auth.js"]
@@ -308,7 +343,7 @@ Options:
308
343
  - Use clear section headers for better snippet extraction
309
344
  - Add descriptions to improve search relevance
310
345
 
311
- ## Why MCP over Static Rules?
346
+ ## Why MCP over Static Instruction Files?
312
347
 
313
348
  Unlike static `.cursorrules` or `.github/copilot-instructions.md` files:
314
349
 
package/bin/doc-bot.js CHANGED
@@ -16,6 +16,7 @@ program
16
16
  .description('Generic MCP server for intelligent documentation access')
17
17
  .version(packageJson.version)
18
18
  .option('-d, --docs <path>', 'Path to docs folder', 'doc-bot')
19
+ .option('-s, --docsets <path>', 'Path to docsets folder')
19
20
  .option('-v, --verbose', 'Enable verbose logging')
20
21
  .option('-w, --watch', 'Watch for file changes')
21
22
  .parse();
@@ -32,11 +33,12 @@ async function main() {
32
33
  console.log('📖 To get started, create your documentation folder:');
33
34
  console.log('');
34
35
  console.log(` mkdir ${path.basename(docsPath)}`);
35
- console.log(` echo "---\nalwaysApply: true\ntitle: Getting Started\n---\n# Getting Started\nThis is your project documentation." > ${path.basename(docsPath)}/getting-started.md`);
36
+ console.log(` echo "---\ntitle: Getting Started\n---\n# Getting Started\nThis is your project documentation." > ${path.basename(docsPath)}/getting-started.md`);
36
37
  console.log('');
37
38
  console.log('📋 Use frontmatter in your markdown files:');
38
- console.log(' alwaysApply: true (for global rules)');
39
- console.log(' alwaysApply: false (for contextual rules)');
39
+ console.log(' title: "Doc Title" (required)');
40
+ console.log(' keywords: ["term"] (optional)');
41
+ console.log(' filePatterns: ["**/*.test.js"] (optional)');
40
42
  console.log('');
41
43
  console.log('💡 Tip: By default, doc-bot looks for a doc-bot folder.');
42
44
  console.log(' Use --docs to specify a different folder.');
@@ -45,6 +47,7 @@ async function main() {
45
47
 
46
48
  const server = new DocsServer({
47
49
  docsPath,
50
+ docsetsPath: options.docsets ? path.resolve(options.docsets) : undefined,
48
51
  verbose: options.verbose,
49
52
  watch: options.watch
50
53
  });
@@ -52,6 +55,9 @@ async function main() {
52
55
  if (options.verbose) {
53
56
  console.error('🚀 Starting doc-bot...');
54
57
  console.error(`📁 Documentation: ${docsPath}`);
58
+ if (options.docsets) {
59
+ console.error(`📚 Docsets: ${path.resolve(options.docsets)}`);
60
+ }
55
61
  console.error(`⚙️ Configuration: Frontmatter-based`);
56
62
 
57
63
  if (options.watch) {
@@ -72,4 +78,4 @@ main().catch(error => {
72
78
  console.error(error.stack);
73
79
  }
74
80
  process.exit(1);
75
- });
81
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterxleep/doc-bot",
3
- "version": "1.23.1",
3
+ "version": "2.0.0",
4
4
  "description": "Generic MCP server for intelligent documentation access in any project",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -68,7 +68,6 @@
68
68
  "bin/",
69
69
  "prompts/",
70
70
  "README.md",
71
- "LICENSE",
72
- "AGENT_INTEGRATION_RULE.txt"
71
+ "LICENSE"
73
72
  ]
74
73
  }