@becrafter/prompt-manager 0.1.31 → 0.2.3-alpha.7
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/package.json +20 -4
- package/packages/resources/tools/agent-browser/agent-browser.tool.js +18 -17
- package/packages/server/api/admin.routes.js +385 -0
- package/packages/server/mcp/prompt.handler.js +6 -6
- package/packages/server/server.js +13 -0
- package/packages/server/services/TerminalService.js +37 -17
- package/packages/server/services/skill-sync.service.js +223 -0
- package/packages/server/services/skills.service.js +731 -0
- package/packages/server/utils/config.js +8 -0
- package/packages/server/utils/util.js +27 -21
|
@@ -298,6 +298,14 @@ export class Config {
|
|
|
298
298
|
return path.join(this.getConfigHome(), 'configs', 'templates');
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
/**
|
|
302
|
+
* 获取技能配置目录
|
|
303
|
+
* @returns {string} 技能配置目录路径
|
|
304
|
+
*/
|
|
305
|
+
getSkillsDir() {
|
|
306
|
+
return path.join(this.getConfigHome(), 'skills');
|
|
307
|
+
}
|
|
308
|
+
|
|
301
309
|
/**
|
|
302
310
|
* 获取用户配置目录
|
|
303
311
|
* @returns {string} 用户配置目录路径
|
|
@@ -23,7 +23,7 @@ let _promptManager;
|
|
|
23
23
|
export class Util {
|
|
24
24
|
/**
|
|
25
25
|
* 检查并初始化prompts目录,如果目录为空则从示例目录复制内容
|
|
26
|
-
* @returns
|
|
26
|
+
* @returns {Promise<void>}
|
|
27
27
|
*/
|
|
28
28
|
async seedPromptsIfEmpty() {
|
|
29
29
|
try {
|
|
@@ -100,8 +100,8 @@ export class Util {
|
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* 生成文件唯一标识码
|
|
103
|
-
* @param {
|
|
104
|
-
* @returns
|
|
103
|
+
* @param {string} relativePath
|
|
104
|
+
* @returns {string}
|
|
105
105
|
*/
|
|
106
106
|
generateUniqueId(relativePath) {
|
|
107
107
|
const hash = crypto.createHash('sha256');
|
|
@@ -112,7 +112,7 @@ export class Util {
|
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* 从文件中读取提示词
|
|
115
|
-
* @returns
|
|
115
|
+
* @returns {Array<Object>}
|
|
116
116
|
*/
|
|
117
117
|
getPromptsFromFiles() {
|
|
118
118
|
const prompts = [];
|
|
@@ -253,8 +253,8 @@ export class Util {
|
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* 验证目录名称是否有效
|
|
256
|
-
* @param {
|
|
257
|
-
* @returns
|
|
256
|
+
* @param {string} name
|
|
257
|
+
* @returns {boolean}
|
|
258
258
|
*/
|
|
259
259
|
isValidGroupName(name) {
|
|
260
260
|
if (typeof name !== 'string') return false;
|
|
@@ -263,8 +263,8 @@ export class Util {
|
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* 验证目录名称
|
|
266
|
-
* @param {
|
|
267
|
-
* @returns
|
|
266
|
+
* @param {string} relativePath
|
|
267
|
+
* @returns {Array<string>|null}
|
|
268
268
|
*/
|
|
269
269
|
validateGroupPath(relativePath) {
|
|
270
270
|
if (!relativePath || typeof relativePath !== 'string') {
|
|
@@ -284,8 +284,8 @@ export class Util {
|
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
286
|
*
|
|
287
|
-
* @param {
|
|
288
|
-
* @returns
|
|
287
|
+
* @param {string} relativePath
|
|
288
|
+
* @returns {Object|null}
|
|
289
289
|
*/
|
|
290
290
|
resolveGroupDir(relativePath) {
|
|
291
291
|
const segments = this.validateGroupPath(relativePath);
|
|
@@ -300,8 +300,8 @@ export class Util {
|
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
302
|
* 获取目录元数据文件路径
|
|
303
|
-
* @param {
|
|
304
|
-
* @returns
|
|
303
|
+
* @param {string} dir
|
|
304
|
+
* @returns {string}
|
|
305
305
|
*/
|
|
306
306
|
getGroupMetaPath(dir) {
|
|
307
307
|
return path.join(dir, GROUP_META_FILENAME);
|
|
@@ -309,8 +309,8 @@ export class Util {
|
|
|
309
309
|
|
|
310
310
|
/**
|
|
311
311
|
* 读取目录元数据
|
|
312
|
-
* @param {
|
|
313
|
-
* @returns
|
|
312
|
+
* @param {string} dir
|
|
313
|
+
* @returns {Object}
|
|
314
314
|
*/
|
|
315
315
|
readGroupMeta(dir) {
|
|
316
316
|
try {
|
|
@@ -331,9 +331,9 @@ export class Util {
|
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
333
|
* 获取所有分组(直接从目录读取)
|
|
334
|
-
* @param {
|
|
335
|
-
* @param {
|
|
336
|
-
* @returns
|
|
334
|
+
* @param {string} baseDir
|
|
335
|
+
* @param {string} relativePath
|
|
336
|
+
* @returns {Array<Object>}
|
|
337
337
|
*/
|
|
338
338
|
buildGroupTree(baseDir, relativePath = '') {
|
|
339
339
|
const nodes = [];
|
|
@@ -397,11 +397,17 @@ export class Util {
|
|
|
397
397
|
|
|
398
398
|
// 检查是否是打包应用
|
|
399
399
|
if (isElectron && process.resourcesPath) {
|
|
400
|
+
const resourcesWebPath = path.join(process.resourcesPath, 'web');
|
|
401
|
+
if (this._pathExistsSync(resourcesWebPath)) {
|
|
402
|
+
console.log('📦 Using Electron resources path:', resourcesWebPath);
|
|
403
|
+
return resourcesWebPath;
|
|
404
|
+
}
|
|
405
|
+
|
|
400
406
|
const ourAppAsar = path.join(process.resourcesPath, 'app.asar');
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
console.log('📦 Using Electron ASAR path:',
|
|
404
|
-
return
|
|
407
|
+
const asarWebPath = path.join(process.resourcesPath, 'app.asar', 'web');
|
|
408
|
+
if (fs.existsSync(ourAppAsar) && this._pathExistsSync(asarWebPath)) {
|
|
409
|
+
console.log('📦 Using Electron ASAR path:', asarWebPath);
|
|
410
|
+
return asarWebPath;
|
|
405
411
|
}
|
|
406
412
|
}
|
|
407
413
|
|