@afterxleep/doc-bot 1.9.1 → 1.13.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 (25) hide show
  1. package/README.md +226 -294
  2. package/bin/doc-bot.js +2 -3
  3. package/package.json +8 -7
  4. package/src/__tests__/docset-integration.test.js +146 -0
  5. package/src/__tests__/temp-docs-1752689978225/test.md +5 -0
  6. package/src/__tests__/temp-docs-1752689978235/test.md +5 -0
  7. package/src/__tests__/temp-docs-1752689978241/test.md +5 -0
  8. package/src/__tests__/temp-docs-1752689978243/test.md +5 -0
  9. package/src/__tests__/temp-docs-1752689978244/test.md +5 -0
  10. package/src/__tests__/temp-docsets-1752689978244/7e2cbc65/Mock.docset/Contents/Info.plist +10 -0
  11. package/src/__tests__/temp-docsets-1752689978244/7e2cbc65/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  12. package/src/__tests__/temp-docsets-1752689978244/Mock.docset/Contents/Info.plist +10 -0
  13. package/src/__tests__/temp-docsets-1752689978244/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  14. package/src/__tests__/temp-docsets-1752689978244/docsets.json +10 -0
  15. package/src/index.js +474 -28
  16. package/src/services/DocumentationService.js +131 -2
  17. package/src/services/UnifiedSearchService.js +214 -0
  18. package/src/services/__tests__/DocumentationService.test.js +318 -0
  19. package/src/services/__tests__/UnifiedSearchService.test.js +302 -0
  20. package/src/services/docset/ParallelSearchManager.js +158 -0
  21. package/src/services/docset/__tests__/DocsetDatabase.test.js +337 -0
  22. package/src/services/docset/__tests__/DocsetService.test.js +195 -0
  23. package/src/services/docset/__tests__/EnhancedDocsetDatabase.test.js +324 -0
  24. package/src/services/docset/database.js +474 -0
  25. package/src/services/docset/index.js +349 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterxleep/doc-bot",
3
- "version": "1.9.1",
3
+ "version": "1.13.0",
4
4
  "description": "Generic MCP server for intelligent documentation access in any project",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -12,7 +12,7 @@
12
12
  "start:watch": "node bin/doc-bot.js --verbose --watch",
13
13
  "start:examples": "node bin/doc-bot.js --docs ./samples --verbose",
14
14
  "dev": "node bin/doc-bot.js --verbose --watch",
15
- "test": "NODE_OPTIONS=--experimental-vm-modules jest",
15
+ "test": "jest",
16
16
  "test:watch": "jest --watch",
17
17
  "test:coverage": "jest --coverage",
18
18
  "lint": "eslint src/ bin/ --ext .js",
@@ -45,17 +45,18 @@
45
45
  "chokidar": "^3.5.3",
46
46
  "fs-extra": "^11.0.0",
47
47
  "glob": "^10.3.0",
48
- "yaml": "^2.3.0"
48
+ "yaml": "^2.3.0",
49
+ "better-sqlite3": "^11.10.0",
50
+ "axios": "^1.6.0",
51
+ "tar": "^7.4.0",
52
+ "adm-zip": "^0.5.16",
53
+ "plist": "^3.1.0"
49
54
  },
50
55
  "devDependencies": {
51
56
  "eslint": "^8.57.0",
52
57
  "jest": "^29.7.0",
53
58
  "supertest": "^6.3.0"
54
59
  },
55
- "jest": {
56
- "testEnvironment": "node",
57
- "transform": {}
58
- },
59
60
  "engines": {
60
61
  "node": ">=18.0.0"
61
62
  },
@@ -0,0 +1,146 @@
1
+ import { DocsServer } from '../index.js';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname } from 'path';
6
+ import os from 'os';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ describe('DocsServer Docset Integration', () => {
12
+ let server;
13
+ let tempDocsPath;
14
+ let tempDocsetsPath;
15
+
16
+ beforeEach(async () => {
17
+ // Create temporary directories
18
+ tempDocsPath = path.join(__dirname, 'temp-docs-' + Date.now());
19
+ tempDocsetsPath = path.join(__dirname, 'temp-docsets-' + Date.now());
20
+
21
+ await fs.ensureDir(tempDocsPath);
22
+ await fs.ensureDir(tempDocsetsPath);
23
+
24
+ // Create a simple test doc
25
+ await fs.writeFile(
26
+ path.join(tempDocsPath, 'test.md'),
27
+ '---\nalwaysApply: true\ntitle: Test Doc\n---\n# Test'
28
+ );
29
+ });
30
+
31
+ afterEach(async () => {
32
+ if (server) {
33
+ await server.close();
34
+ }
35
+ await fs.remove(tempDocsPath);
36
+ await fs.remove(tempDocsetsPath);
37
+ });
38
+
39
+ describe('Server initialization with docsets', () => {
40
+ it('should initialize with custom docsets path', async () => {
41
+ server = new DocsServer({
42
+ docsPath: tempDocsPath,
43
+ docsetsPath: tempDocsetsPath,
44
+ verbose: false
45
+ });
46
+
47
+ await server.start();
48
+
49
+ expect(server.docsetService).toBeDefined();
50
+ expect(server.docsetService.storagePath).toBe(tempDocsetsPath);
51
+ });
52
+
53
+ it('should use default docsets path when not provided', async () => {
54
+ server = new DocsServer({
55
+ docsPath: tempDocsPath,
56
+ verbose: false
57
+ });
58
+
59
+ await server.start();
60
+
61
+ const expectedPath = path.join(os.homedir(), 'Developer', 'DocSets');
62
+ expect(server.docsetService.storagePath).toBe(expectedPath);
63
+ });
64
+ });
65
+
66
+ describe('Docset service functionality', () => {
67
+ beforeEach(async () => {
68
+ server = new DocsServer({
69
+ docsPath: tempDocsPath,
70
+ docsetsPath: tempDocsetsPath,
71
+ verbose: false
72
+ });
73
+ await server.start();
74
+ });
75
+
76
+ it('should have docset service initialized', () => {
77
+ expect(server.docsetService).toBeDefined();
78
+ expect(server.multiDocsetDatabase).toBeDefined();
79
+ });
80
+
81
+ it('should have empty docsets initially', async () => {
82
+ const docsets = await server.docsetService.listDocsets();
83
+ expect(docsets).toEqual([]);
84
+ });
85
+
86
+ it('should handle docset operations', async () => {
87
+ // Create a mock docset
88
+ const mockDocsetPath = path.join(tempDocsetsPath, 'Mock.docset');
89
+ const contentsPath = path.join(mockDocsetPath, 'Contents');
90
+ const resourcesPath = path.join(contentsPath, 'Resources');
91
+
92
+ await fs.ensureDir(resourcesPath);
93
+
94
+ // Create Info.plist
95
+ const infoPlist = `<?xml version="1.0" encoding="UTF-8"?>
96
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
97
+ <plist version="1.0">
98
+ <dict>
99
+ <key>CFBundleName</key>
100
+ <string>Mock Documentation</string>
101
+ <key>CFBundleIdentifier</key>
102
+ <string>mock.documentation</string>
103
+ </dict>
104
+ </plist>`;
105
+ await fs.writeFile(path.join(contentsPath, 'Info.plist'), infoPlist);
106
+
107
+ // Create SQLite database
108
+ const Database = (await import('better-sqlite3')).default;
109
+ const dbPath = path.join(resourcesPath, 'docSet.dsidx');
110
+ const db = new Database(dbPath);
111
+ db.exec(`
112
+ CREATE TABLE searchIndex(
113
+ id INTEGER PRIMARY KEY,
114
+ name TEXT,
115
+ type TEXT,
116
+ path TEXT
117
+ );
118
+ `);
119
+ db.prepare('INSERT INTO searchIndex (name, type, path) VALUES (?, ?, ?)')
120
+ .run('TestClass', 'Class', 'test.html');
121
+ db.close();
122
+
123
+ // Test adding docset
124
+ const docsetInfo = await server.docsetService.addDocset(mockDocsetPath);
125
+ expect(docsetInfo.name).toBe('Mock Documentation');
126
+
127
+ // Test listing docsets
128
+ const docsets = await server.docsetService.listDocsets();
129
+ expect(docsets).toHaveLength(1);
130
+ expect(docsets[0].name).toBe('Mock Documentation');
131
+
132
+ // Add to database for searching
133
+ server.multiDocsetDatabase.addDocset(docsetInfo);
134
+
135
+ // Test searching
136
+ const searchResults = server.multiDocsetDatabase.search('Test');
137
+ expect(searchResults).toHaveLength(1);
138
+ expect(searchResults[0].name).toBe('TestClass');
139
+
140
+ // Test removing docset
141
+ await server.docsetService.removeDocset(docsetInfo.id);
142
+ const finalDocsets = await server.docsetService.listDocsets();
143
+ expect(finalDocsets).toHaveLength(0);
144
+ });
145
+ });
146
+ });
@@ -0,0 +1,5 @@
1
+ ---
2
+ alwaysApply: true
3
+ title: Test Doc
4
+ ---
5
+ # Test
@@ -0,0 +1,5 @@
1
+ ---
2
+ alwaysApply: true
3
+ title: Test Doc
4
+ ---
5
+ # Test
@@ -0,0 +1,5 @@
1
+ ---
2
+ alwaysApply: true
3
+ title: Test Doc
4
+ ---
5
+ # Test
@@ -0,0 +1,5 @@
1
+ ---
2
+ alwaysApply: true
3
+ title: Test Doc
4
+ ---
5
+ # Test
@@ -0,0 +1,5 @@
1
+ ---
2
+ alwaysApply: true
3
+ title: Test Doc
4
+ ---
5
+ # Test
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleName</key>
6
+ <string>Mock Documentation</string>
7
+ <key>CFBundleIdentifier</key>
8
+ <string>mock.documentation</string>
9
+ </dict>
10
+ </plist>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleName</key>
6
+ <string>Mock Documentation</string>
7
+ <key>CFBundleIdentifier</key>
8
+ <string>mock.documentation</string>
9
+ </dict>
10
+ </plist>
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "id": "7e2cbc65",
4
+ "name": "Mock Documentation",
5
+ "source": "/Users/afterxleep/Developer/doc-bot/src/__tests__/temp-docsets-1752689978244/Mock.docset",
6
+ "path": "/Users/afterxleep/Developer/doc-bot/src/__tests__/temp-docsets-1752689978244/7e2cbc65/Mock.docset",
7
+ "downloadedAt": "2025-07-16T18:19:38.250Z",
8
+ "size": 8513
9
+ }
10
+ ]