@becrafter/prompt-manager 0.0.19 → 0.1.2

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 (104) hide show
  1. package/README.md +145 -234
  2. package/app/desktop/assets/app.1.png +0 -0
  3. package/app/desktop/assets/app.png +0 -0
  4. package/app/desktop/assets/icons/icon.icns +0 -0
  5. package/app/desktop/assets/icons/icon.ico +0 -0
  6. package/app/desktop/assets/icons/icon.png +0 -0
  7. package/app/desktop/assets/icons/tray.png +0 -0
  8. package/app/desktop/assets/tray.1.png +0 -0
  9. package/app/desktop/assets/tray.png +0 -0
  10. package/app/desktop/main.js +27 -0
  11. package/app/desktop/package-lock.json +201 -4
  12. package/app/desktop/package.json +23 -29
  13. package/app/desktop/src/services/module-loader.js +43 -22
  14. package/app/desktop/src/services/runtime-manager.js +172 -23
  15. package/app/desktop/src/services/update-manager.js +6 -7
  16. package/app/desktop/src/ui/admin-window-manager.js +757 -0
  17. package/app/desktop/src/ui/splash-manager.js +253 -0
  18. package/app/desktop/src/ui/tray-manager.js +8 -24
  19. package/app/desktop/src/utils/icon-manager.js +39 -47
  20. package/app/desktop/src/utils/resource-paths.js +0 -23
  21. package/app/desktop/src/utils/resource-sync.js +260 -0
  22. package/app/desktop/src/utils/runtime-sync.js +241 -0
  23. package/examples/prompts/recommend/human_3-0_growth_diagnostic_coach_prompt.yaml +105 -0
  24. package/package.json +16 -13
  25. package/packages/admin-ui/.babelrc +3 -0
  26. package/packages/admin-ui/admin.html +237 -4784
  27. package/packages/admin-ui/css/main.css +2592 -0
  28. package/packages/admin-ui/css/recommended-prompts.css +610 -0
  29. package/packages/admin-ui/package-lock.json +6973 -0
  30. package/packages/admin-ui/package.json +36 -0
  31. package/packages/admin-ui/src/codemirror.js +53 -0
  32. package/packages/admin-ui/src/index.js +3188 -0
  33. package/packages/admin-ui/webpack.config.js +76 -0
  34. package/packages/resources/tools/chrome-devtools/README.md +310 -0
  35. package/packages/resources/tools/chrome-devtools/chrome-devtools.tool.js +1703 -0
  36. package/packages/resources/tools/file-reader/README.md +289 -0
  37. package/packages/resources/tools/file-reader/file-reader.tool.js +1545 -0
  38. package/packages/resources/tools/filesystem/README.md +359 -0
  39. package/packages/resources/tools/filesystem/filesystem.tool.js +514 -160
  40. package/packages/resources/tools/ollama-remote/README.md +192 -0
  41. package/packages/resources/tools/ollama-remote/ollama-remote.tool.js +421 -0
  42. package/packages/resources/tools/pdf-reader/README.md +236 -0
  43. package/packages/resources/tools/pdf-reader/pdf-reader.tool.js +565 -0
  44. package/packages/resources/tools/playwright/README.md +306 -0
  45. package/packages/resources/tools/playwright/playwright.tool.js +1186 -0
  46. package/packages/resources/tools/todolist/README.md +394 -0
  47. package/packages/resources/tools/todolist/todolist.tool.js +1312 -0
  48. package/packages/server/README.md +142 -0
  49. package/packages/server/api/admin.routes.js +42 -11
  50. package/packages/server/api/surge.routes.js +43 -0
  51. package/packages/server/app.js +119 -14
  52. package/packages/server/index.js +39 -0
  53. package/packages/server/mcp/mcp.server.js +324 -105
  54. package/packages/server/mcp/sequential-thinking.handler.js +318 -0
  55. package/packages/server/mcp/think-plan.handler.js +274 -0
  56. package/packages/server/middlewares/auth.middleware.js +6 -0
  57. package/packages/server/package.json +51 -0
  58. package/packages/server/server.js +37 -1
  59. package/packages/server/toolm/index.js +9 -0
  60. package/packages/server/toolm/package-installer.service.js +267 -0
  61. package/packages/server/toolm/test-tools.js +264 -0
  62. package/packages/server/toolm/tool-context.service.js +334 -0
  63. package/packages/server/toolm/tool-dependency.service.js +168 -0
  64. package/packages/server/toolm/tool-description-generator-optimized.service.js +375 -0
  65. package/packages/server/toolm/tool-description-generator.service.js +312 -0
  66. package/packages/server/toolm/tool-environment.service.js +200 -0
  67. package/packages/server/toolm/tool-execution.service.js +277 -0
  68. package/packages/server/toolm/tool-loader.service.js +219 -0
  69. package/packages/server/toolm/tool-logger.service.js +223 -0
  70. package/packages/server/toolm/tool-manager.handler.js +65 -0
  71. package/packages/server/toolm/tool-manual-generator.service.js +389 -0
  72. package/packages/server/toolm/tool-mode-handlers.service.js +224 -0
  73. package/packages/server/toolm/tool-storage.service.js +111 -0
  74. package/packages/server/toolm/tool-sync.service.js +138 -0
  75. package/packages/server/toolm/tool-utils.js +20 -0
  76. package/packages/server/toolm/tool-yaml-parser.service.js +81 -0
  77. package/packages/server/toolm/validate-system.js +421 -0
  78. package/packages/server/utils/config.js +49 -5
  79. package/packages/server/utils/util.js +65 -10
  80. package/scripts/build-icons.js +99 -69
  81. package/scripts/build.sh +57 -0
  82. package/scripts/surge/CNAME +1 -0
  83. package/scripts/surge/README.md +47 -0
  84. package/scripts/surge/package-lock.json +34 -0
  85. package/scripts/surge/package.json +20 -0
  86. package/scripts/surge/sync-to-surge.js +151 -0
  87. package/app/desktop/assets/icons/icon_1024x1024.png +0 -0
  88. package/app/desktop/assets/icons/icon_128x128.png +0 -0
  89. package/app/desktop/assets/icons/icon_16x16.png +0 -0
  90. package/app/desktop/assets/icons/icon_24x24.png +0 -0
  91. package/app/desktop/assets/icons/icon_256x256.png +0 -0
  92. package/app/desktop/assets/icons/icon_32x32.png +0 -0
  93. package/app/desktop/assets/icons/icon_48x48.png +0 -0
  94. package/app/desktop/assets/icons/icon_512x512.png +0 -0
  95. package/app/desktop/assets/icons/icon_64x64.png +0 -0
  96. package/app/desktop/assets/icons/icon_96x96.png +0 -0
  97. package/packages/admin-ui/js/closebrackets.min.js +0 -8
  98. package/packages/admin-ui/js/codemirror.min.js +0 -8
  99. package/packages/admin-ui/js/js-yaml.min.js +0 -2
  100. package/packages/admin-ui/js/markdown.min.js +0 -8
  101. package/packages/resources/tools/index.js +0 -16
  102. package/packages/server/mcp/toolx.handler.js +0 -131
  103. package/scripts/icns-builder/package.json +0 -12
  104. /package/packages/server/mcp/{mcp.handler.js → prompt.handler.js} +0 -0
@@ -11,8 +11,9 @@ import toIco from 'to-ico';
11
11
  const __filename = fileURLToPath(import.meta.url);
12
12
  const __dirname = path.dirname(__filename);
13
13
 
14
- // 图标文件路径
15
- const sourceIcon = path.join(__dirname, '..', 'app', 'desktop', 'assets', 'icons', 'icon.png');
14
+ // 图标源文件路径
15
+ const appSourceIcon = path.join(__dirname, '..', 'app', 'desktop', 'assets', 'app.png');
16
+ const traySourceIcon = path.join(__dirname, '..', 'app', 'desktop', 'assets', 'tray.png');
16
17
  const assetsDir = path.join(__dirname, '..', 'app', 'desktop', 'assets', 'icons');
17
18
 
18
19
  // 确保 assets 目录存在
@@ -20,86 +21,115 @@ if (!fs.existsSync(assetsDir)) {
20
21
  fs.mkdirSync(assetsDir, { recursive: true });
21
22
  }
22
23
 
23
- // macOS 图标尺寸
24
- const macSizes = [16, 32, 64, 128, 256, 512, 1024];
25
-
26
- // Windows 图标尺寸
27
- const winSizes = [16, 24, 32, 48, 64, 96, 128, 256];
28
-
29
- // 为 macOS 创建不同尺寸的图标
30
- console.log('Creating macOS icons...');
31
- const macIconDir = path.join(assetsDir, 'icon.iconset');
32
- if (!fs.existsSync(macIconDir)) {
33
- fs.mkdirSync(macIconDir, { recursive: true });
24
+ // 检查源文件是否存在
25
+ if (!fs.existsSync(appSourceIcon)) {
26
+ console.error(`Error: App source icon not found at ${appSourceIcon}`);
27
+ process.exit(1);
34
28
  }
35
29
 
36
- for (const size of macSizes) {
37
- const filename = `icon_${size}x${size}.png`;
38
- const filepath = path.join(macIconDir, size === 512 ? 'icon_512x512@2x.png' : `icon_${size}x${size}.png`);
39
- console.log(` - ${filename}`);
40
- // 对于 512x512@2x 实际上是 1024x1024
41
- const actualSize = size === 512 ? 1024 : size;
42
- await sharp(sourceIcon).resize(actualSize, actualSize).toFile(filepath);
30
+ if (!fs.existsSync(traySourceIcon)) {
31
+ console.error(`Error: Tray source icon not found at ${traySourceIcon}`);
32
+ process.exit(1);
43
33
  }
44
34
 
45
- // Windows 创建不同尺寸的图标
46
- console.log('Creating Windows icons...');
47
- const winIconBuffers = [];
48
- for (const size of winSizes) {
49
- const filename = `icon_${size}x${size}.png`;
50
- const filepath = path.join(assetsDir, filename);
51
- console.log(` - ${filename}`);
52
- const buffer = await sharp(sourceIcon).resize(size, size).png({ compressionLevel: 9 }).toBuffer();
53
- fs.writeFileSync(filepath, buffer);
54
- // 保存前几个尺寸用于创建 ICO 文件,现在包括 256x256
55
- if (size == 256) {
56
- // 确保 buffer 是有效的 Buffer 对象
57
- if (Buffer.isBuffer(buffer) && buffer.length > 0) {
58
- winIconBuffers.push(buffer);
59
- } else {
60
- console.log(` - Skipping invalid buffer for size ${size}`);
35
+ async function buildIcons() {
36
+ try {
37
+ console.log('Found source icons:');
38
+ console.log(` - App icon: ${appSourceIcon}`);
39
+ console.log(` - Tray icon: ${traySourceIcon}`);
40
+
41
+ // macOS 图标尺寸
42
+ const macSizes = [16, 32, 64, 128, 256, 512, 1024];
43
+
44
+ // 创建托盘图标 (24x24)
45
+ console.log('Creating tray icon...');
46
+ const filename = `tray.png`;
47
+ const trayIconPath = path.join(assetsDir, filename);
48
+ console.log(` - ${filename}`);
49
+ await sharp(traySourceIcon).resize(24, 24).toFile(trayIconPath);
50
+
51
+
52
+ // 创建 PNG 图标
53
+ console.log('Creating PNG file for default...');
54
+ const iconFilename = `icon.png`;
55
+ const appIconPath = path.join(assetsDir, iconFilename);
56
+ console.log(` - ${iconFilename}`);
57
+ await sharp(appSourceIcon).resize(512, 512).toFile(appIconPath);
58
+
59
+
60
+ // 为 macOS 创建不同尺寸的应用图标
61
+ console.log('Creating macOS app icons...');
62
+ const macIconDir = path.join(assetsDir, 'app.iconset');
63
+ if (!fs.existsSync(macIconDir)) {
64
+ fs.mkdirSync(macIconDir, { recursive: true });
61
65
  }
62
- }
63
- }
64
66
 
65
- // 创建 ICNS 文件 (macOS) - 使用 iconutil 工具
66
- console.log('Creating ICNS file for macOS...');
67
- try {
68
- const icnsPath = path.join(assetsDir, 'icon.icns');
69
-
70
- // 使用 iconutil 创建 ICNS 文件
71
- const iconutil = spawn('iconutil', ['-c', 'icns', '-o', icnsPath, macIconDir]);
72
-
73
- iconutil.on('close', (code) => {
74
- if (code === 0) {
75
- console.log(' - icon.icns');
76
- // 清理临时文件
77
- fs.rmSync(macIconDir, { recursive: true, force: true });
78
- } else {
79
- console.log(' - Failed to create ICNS file with iconutil');
67
+ for (const size of macSizes) {
68
+ const filename = `icon_${size}x${size}.png`;
69
+ const filepath = path.join(macIconDir, size === 512 ? 'icon_512x512@2x.png' : `icon_${size}x${size}.png`);
70
+ console.log(` - ${filename}`);
71
+ // 对于 512x512@2x 实际上是 1024x1024
72
+ const actualSize = size === 512 ? 1024 : size;
73
+ await sharp(appSourceIcon).resize(actualSize, actualSize).toFile(filepath);
80
74
  }
81
- });
82
- } catch (error) {
83
- console.log(' - Failed to create ICNS file:', error.message, error.stack);
84
- }
85
75
 
86
- // 创建 ICO 文件 (Windows)
87
- console.log('Creating ICO file for Windows...');
88
- try {
89
- // 确保 winIconBuffers 不为空并且包含有效的缓冲区
90
- if (winIconBuffers.length > 0) {
91
- // 验证所有缓冲区都是有效的
92
- const validBuffers = winIconBuffers.filter(buffer => Buffer.isBuffer(buffer) && buffer.length > 0);
93
- if (validBuffers.length > 0) {
94
- const icoBuffer = await toIco(validBuffers);
76
+ // 创建 ICNS 文件 (macOS) - 使用 iconutil 工具
77
+ console.log('Creating ICNS file for macOS...');
78
+ try {
79
+ const icnsPath = path.join(assetsDir, 'icon.icns');
80
+
81
+ // 使用 iconutil 创建 ICNS 文件
82
+ await new Promise((resolve, reject) => {
83
+ const iconutil = spawn('iconutil', ['-c', 'icns', '-o', icnsPath, macIconDir]);
84
+
85
+ iconutil.on('close', (code) => {
86
+ if (code === 0) {
87
+ console.log(' - icon.icns');
88
+ // 清理临时文件
89
+ fs.rmSync(macIconDir, { recursive: true, force: true });
90
+ resolve();
91
+ } else {
92
+ console.log(' - Failed to create ICNS file with iconutil');
93
+ resolve(); // 继续执行,不阻止其他图标生成
94
+ }
95
+ });
96
+
97
+ iconutil.on('error', (error) => {
98
+ console.log(' - Failed to create ICNS file:', error.message);
99
+ resolve(); // 继续执行,不阻止其他图标生成
100
+ });
101
+ });
102
+ } catch (error) {
103
+ console.log(' - Failed to create ICNS file:', error.message);
104
+ }
105
+
106
+
107
+ // 创建 ICO 文件 (Windows)
108
+ console.log('Creating ICO file for Windows...');
109
+ // Windows 图标常用尺寸
110
+ const winSizes = [16, 32, 48, 64, 128, 256];
111
+ const winIconBuffers = [];
112
+
113
+ for (const size of winSizes) {
114
+ const buffer = await sharp(appSourceIcon).resize(size, size).png().toBuffer();
115
+ winIconBuffers.push(buffer);
116
+ }
117
+
118
+ if (winIconBuffers.length > 0) {
119
+ console.log(' - icon.ico');
120
+ const icoBuffer = await toIco(winIconBuffers);
95
121
  const icoPath = path.join(assetsDir, 'icon.ico');
96
122
  fs.writeFileSync(icoPath, icoBuffer);
97
123
  } else {
98
124
  console.log(' - No valid buffers for ICO creation');
99
125
  }
126
+
127
+
128
+ console.log('Icon preparation completed.');
129
+ } catch (error) {
130
+ console.error('Error building icons:', error);
131
+ process.exit(1);
100
132
  }
101
- } catch (error) {
102
- console.log(' - Failed to create ICO file:', error.message, error.stack);
103
133
  }
104
134
 
105
- console.log('Icon preparation completed.');
135
+ buildIcons();
@@ -0,0 +1,57 @@
1
+ #!/bin/bash
2
+
3
+ # 设置 npm 镜像源
4
+ echo "Setting npm registry to https://registry.npmmirror.com"
5
+ npm config set registry https://registry.npmmirror.com
6
+
7
+ # 安装 app/desktop 依赖
8
+ echo "Installing dependencies for app/desktop..."
9
+ cd app/desktop
10
+ npm install
11
+ cd -
12
+
13
+ # 安装 packages/admin-ui 依赖
14
+ echo "Installing dependencies for packages/admin-ui..."
15
+ cd packages/admin-ui
16
+ npm install
17
+ cd -
18
+
19
+ # 清理缓存
20
+ echo "Cleaning up cache..."
21
+ rm -rf ~/Library/Application\ Support/@becrafter/prompt-desktop/prompt-manager
22
+
23
+ if [ "$1" != "dev" ]; then
24
+ # 构建 admin-ui
25
+ echo "Building admin-ui..."
26
+ npm run admin:build
27
+ fi
28
+
29
+ # 构建根目录环境
30
+ echo "Building root environment..."
31
+ npm install
32
+
33
+ # 根据参数执行 desktop 构建
34
+ echo "Building desktop app..."
35
+ case "$1" in
36
+ "dev")
37
+ npm run dev --prefix app/desktop
38
+ ;;
39
+ "build:all")
40
+ npm run build --prefix app/desktop -- --mac --win --linux
41
+ ;;
42
+ "build:mac")
43
+ npm run build --prefix app/desktop -- --mac
44
+ ;;
45
+ "build:win")
46
+ npm run build --prefix app/desktop -- --win
47
+ ;;
48
+ "build:linux")
49
+ npm run build --prefix app/desktop -- --linux
50
+ ;;
51
+ *)
52
+ npm run build --prefix app/desktop
53
+ ;;
54
+ esac
55
+
56
+ # 打印构建完成时间
57
+ echo "Build completed! Time: $(date +'%Y-%m-%d %H:%M:%S')"
@@ -0,0 +1 @@
1
+ becrafter.surge.sh
@@ -0,0 +1,47 @@
1
+ # Prompt Manager Surge同步脚本
2
+
3
+ 该脚本用于将本地提示词文件同步到Surge.sh静态托管服务,供Prompt Manager服务调用。
4
+
5
+ ## 功能特性
6
+
7
+ 1. 解析指定目录下的提示词YAML文件并生成JSON文件
8
+ 2. 生成提示词索引文件
9
+ 3. 发布到Surge.sh供外部访问
10
+
11
+ ## 使用方法
12
+
13
+ ### 安装依赖
14
+
15
+ ```bash
16
+ npm install
17
+ ```
18
+
19
+ ### 同步文件
20
+
21
+ ```bash
22
+ npm run build
23
+ # 或者
24
+ node sync-to-surge.js
25
+ ```
26
+
27
+ ### 同步并发布到Surge
28
+
29
+ ```bash
30
+ npm run deploy
31
+ # 或者
32
+ node sync-to-surge.js --deploy
33
+ ```
34
+
35
+ ## 文件结构
36
+
37
+ ```
38
+ dist/
39
+ └── assets/
40
+ ├── prompts.json (提示词索引)
41
+ └── prompts/ (提示词JSON文件,保持原有目录结构)
42
+ ```
43
+
44
+ ## API接口
45
+
46
+ - `/assets/prompts.json` - 获取所有提示词列表
47
+ - `/assets/prompts/{category}/{name}.json` - 获取JSON格式的提示词文件
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "prompts-surge-sync",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "prompts-surge-sync",
9
+ "version": "1.0.0",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "js-yaml": "^4.1.1"
13
+ }
14
+ },
15
+ "node_modules/argparse": {
16
+ "version": "2.0.1",
17
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
18
+ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
19
+ "license": "Python-2.0"
20
+ },
21
+ "node_modules/js-yaml": {
22
+ "version": "4.1.1",
23
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
24
+ "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
25
+ "license": "MIT",
26
+ "dependencies": {
27
+ "argparse": "^2.0.1"
28
+ },
29
+ "bin": {
30
+ "js-yaml": "bin/js-yaml.js"
31
+ }
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "prompts-surge-sync",
3
+ "version": "1.0.0",
4
+ "description": "Sync prompt files to Surge.sh for Prompt Manager",
5
+ "main": "sync-to-surge.js",
6
+ "scripts": {
7
+ "build": "rm -rf dist && node sync-to-surge.js",
8
+ "deploy": "node sync-to-surge.js --deploy",
9
+ "clean": "rm -rf dist"
10
+ },
11
+ "dependencies": {
12
+ "js-yaml": "^4.1.0"
13
+ },
14
+ "keywords": [
15
+ "prompt-manager",
16
+ "surge"
17
+ ],
18
+ "author": "Prompt Manager Team",
19
+ "license": "MIT"
20
+ }
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { execSync } = require('child_process');
6
+ const yaml = require('js-yaml');
7
+
8
+ // 源目录和目标目录
9
+ const SOURCE_DIR = path.join(__dirname, '../../examples/prompts');
10
+ const DIST_DIR = path.join(__dirname, './dist');
11
+ const ASSETS_DIR = path.join(DIST_DIR, './assets');
12
+ const PROMPTS_DIR = path.join(ASSETS_DIR, 'prompts');
13
+
14
+ /**
15
+ * 读取YAML文件并解析为JSON对象
16
+ * @param {string} filePath - YAML文件路径
17
+ * @returns {object} 解析后的对象
18
+ */
19
+ function readYamlFile(filePath) {
20
+ const content = fs.readFileSync(filePath, 'utf8');
21
+ return yaml.load(content);
22
+ }
23
+
24
+ /**
25
+ * 递归遍历目录,查找所有YAML文件
26
+ * @param {string} dir - 目录路径
27
+ * @param {string[]} fileList - 文件列表
28
+ * @returns {string[]} YAML文件路径列表
29
+ */
30
+ function walkDirectory(dir, fileList = []) {
31
+ const files = fs.readdirSync(dir);
32
+
33
+ files.forEach(file => {
34
+ const filePath = path.join(dir, file);
35
+ const stat = fs.statSync(filePath);
36
+
37
+ if (stat.isDirectory()) {
38
+ walkDirectory(filePath, fileList);
39
+ } else if (file.endsWith('.yaml') || file.endsWith('.yml')) {
40
+ fileList.push(filePath);
41
+ }
42
+ });
43
+
44
+ return fileList;
45
+ }
46
+
47
+ /**
48
+ * 确保目录存在,如果不存在则创建
49
+ * @param {string} dirPath - 目录路径
50
+ */
51
+ function ensureDirectoryExists(dirPath) {
52
+ if (!fs.existsSync(dirPath)) {
53
+ fs.mkdirSync(dirPath, { recursive: true });
54
+ }
55
+ }
56
+
57
+ /**
58
+ * 从源文件路径计算出相对于源目录的目标路径
59
+ * @param {string} sourceFilePath - 源文件路径
60
+ * @param {string} sourceDir - 源目录
61
+ * @param {string} targetDir - 目标目录
62
+ * @returns {string} 目标文件路径
63
+ */
64
+ function getTargetPath(sourceFilePath, sourceDir, targetDir) {
65
+ const relativePath = path.relative(sourceDir, sourceFilePath);
66
+ const fileName = path.basename(sourceFilePath, path.extname(sourceFilePath));
67
+ return path.join(targetDir, relativePath.replace(path.basename(sourceFilePath), `${fileName}.json`));
68
+ }
69
+
70
+ console.log('开始同步Prompt文件到Surge...');
71
+
72
+ // 创建assets目录
73
+ ensureDirectoryExists(ASSETS_DIR);
74
+ ensureDirectoryExists(PROMPTS_DIR);
75
+
76
+ // 查找所有YAML文件
77
+ const yamlFiles = walkDirectory(SOURCE_DIR);
78
+ console.log(`找到 ${yamlFiles.length} 个YAML文件`);
79
+
80
+ // 解析YAML文件并转换为JSON
81
+ const indexData = [];
82
+
83
+ for (const yamlFile of yamlFiles) {
84
+ try {
85
+ console.log(`正在处理: ${yamlFile}`);
86
+
87
+ // 读取并解析YAML文件
88
+ const yamlData = readYamlFile(yamlFile);
89
+
90
+ // 提取必要字段
91
+ const { name, description, tags = [] } = yamlData;
92
+
93
+ // 计算目标JSON文件路径
94
+ const targetPath = getTargetPath(yamlFile, SOURCE_DIR, PROMPTS_DIR);
95
+
96
+ // 确保目标目录存在
97
+ ensureDirectoryExists(path.dirname(targetPath));
98
+
99
+ // 写入JSON文件
100
+ fs.writeFileSync(targetPath, JSON.stringify(yamlData, null, 2), 'utf8');
101
+
102
+ // 添加到索引数据
103
+ const relativePath = path.relative(ASSETS_DIR, targetPath);
104
+ indexData.push({
105
+ name: name || path.basename(yamlFile, path.extname(yamlFile)),
106
+ description: description || '',
107
+ tags,
108
+ path: relativePath
109
+ });
110
+
111
+ console.log(`已生成: ${targetPath}`);
112
+ } catch (error) {
113
+ console.error(`处理文件 ${yamlFile} 时出错:`, error.message);
114
+ }
115
+ }
116
+
117
+ // 生成索引文件
118
+ const indexPath = path.join(ASSETS_DIR, 'prompts.json');
119
+ fs.writeFileSync(indexPath, JSON.stringify(indexData, null, 2), 'utf8');
120
+ console.log(`已生成索引文件: ${indexPath}`);
121
+
122
+ console.log('YAML文件解析和转换完成');
123
+
124
+ // 检查是否需要发布到Surge
125
+ const shouldDeploy = process.argv.includes('--deploy') || process.argv.includes('-d');
126
+
127
+ if (shouldDeploy) {
128
+ try {
129
+ console.log('开始发布到Surge...');
130
+
131
+ // 检查是否安装了surge
132
+ try {
133
+ execSync('which surge', { stdio: 'ignore' });
134
+ } catch (error) {
135
+ console.error('错误: 未找到surge命令,请先安装surge: npm install -g surge');
136
+ process.exit(1);
137
+ }
138
+
139
+ // 发布到Surge
140
+ const deployCommand = `surge ${DIST_DIR}`;
141
+ console.log(`执行命令: ${deployCommand}`);
142
+ execSync(deployCommand, { stdio: 'inherit' });
143
+
144
+ console.log('发布完成!');
145
+ } catch (error) {
146
+ console.error('发布到Surge时出错:', error.message);
147
+ process.exit(1);
148
+ }
149
+ } else {
150
+ console.log('同步完成。使用 --deploy 或 -d 参数发布到Surge。');
151
+ }
@@ -1,8 +0,0 @@
1
- /**
2
- * Minified by jsDelivr using Terser v5.37.0.
3
- * Original file: /npm/codemirror@5.65.2/addon/edit/closebrackets.js
4
- *
5
- * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6
- */
7
- !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}((function(e){var n={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},t=e.Pos;function r(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:n[t]}e.defineOption("autoCloseBrackets",!1,(function(n,t,o){o&&o!=e.Init&&(n.removeKeyMap(i),n.state.closeBrackets=null),t&&(a(r(t,"pairs")),n.state.closeBrackets=t,n.addKeyMap(i))}));var i={Backspace:function(n){var i=s(n);if(!i||n.getOption("disableInput"))return e.Pass;for(var a=r(i,"pairs"),o=n.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return e.Pass;var c=f(n,o[l].head);if(!c||a.indexOf(c)%2!=0)return e.Pass}for(l=o.length-1;l>=0;l--){var h=o[l].head;n.replaceRange("",t(h.line,h.ch-1),t(h.line,h.ch+1),"+delete")}},Enter:function(n){var t=s(n),i=t&&r(t,"explode");if(!i||n.getOption("disableInput"))return e.Pass;for(var a=n.listSelections(),o=0;o<a.length;o++){if(!a[o].empty())return e.Pass;var c=f(n,a[o].head);if(!c||i.indexOf(c)%2!=0)return e.Pass}n.operation((function(){var e=n.lineSeparator()||"\n";n.replaceSelection(e+e,null),l(n,-1),a=n.listSelections();for(var t=0;t<a.length;t++){var r=a[t].head.line;n.indentLine(r,null,!0),n.indentLine(r+1,null,!0)}}))}};function a(e){for(var n=0;n<e.length;n++){var t=e.charAt(n),r="'"+t+"'";i[r]||(i[r]=o(t))}}function o(n){return function(i){return function(n,i){var a=s(n);if(!a||n.getOption("disableInput"))return e.Pass;var o=r(a,"pairs"),f=o.indexOf(i);if(-1==f)return e.Pass;for(var u,d=r(a,"closeBefore"),p=r(a,"triples"),g=o.charAt(f+1)==i,v=n.listSelections(),b=f%2==0,P=0;P<v.length;P++){var S,k=v[P],y=k.head,O=n.getRange(y,t(y.line,y.ch+1));if(b&&!k.empty())S="surround";else if(!g&&b||O!=i)if(g&&y.ch>1&&p.indexOf(i)>=0&&n.getRange(t(y.line,y.ch-2),y)==i+i){if(y.ch>2&&/\bstring/.test(n.getTokenTypeAt(t(y.line,y.ch-2))))return e.Pass;S="addFour"}else if(g){var m=0==y.ch?" ":n.getRange(t(y.line,y.ch-1),y);if(e.isWordChar(O)||m==i||e.isWordChar(m))return e.Pass;S="both"}else{if(!b||!(0===O.length||/\s/.test(O)||d.indexOf(O)>-1))return e.Pass;S="both"}else S=g&&h(n,y)?"both":p.indexOf(i)>=0&&n.getRange(y,t(y.line,y.ch+3))==i+i+i?"skipThree":"skip";if(u){if(u!=S)return e.Pass}else u=S}var x=f%2?o.charAt(f-1):i,A=f%2?i:o.charAt(f+1);n.operation((function(){if("skip"==u)l(n,1);else if("skipThree"==u)l(n,3);else if("surround"==u){for(var e=n.getSelections(),t=0;t<e.length;t++)e[t]=x+e[t]+A;n.replaceSelections(e,"around"),e=n.listSelections().slice();for(t=0;t<e.length;t++)e[t]=c(e[t]);n.setSelections(e)}else"both"==u?(n.replaceSelection(x+A,null),n.triggerElectric(x+A),l(n,-1)):"addFour"==u&&(n.replaceSelection(x+x+x+x,"before"),l(n,1))}))}(i,n)}}function s(e){var n=e.state.closeBrackets;return!n||n.override?n:e.getModeAt(e.getCursor()).closeBrackets||n}function l(e,n){for(var t=[],r=e.listSelections(),i=0,a=0;a<r.length;a++){var o=r[a];o.head==e.getCursor()&&(i=a);var s=o.head.ch||n>0?{line:o.head.line,ch:o.head.ch+n}:{line:o.head.line-1};t.push({anchor:s,head:s})}e.setSelections(t,i)}function c(n){var r=e.cmpPos(n.anchor,n.head)>0;return{anchor:new t(n.anchor.line,n.anchor.ch+(r?-1:1)),head:new t(n.head.line,n.head.ch+(r?1:-1))}}function f(e,n){var r=e.getRange(t(n.line,n.ch-1),t(n.line,n.ch+1));return 2==r.length?r:null}function h(e,n){var r=e.getTokenAt(t(n.line,n.ch+1));return/\bstring/.test(r.type)&&r.start==n.ch&&(0==n.ch||!/\bstring/.test(e.getTokenTypeAt(n)))}a(n.pairs+"`")}));
8
- //# sourceMappingURL=/sm/4c04f9a75ec4213487615d8760c65b8304869cb18f8db3d9004e5ad64726888f.map