@bangdao-ai/acw-tools 1.1.34 → 1.2.1-beta.1
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/cursorConversationParser.js +13 -36
- package/index.js +11 -50
- package/manifest.json +1 -1
- package/package.json +2 -2
- package/postinstall.js +53 -50
|
@@ -153,6 +153,12 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
+
// 新增: 记录 cursorCommands (只在数组不为空时添加)
|
|
157
|
+
const cursorCommands = bubble.context?.cursorCommands;
|
|
158
|
+
if (cursorCommands && Array.isArray(cursorCommands) && cursorCommands.length > 0) {
|
|
159
|
+
execution.cursorCommands = cursorCommands.map(cmd => cmd.filename).filter(Boolean);
|
|
160
|
+
}
|
|
161
|
+
|
|
156
162
|
additionalInfo.performance.executions.push(execution);
|
|
157
163
|
|
|
158
164
|
} else if (bubbleType === 2) {
|
|
@@ -1258,44 +1264,14 @@ export async function extractConversationFromGlobalDb(composerId, outputPath, cu
|
|
|
1258
1264
|
throw new Error(`全局数据库不存在: ${globalDbPath}`);
|
|
1259
1265
|
}
|
|
1260
1266
|
|
|
1261
|
-
// 使用
|
|
1262
|
-
const
|
|
1263
|
-
const
|
|
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
|
-
};
|
|
1267
|
+
// 使用 better-sqlite3 打开数据库
|
|
1268
|
+
const Database = (await import("better-sqlite3")).default;
|
|
1269
|
+
const db = new Database(globalDbPath, { readonly: true });
|
|
1294
1270
|
|
|
1295
1271
|
try {
|
|
1296
1272
|
return extractConversationCore(composerId, outputPath, db);
|
|
1297
1273
|
} finally {
|
|
1298
|
-
|
|
1274
|
+
db.close();
|
|
1299
1275
|
}
|
|
1300
1276
|
}
|
|
1301
1277
|
|
|
@@ -1313,14 +1289,15 @@ export function extractConversationFromGlobalDbWithConnection(composerId, output
|
|
|
1313
1289
|
* 列出所有可用的composer
|
|
1314
1290
|
* @param {string} [customDbPath] - 自定义数据库路径(可选,默认使用系统全局数据库)
|
|
1315
1291
|
*/
|
|
1316
|
-
export function listAllComposers(customDbPath = null) {
|
|
1292
|
+
export async function listAllComposers(customDbPath = null) {
|
|
1317
1293
|
const globalDbPath = customDbPath || getGlobalDbPath();
|
|
1318
1294
|
|
|
1319
1295
|
if (!fs.existsSync(globalDbPath)) {
|
|
1320
1296
|
throw new Error(`全局数据库不存在: ${globalDbPath}`);
|
|
1321
1297
|
}
|
|
1322
1298
|
|
|
1323
|
-
const
|
|
1299
|
+
const Database = (await import("better-sqlite3")).default;
|
|
1300
|
+
const db = new Database(globalDbPath, { readonly: true });
|
|
1324
1301
|
|
|
1325
1302
|
try {
|
|
1326
1303
|
// 查询最近30天内lastUpdatedAt不为空的composerData
|
package/index.js
CHANGED
|
@@ -18,65 +18,26 @@ const FETCH_TIMEOUT_UPLOAD = 30000; // 上传请求超时时间(30秒)
|
|
|
18
18
|
const FETCH_TIMEOUT_TELEMETRY = 30000; // 遥测上报超时时间(30秒)
|
|
19
19
|
const RETRY_BASE_DELAY = 2000; // 重试基础延迟(2秒)
|
|
20
20
|
|
|
21
|
-
// ====================
|
|
21
|
+
// ==================== 数据库引擎加载(使用 better-sqlite3)====================
|
|
22
22
|
let dbEngine = null;
|
|
23
23
|
let dbEngineType = 'none';
|
|
24
24
|
let chatGrabAvailable = false;
|
|
25
|
-
let SQL = null; // 全局 SQL 实例
|
|
26
25
|
|
|
27
|
-
//
|
|
26
|
+
// 使用 better-sqlite3(原生模块,性能更好)
|
|
28
27
|
try {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// 动态导入 better-sqlite3
|
|
29
|
+
const Database = (await import("better-sqlite3")).default;
|
|
31
30
|
|
|
32
|
-
//
|
|
33
|
-
dbEngine =
|
|
34
|
-
constructor(filename, options = {}) {
|
|
35
|
-
this.filename = filename;
|
|
36
|
-
this.readonly = options.readonly || false;
|
|
37
|
-
|
|
38
|
-
// 读取数据库文件
|
|
39
|
-
const buffer = fs.readFileSync(filename);
|
|
40
|
-
this.db = new SQL.Database(buffer);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
prepare(sql) {
|
|
44
|
-
const stmt = this.db.prepare(sql);
|
|
45
|
-
return {
|
|
46
|
-
get: (...params) => {
|
|
47
|
-
stmt.bind(params);
|
|
48
|
-
if (stmt.step()) {
|
|
49
|
-
const result = stmt.getAsObject();
|
|
50
|
-
stmt.reset();
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
stmt.reset();
|
|
54
|
-
return undefined;
|
|
55
|
-
},
|
|
56
|
-
all: (...params) => {
|
|
57
|
-
stmt.bind(params);
|
|
58
|
-
const result = [];
|
|
59
|
-
while (stmt.step()) {
|
|
60
|
-
result.push(stmt.getAsObject());
|
|
61
|
-
}
|
|
62
|
-
stmt.reset();
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
close() {
|
|
69
|
-
this.db.close();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
31
|
+
// better-sqlite3 已经提供了完整的 API,直接使用
|
|
32
|
+
dbEngine = Database;
|
|
72
33
|
|
|
73
|
-
dbEngineType = '
|
|
34
|
+
dbEngineType = 'better-sqlite3';
|
|
74
35
|
chatGrabAvailable = true;
|
|
75
|
-
console.error('[OK] 使用
|
|
36
|
+
console.error('[OK] 使用 better-sqlite3 引擎(原生模块,性能优异)');
|
|
76
37
|
console.error(' 对话抓取功能正常可用');
|
|
77
|
-
} catch (
|
|
78
|
-
console.error('[ERROR]
|
|
79
|
-
console.error(' 原因: ' +
|
|
38
|
+
} catch (betterSqlite3Error) {
|
|
39
|
+
console.error('[ERROR] better-sqlite3 加载失败,对话抓取功能将被禁用');
|
|
40
|
+
console.error(' 原因: ' + betterSqlite3Error.message);
|
|
80
41
|
console.error(' 规则下载功能不受影响');
|
|
81
42
|
}
|
|
82
43
|
|
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.2.1",
|
|
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.2.1-beta.1",
|
|
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",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@modelcontextprotocol/sdk": "^1.18.2",
|
|
44
44
|
"adm-zip": "^0.5.10",
|
|
45
|
+
"better-sqlite3": "^12.4.1",
|
|
45
46
|
"node-fetch": "^3.3.2",
|
|
46
|
-
"sql.js": "^1.13.0",
|
|
47
47
|
"zod": "^3.25.76"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
package/postinstall.js
CHANGED
|
@@ -2,62 +2,65 @@
|
|
|
2
2
|
// postinstall 脚本:安装后检查,即使出错也不应该阻止安装
|
|
3
3
|
// 使用 try-catch 包裹整个脚本,确保任何错误都不会导致安装失败
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
// npm postinstall 脚本执行时,process.cwd() 就是包的安装目录
|
|
11
|
-
const __dirname = process.cwd();
|
|
12
|
-
|
|
13
|
-
// 读取版本号
|
|
14
|
-
let mcpVersion = 'unknown';
|
|
9
|
+
(async () => {
|
|
15
10
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
// 获取当前目录(package.json所在目录)
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
|
|
15
|
+
// 读取版本号
|
|
16
|
+
let mcpVersion = 'unknown';
|
|
17
|
+
try {
|
|
18
|
+
const pkgPath = path.join(__dirname, 'package.json');
|
|
19
|
+
if (fs.existsSync(pkgPath)) {
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
21
|
+
mcpVersion = pkg.version || 'unknown';
|
|
22
|
+
}
|
|
23
|
+
} catch (e) {
|
|
24
|
+
// 忽略错误,使用默认值
|
|
20
25
|
}
|
|
21
|
-
} catch (e) {
|
|
22
|
-
// 忽略错误,使用默认值
|
|
23
|
-
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
console.log('ACW Tools MCP 安装后检查开始...');
|
|
28
|
+
console.log('MCP 版本:', mcpVersion);
|
|
29
|
+
console.log('Node.js 版本:', process.version);
|
|
30
|
+
console.log('平台:', process.platform);
|
|
31
|
+
console.log('架构:', process.arch);
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
let engine = 'none';
|
|
34
|
+
let errorDetails = null;
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
try {
|
|
37
|
+
console.log('正在检查 better-sqlite3 依赖...');
|
|
38
|
+
const { default: Database } = await import('better-sqlite3');
|
|
39
|
+
console.log('[OK] better-sqlite3 模块加载成功');
|
|
40
|
+
engine = 'better-sqlite3';
|
|
41
|
+
console.log('[OK] 数据库引擎: better-sqlite3 (原生模块,性能优异)');
|
|
42
|
+
console.log('[OK] 对话抓取功能已启用');
|
|
43
|
+
} catch (e1) {
|
|
44
|
+
errorDetails = e1;
|
|
45
|
+
console.warn('[WARN] better-sqlite3 模块加载失败');
|
|
46
|
+
console.warn(' 错误类型:', e1.name);
|
|
47
|
+
console.warn(' 错误消息:', e1.message);
|
|
48
|
+
if (e1.code) {
|
|
49
|
+
console.warn(' 错误代码:', e1.code);
|
|
50
|
+
}
|
|
51
|
+
if (e1.stack) {
|
|
52
|
+
const lines = e1.stack.split('\n');
|
|
53
|
+
console.warn(' 堆栈信息:', lines.slice(0, 3).join('\n'));
|
|
54
|
+
}
|
|
55
|
+
console.warn('[WARN] 无可用数据库引擎,对话抓取功能将被禁用');
|
|
56
|
+
console.warn('提示: 规则下载功能不受影响,仍可正常使用');
|
|
48
57
|
}
|
|
49
|
-
if (e1.stack) {
|
|
50
|
-
const lines = e1.stack.split('\n');
|
|
51
|
-
console.warn(' 堆栈信息:', lines.slice(0, 3).join('\n'));
|
|
52
|
-
}
|
|
53
|
-
console.warn('[WARN] 无可用数据库引擎,对话抓取功能将被禁用');
|
|
54
|
-
console.warn('提示: 规则下载功能不受影响,仍可正常使用');
|
|
55
|
-
}
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
} catch (error) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
59
|
+
console.log('安装后检查完成');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// 捕获所有未预期的错误,确保不会导致安装失败
|
|
62
|
+
console.warn('[WARN] postinstall 脚本执行出错,但不影响安装:', error.message);
|
|
63
|
+
// 不抛出错误,让安装继续
|
|
64
|
+
}
|
|
65
|
+
})();
|
|
63
66
|
|