@bangdao-ai/acw-tools 1.1.24 → 1.1.27
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 +50 -0
- package/cursorConversationParser.js +35 -5
- package/index.js +84 -8
- package/manifest.json +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -10,6 +10,27 @@ MCP (Model Context Protocol) 工具集,用于在 Cursor 中通过自然语言
|
|
|
10
10
|
|
|
11
11
|
### 配置示例(Token 认证)
|
|
12
12
|
|
|
13
|
+
#### 方式一:直接运行本地文件(推荐)
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"mcpServers": {
|
|
18
|
+
"acw-tools": {
|
|
19
|
+
"command": "node",
|
|
20
|
+
"args": ["E:\\lh\\ai-collaborative-workbench\\app\\mcp\\index.js"],
|
|
21
|
+
"env": {
|
|
22
|
+
"ACW_BASE_URL": "http://acw-fn.leo.bangdao-tech.com",
|
|
23
|
+
"ACW_TOKEN": "your-token-here"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**注意**: 请将路径 `E:\\lh\\ai-collaborative-workbench\\app\\mcp\\index.js` 替换为你实际的项目路径。
|
|
31
|
+
|
|
32
|
+
#### 方式二:使用 npm 包(在线版本)
|
|
33
|
+
|
|
13
34
|
```json
|
|
14
35
|
{
|
|
15
36
|
"mcpServers": {
|
|
@@ -28,6 +49,8 @@ MCP (Model Context Protocol) 工具集,用于在 Cursor 中通过自然语言
|
|
|
28
49
|
**配置说明**:
|
|
29
50
|
- `ACW_BASE_URL`: ACW 服务端地址(默认:http://acw-fn.leo.bangdao-tech.com)
|
|
30
51
|
- `ACW_TOKEN`: 你的用户 Token(必需,在 ACW 平台个人中心 → Token 管理中创建)
|
|
52
|
+
- **方式一**:直接运行项目中的 `app/mcp/index.js` 文件,适合本地开发
|
|
53
|
+
- **方式二**:从 npm 下载并运行最新版本,适合生产环境
|
|
31
54
|
|
|
32
55
|
### 重要提示
|
|
33
56
|
|
|
@@ -41,6 +64,33 @@ MCP (Model Context Protocol) 工具集,用于在 Cursor 中通过自然语言
|
|
|
41
64
|
|
|
42
65
|
---
|
|
43
66
|
|
|
67
|
+
## Windows 系统注意事项
|
|
68
|
+
|
|
69
|
+
### ✨ v1.1.26+:零配置、开箱即用
|
|
70
|
+
|
|
71
|
+
从 **v1.1.26** 版本开始,Windows 用户**无需安装任何编译工具**!
|
|
72
|
+
|
|
73
|
+
#### 🎯 自动降级机制
|
|
74
|
+
|
|
75
|
+
工具会自动在两个数据库引擎之间智能选择:
|
|
76
|
+
- **better-sqlite3**(高性能原生模块) - 如果可用
|
|
77
|
+
- **sql.js**(纯 JavaScript 实现) - 自动降级,100% 兼容
|
|
78
|
+
|
|
79
|
+
#### 📊 用户体验
|
|
80
|
+
|
|
81
|
+
| 功能 | 可用性 | 性能 |
|
|
82
|
+
|------|--------|------|
|
|
83
|
+
| **规则下载** | ✅ 始终可用 | ⚡ 快速 |
|
|
84
|
+
| **对话抓取** | ✅ 始终可用 | ⚡ 自动选择最佳引擎 |
|
|
85
|
+
|
|
86
|
+
查看使用的引擎:`%USERPROFILE%\.cursor\.chat_grab\logs\acw-mcp-日期.log`
|
|
87
|
+
|
|
88
|
+
#### 🔍 更多信息
|
|
89
|
+
|
|
90
|
+
如有疑问,参考:**[Windows 故障排除指南](./WINDOWS_TROUBLESHOOTING.md)**
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
44
94
|
## 许可证
|
|
45
95
|
|
|
46
96
|
MIT License
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* 从Cursor全局数据库中提取完整对话记录
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import sqlite3 from 'better-sqlite3';
|
|
7
6
|
import fs from 'fs';
|
|
8
7
|
import path from 'path';
|
|
9
8
|
import os from 'os';
|
|
@@ -1252,20 +1251,51 @@ function extractConversationCore(composerId, outputPath, db) {
|
|
|
1252
1251
|
* @param {string} outputPath - 输出文件路径
|
|
1253
1252
|
* @param {string} [customDbPath] - 自定义数据库路径(可选,默认使用系统全局数据库)
|
|
1254
1253
|
*/
|
|
1255
|
-
export function extractConversationFromGlobalDb(composerId, outputPath, customDbPath = null) {
|
|
1254
|
+
export async function extractConversationFromGlobalDb(composerId, outputPath, customDbPath = null) {
|
|
1256
1255
|
const globalDbPath = customDbPath || getGlobalDbPath();
|
|
1257
1256
|
|
|
1258
1257
|
if (!fs.existsSync(globalDbPath)) {
|
|
1259
1258
|
throw new Error(`全局数据库不存在: ${globalDbPath}`);
|
|
1260
1259
|
}
|
|
1261
1260
|
|
|
1262
|
-
// 打开数据库
|
|
1263
|
-
const
|
|
1261
|
+
// 使用 sql.js 打开数据库
|
|
1262
|
+
const initSqlJs = (await import("sql.js")).default;
|
|
1263
|
+
const SQL = await initSqlJs();
|
|
1264
|
+
const buffer = fs.readFileSync(globalDbPath);
|
|
1265
|
+
const sqlDb = new SQL.Database(buffer);
|
|
1266
|
+
|
|
1267
|
+
// 创建兼容的包装器
|
|
1268
|
+
const db = {
|
|
1269
|
+
prepare: (sql) => {
|
|
1270
|
+
const stmt = sqlDb.prepare(sql);
|
|
1271
|
+
return {
|
|
1272
|
+
get: (...params) => {
|
|
1273
|
+
stmt.bind(params);
|
|
1274
|
+
if (stmt.step()) {
|
|
1275
|
+
const result = stmt.getAsObject();
|
|
1276
|
+
stmt.reset();
|
|
1277
|
+
return result;
|
|
1278
|
+
}
|
|
1279
|
+
stmt.reset();
|
|
1280
|
+
return undefined;
|
|
1281
|
+
},
|
|
1282
|
+
all: (...params) => {
|
|
1283
|
+
stmt.bind(params);
|
|
1284
|
+
const result = [];
|
|
1285
|
+
while (stmt.step()) {
|
|
1286
|
+
result.push(stmt.getAsObject());
|
|
1287
|
+
}
|
|
1288
|
+
stmt.reset();
|
|
1289
|
+
return result;
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1264
1294
|
|
|
1265
1295
|
try {
|
|
1266
1296
|
return extractConversationCore(composerId, outputPath, db);
|
|
1267
1297
|
} finally {
|
|
1268
|
-
|
|
1298
|
+
sqlDb.close();
|
|
1269
1299
|
}
|
|
1270
1300
|
}
|
|
1271
1301
|
|
package/index.js
CHANGED
|
@@ -8,11 +8,72 @@ import AdmZip from "adm-zip";
|
|
|
8
8
|
import fs, {readFileSync as readPackageJson} from "fs";
|
|
9
9
|
import path, {dirname} from "path";
|
|
10
10
|
import os from "os";
|
|
11
|
-
import sqlite3 from "better-sqlite3";
|
|
12
11
|
import zlib from "zlib";
|
|
13
12
|
import {fileURLToPath} from 'url';
|
|
14
13
|
import {exec} from 'child_process';
|
|
15
14
|
|
|
15
|
+
// ==================== 数据库引擎加载(直接使用 sql.js)====================
|
|
16
|
+
let dbEngine = null;
|
|
17
|
+
let dbEngineType = 'none';
|
|
18
|
+
let chatGrabAvailable = false;
|
|
19
|
+
let SQL = null; // 全局 SQL 实例
|
|
20
|
+
|
|
21
|
+
// 直接使用 sql.js(纯 JavaScript,无需编译,跨平台兼容)
|
|
22
|
+
try {
|
|
23
|
+
const initSqlJs = (await import("sql.js")).default;
|
|
24
|
+
SQL = await initSqlJs();
|
|
25
|
+
|
|
26
|
+
// 创建一个兼容 better-sqlite3 API 的包装器
|
|
27
|
+
dbEngine = class SqlJsDatabase {
|
|
28
|
+
constructor(filename, options = {}) {
|
|
29
|
+
this.filename = filename;
|
|
30
|
+
this.readonly = options.readonly || false;
|
|
31
|
+
|
|
32
|
+
// 读取数据库文件
|
|
33
|
+
const buffer = fs.readFileSync(filename);
|
|
34
|
+
this.db = new SQL.Database(buffer);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
prepare(sql) {
|
|
38
|
+
const stmt = this.db.prepare(sql);
|
|
39
|
+
return {
|
|
40
|
+
get: (...params) => {
|
|
41
|
+
stmt.bind(params);
|
|
42
|
+
if (stmt.step()) {
|
|
43
|
+
const result = stmt.getAsObject();
|
|
44
|
+
stmt.reset();
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
stmt.reset();
|
|
48
|
+
return undefined;
|
|
49
|
+
},
|
|
50
|
+
all: (...params) => {
|
|
51
|
+
stmt.bind(params);
|
|
52
|
+
const result = [];
|
|
53
|
+
while (stmt.step()) {
|
|
54
|
+
result.push(stmt.getAsObject());
|
|
55
|
+
}
|
|
56
|
+
stmt.reset();
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
close() {
|
|
63
|
+
this.db.close();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
dbEngineType = 'sql.js';
|
|
68
|
+
chatGrabAvailable = true;
|
|
69
|
+
console.error('✅ 使用 sql.js 引擎(纯 JavaScript,无需编译,跨平台兼容)');
|
|
70
|
+
console.error(' 对话抓取功能正常可用');
|
|
71
|
+
} catch (sqlJsError) {
|
|
72
|
+
console.error('❌ sql.js 加载失败,对话抓取功能将被禁用');
|
|
73
|
+
console.error(' 原因: ' + sqlJsError.message);
|
|
74
|
+
console.error(' 规则下载功能不受影响');
|
|
75
|
+
}
|
|
76
|
+
|
|
16
77
|
/**
|
|
17
78
|
* WARNING for STDIO mode:
|
|
18
79
|
* - Do NOT write to stdout (console.log)
|
|
@@ -582,8 +643,9 @@ function loadMarkdownFromFile(composerId) {
|
|
|
582
643
|
*/
|
|
583
644
|
async function generateMarkdownFromComposerData(composerId, db) {
|
|
584
645
|
try {
|
|
585
|
-
// 动态导入cursorConversationParser
|
|
586
|
-
const
|
|
646
|
+
// 动态导入cursorConversationParser(使用 import.meta.url 构建相对路径,确保在不同运行环境下都能找到)
|
|
647
|
+
const parserUrl = new URL('./cursorConversationParser.js', import.meta.url).href;
|
|
648
|
+
const parserModule = await import(parserUrl);
|
|
587
649
|
|
|
588
650
|
// 使用完整的解析器生成markdown
|
|
589
651
|
// 创建临时文件路径用于生成markdown
|
|
@@ -771,6 +833,15 @@ async function grabAndUploadConversations() {
|
|
|
771
833
|
logger.info('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
772
834
|
logger.info('开始抓取对话记录');
|
|
773
835
|
|
|
836
|
+
// 0. 检查数据库引擎是否可用
|
|
837
|
+
if (!chatGrabAvailable || !dbEngine) {
|
|
838
|
+
logger.warn('数据库引擎不可用,跳过对话抓取', {
|
|
839
|
+
chatGrabAvailable,
|
|
840
|
+
dbEngineType
|
|
841
|
+
});
|
|
842
|
+
return false;
|
|
843
|
+
}
|
|
844
|
+
|
|
774
845
|
// 1. 检查数据库文件是否存在
|
|
775
846
|
const dbPath = getCursorDbPath();
|
|
776
847
|
if (!fs.existsSync(dbPath)) {
|
|
@@ -778,13 +849,16 @@ async function grabAndUploadConversations() {
|
|
|
778
849
|
return false;
|
|
779
850
|
}
|
|
780
851
|
|
|
781
|
-
logger.info('找到Cursor数据库', {
|
|
852
|
+
logger.info('找到Cursor数据库', {
|
|
853
|
+
dbPath,
|
|
854
|
+
dbEngineType
|
|
855
|
+
});
|
|
782
856
|
|
|
783
857
|
let db = null;
|
|
784
858
|
|
|
785
859
|
try {
|
|
786
|
-
// 2.
|
|
787
|
-
db =
|
|
860
|
+
// 2. 打开数据库(使用智能选择的引擎)
|
|
861
|
+
db = new dbEngine(dbPath, { readonly: true });
|
|
788
862
|
|
|
789
863
|
// 3. 加载状态文件
|
|
790
864
|
const state = loadChatGrabState();
|
|
@@ -1642,8 +1716,10 @@ async function main() {
|
|
|
1642
1716
|
hostName: HOST_NAME,
|
|
1643
1717
|
osType: OS_TYPE,
|
|
1644
1718
|
availableTools: ['download_rule'],
|
|
1645
|
-
chatGrabEnabled:
|
|
1646
|
-
chatGrabDir: CHAT_GRAB_DIR
|
|
1719
|
+
chatGrabEnabled: chatGrabAvailable,
|
|
1720
|
+
chatGrabDir: CHAT_GRAB_DIR,
|
|
1721
|
+
dbEngineType: dbEngineType,
|
|
1722
|
+
...(chatGrabAvailable ? {} : { chatGrabDisabledReason: 'No database engine available' })
|
|
1647
1723
|
});
|
|
1648
1724
|
|
|
1649
1725
|
// 上报主机信息(异步执行,失败不影响启动)
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ACW工具集",
|
|
3
3
|
"description": "ACW平台工具集:智能下载规则到项目、初始化Common Admin模板项目",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.26",
|
|
5
5
|
"author": "邦道科技 - 产品技术中心",
|
|
6
6
|
"homepage": "https://www.npmjs.com/package/@bangdao-ai/acw-tools",
|
|
7
7
|
"repository": "https://www.npmjs.com/package/@bangdao-ai/acw-tools?activeTab=readme",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bangdao-ai/acw-tools",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP (Model Context Protocol) tools for ACW - download rules and initialize Common Admin projects",
|
|
6
6
|
"main": "index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"acw-tools": "index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"start:stdio": "node index.js"
|
|
11
|
+
"start:stdio": "node index.js",
|
|
12
|
+
"postinstall": "node -e \"let engine='none'; try { require('sql.js'); engine='sql.js'; console.log('✅ 数据库引擎: sql.js (纯JavaScript,无需编译,跨平台兼容)'); } catch(e2) { console.warn('⚠️ 无可用数据库引擎,对话抓取功能将被禁用'); }\""
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"mcp",
|
|
@@ -41,8 +42,8 @@
|
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@modelcontextprotocol/sdk": "^1.18.2",
|
|
43
44
|
"adm-zip": "^0.5.10",
|
|
44
|
-
"better-sqlite3": "11.10.0",
|
|
45
45
|
"node-fetch": "^3.3.2",
|
|
46
|
+
"sql.js": "^1.13.0",
|
|
46
47
|
"zod": "^3.25.76"
|
|
47
48
|
},
|
|
48
49
|
"files": [
|
|
@@ -50,6 +51,8 @@
|
|
|
50
51
|
"cursorConversationParser.js",
|
|
51
52
|
"manifest.json",
|
|
52
53
|
"README.md",
|
|
54
|
+
"WINDOWS_TROUBLESHOOTING.md",
|
|
55
|
+
"CHANGELOG.md",
|
|
53
56
|
"LICENSE"
|
|
54
57
|
]
|
|
55
58
|
}
|