@becrafter/prompt-manager 0.1.10 → 0.1.12
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/env.example
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@becrafter/prompt-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Remote MCP Server for managing prompts",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"test:server:integration": "cd packages/server && npm run test:integration",
|
|
49
49
|
"test:e2e": "node test/e2e/test-packaged-app.js",
|
|
50
50
|
"test:upload": "node test/integration/test_upload.js",
|
|
51
|
-
"test:install": "node scripts/test-install.js",
|
|
51
|
+
"test:install": "cd packages/admin-ui && npm install && npm run build && cd - && node scripts/test-install.js",
|
|
52
52
|
"lint": "cd packages/server && npm run lint",
|
|
53
53
|
"lint:check": "cd packages/server && npm run lint:check",
|
|
54
54
|
"format": "cd packages/server && npm run format",
|
package/packages/server/app.js
CHANGED
|
@@ -104,8 +104,8 @@ async function sendIndexHtml(req, res) {
|
|
|
104
104
|
// 从 adminUiRoot 中提取 asar 文件路径和相对路径
|
|
105
105
|
const asarPathMatch = adminUiRoot.match(/^(.*?\.asar)(\/.*)?$/);
|
|
106
106
|
const asarFilePath = asarPathMatch ? asarPathMatch[1] : adminUiRoot.replace(/\/.*$/, '.asar');
|
|
107
|
-
const relativePathInAsar = asarPathMatch && asarPathMatch[2] ? asarPathMatch[2].substring(1) : 'web';
|
|
108
|
-
const indexPath = path.posix.join(relativePathInAsar, '
|
|
107
|
+
const relativePathInAsar = asarPathMatch && asarPathMatch[2] ? asarPathMatch[2].substring(1) : 'packages/web';
|
|
108
|
+
const indexPath = path.posix.join(relativePathInAsar, 'admin.html');
|
|
109
109
|
|
|
110
110
|
// 检查文件是否存在
|
|
111
111
|
const stat = asar.statFile(asarFilePath, indexPath);
|
|
@@ -121,7 +121,17 @@ async function sendIndexHtml(req, res) {
|
|
|
121
121
|
res.status(500).send('Internal Server Error');
|
|
122
122
|
}
|
|
123
123
|
} else {
|
|
124
|
-
|
|
124
|
+
// 优先查找 index.html,如果不存在则使用 admin.html
|
|
125
|
+
const indexPath = path.join(adminUiRoot, 'index.html');
|
|
126
|
+
const adminPath = path.join(adminUiRoot, 'admin.html');
|
|
127
|
+
|
|
128
|
+
if (fs.existsSync(indexPath)) {
|
|
129
|
+
res.sendFile(indexPath);
|
|
130
|
+
} else if (fs.existsSync(adminPath)) {
|
|
131
|
+
res.sendFile(adminPath);
|
|
132
|
+
} else {
|
|
133
|
+
res.status(404).send('Admin UI not found');
|
|
134
|
+
}
|
|
125
135
|
}
|
|
126
136
|
}
|
|
127
137
|
|
|
@@ -121,7 +121,7 @@ export class Config {
|
|
|
121
121
|
|
|
122
122
|
// 其他配置
|
|
123
123
|
this.serverName = process.env.MCP_SERVER_NAME || 'prompt-manager';
|
|
124
|
-
this.serverVersion = process.env.MCP_SERVER_VERSION || '0.1.
|
|
124
|
+
this.serverVersion = process.env.MCP_SERVER_VERSION || '0.1.12';
|
|
125
125
|
this.logLevel = process.env.LOG_LEVEL || 'info';
|
|
126
126
|
this.maxPrompts = parseInt(process.env.MAX_PROMPTS) || 1000;
|
|
127
127
|
this.recursiveScan = process.env.RECURSIVE_SCAN !== 'false'; // 默认启用递归扫描
|
|
@@ -356,18 +356,18 @@ export class Util {
|
|
|
356
356
|
const __filename = fileURLToPath(import.meta.url);
|
|
357
357
|
const __dirname = path.dirname(__filename);
|
|
358
358
|
const devWebPath = path.join(__dirname, '..', 'web');
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
if (this._pathExistsSync(devWebPath)) {
|
|
361
361
|
return devWebPath;
|
|
362
362
|
}
|
|
363
|
-
|
|
364
|
-
//
|
|
363
|
+
|
|
364
|
+
// 在 npm 包环境中,优先查找 packages/web(编译后的)
|
|
365
365
|
const projectRoot = path.resolve(__dirname, '../../..');
|
|
366
|
-
const
|
|
367
|
-
if (this._pathExistsSync(
|
|
368
|
-
return
|
|
366
|
+
const webPath = path.join(projectRoot, 'packages', 'web');
|
|
367
|
+
if (this._pathExistsSync(webPath)) {
|
|
368
|
+
return webPath;
|
|
369
369
|
}
|
|
370
|
-
|
|
370
|
+
|
|
371
371
|
// 返回默认路径
|
|
372
372
|
return devWebPath;
|
|
373
373
|
};
|