@becrafter/prompt-manager 0.1.2 → 0.1.8
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 +304 -121
- package/app/cli/commands/start.js +28 -4
- package/app/cli/support/argv.js +6 -0
- package/env.example +32 -0
- package/package.json +36 -6
- package/packages/server/api/admin.routes.js +409 -1
- package/packages/server/api/open.routes.js +7 -2
- package/packages/server/api/tool.routes.js +479 -0
- package/packages/server/app.js +97 -25
- package/packages/server/configs/models/built-in/bigmodel.yaml +6 -0
- package/packages/server/configs/models/providers.yaml +50 -0
- package/packages/server/configs/templates/built-in/general-iteration.yaml +60 -0
- package/packages/server/configs/templates/built-in/general-optimize.yaml +63 -0
- package/packages/server/configs/templates/built-in/output-format-optimize.yaml +95 -0
- package/packages/server/mcp/heartbeat-patch.js +73 -0
- package/packages/server/mcp/mcp.server.js +63 -314
- package/packages/server/mcp/prompt.handler.js +26 -0
- package/packages/server/mcp/thinking-toolkit.handler.js +380 -0
- package/packages/server/package.json +35 -3
- package/packages/server/server.js +114 -12
- package/packages/server/services/TerminalService.js +498 -0
- package/packages/server/services/WebSocketService.js +484 -0
- package/packages/server/services/manager.js +38 -7
- package/packages/server/services/model.service.js +473 -0
- package/packages/server/services/optimization.service.js +457 -0
- package/packages/server/services/template.service.js +333 -0
- package/packages/server/toolm/tool-description-generator-optimized.service.js +5 -2
- package/packages/server/toolm/tool-sync.service.js +47 -3
- package/packages/server/utils/config.js +8 -1
- package/packages/server/utils/port-checker.js +63 -0
- package/packages/server/utils/util.js +27 -0
- package/IFLOW.md +0 -175
- package/app/desktop/assets/app.1.png +0 -0
- package/app/desktop/assets/app.png +0 -0
- package/app/desktop/assets/icons/icon.icns +0 -0
- package/app/desktop/assets/icons/icon.ico +0 -0
- package/app/desktop/assets/icons/icon.png +0 -0
- package/app/desktop/assets/icons/tray.png +0 -0
- package/app/desktop/assets/templates/about.html +0 -147
- package/app/desktop/assets/tray.1.png +0 -0
- package/app/desktop/assets/tray.png +0 -0
- package/app/desktop/main.js +0 -241
- package/app/desktop/package-lock.json +0 -5026
- package/app/desktop/package.json +0 -100
- package/app/desktop/preload.js +0 -7
- package/app/desktop/src/core/error-handler.js +0 -108
- package/app/desktop/src/core/event-emitter.js +0 -84
- package/app/desktop/src/core/logger.js +0 -108
- package/app/desktop/src/core/state-manager.js +0 -125
- package/app/desktop/src/services/module-loader.js +0 -214
- package/app/desktop/src/services/runtime-manager.js +0 -301
- package/app/desktop/src/services/service-manager.js +0 -169
- package/app/desktop/src/services/update-manager.js +0 -267
- package/app/desktop/src/ui/about-dialog-manager.js +0 -208
- package/app/desktop/src/ui/admin-window-manager.js +0 -757
- package/app/desktop/src/ui/splash-manager.js +0 -253
- package/app/desktop/src/ui/tray-manager.js +0 -186
- package/app/desktop/src/utils/icon-manager.js +0 -133
- package/app/desktop/src/utils/path-utils.js +0 -58
- package/app/desktop/src/utils/resource-paths.js +0 -49
- package/app/desktop/src/utils/resource-sync.js +0 -260
- package/app/desktop/src/utils/runtime-sync.js +0 -241
- package/app/desktop/src/utils/template-renderer.js +0 -284
- package/app/desktop/src/utils/version-utils.js +0 -59
- package/examples/prompts/developer/code-review.yaml +0 -32
- package/examples/prompts/developer/code_refactoring.yaml +0 -31
- package/examples/prompts/developer/doc-generator.yaml +0 -36
- package/examples/prompts/developer/error-code-fixer.yaml +0 -35
- package/examples/prompts/engineer/engineer-professional.yaml +0 -92
- package/examples/prompts/engineer/laowang-engineer.yaml +0 -132
- package/examples/prompts/engineer/nekomata-engineer.yaml +0 -123
- package/examples/prompts/engineer/ojousama-engineer.yaml +0 -124
- package/examples/prompts/generator/gen_3d_edu_webpage_html.yaml +0 -117
- package/examples/prompts/generator/gen_3d_webpage_html.yaml +0 -75
- package/examples/prompts/generator/gen_bento_grid_html.yaml +0 -112
- package/examples/prompts/generator/gen_html_web_page.yaml +0 -88
- package/examples/prompts/generator/gen_knowledge_card_html.yaml +0 -83
- package/examples/prompts/generator/gen_magazine_card_html.yaml +0 -82
- package/examples/prompts/generator/gen_mimeng_headline_title.yaml +0 -71
- package/examples/prompts/generator/gen_podcast_script.yaml +0 -69
- package/examples/prompts/generator/gen_prd_prototype_html.yaml +0 -175
- package/examples/prompts/generator/gen_summarize.yaml +0 -157
- package/examples/prompts/generator/gen_title.yaml +0 -119
- package/examples/prompts/generator/others/api_documentation.yaml +0 -32
- package/examples/prompts/generator/others/build_mcp_server.yaml +0 -26
- package/examples/prompts/generator/others/project_architecture.yaml +0 -31
- package/examples/prompts/generator/others/test_case_generator.yaml +0 -30
- package/examples/prompts/generator/others/writing_assistant.yaml +0 -72
- package/examples/prompts/recommend/human_3-0_growth_diagnostic_coach_prompt.yaml +0 -105
- package/examples/prompts/workflow/sixstep-workflow.yaml +0 -192
- package/packages/admin-ui/.babelrc +0 -3
- package/packages/admin-ui/admin.html +0 -412
- package/packages/admin-ui/css/codemirror-theme_xq-light.css +0 -43
- package/packages/admin-ui/css/codemirror.css +0 -344
- package/packages/admin-ui/css/main.css +0 -2592
- package/packages/admin-ui/css/recommended-prompts.css +0 -610
- package/packages/admin-ui/package-lock.json +0 -6973
- package/packages/admin-ui/package.json +0 -36
- package/packages/admin-ui/src/codemirror.js +0 -53
- package/packages/admin-ui/src/index.js +0 -3188
- package/packages/admin-ui/webpack.config.js +0 -76
- package/packages/server/toolm/test-tools.js +0 -264
- package/scripts/build-icons.js +0 -135
- package/scripts/build.sh +0 -57
- package/scripts/postinstall.js +0 -34
- package/scripts/surge/CNAME +0 -1
- package/scripts/surge/README.md +0 -47
- package/scripts/surge/package-lock.json +0 -34
- package/scripts/surge/package.json +0 -20
- package/scripts/surge/sync-to-surge.js +0 -151
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
3
|
-
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
4
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
5
|
-
|
|
6
|
-
module.exports = (env, argv) => {
|
|
7
|
-
const isProduction = argv.mode === 'production';
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
entry: './src/index.js',
|
|
11
|
-
|
|
12
|
-
output: {
|
|
13
|
-
path: path.resolve(__dirname, '..', 'web'),
|
|
14
|
-
filename: isProduction ? '[name].[contenthash].js' : '[name].js',
|
|
15
|
-
clean: true,
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
devServer: {
|
|
19
|
-
static: {
|
|
20
|
-
directory: path.join(__dirname, '.'),
|
|
21
|
-
},
|
|
22
|
-
compress: true,
|
|
23
|
-
port: 9000,
|
|
24
|
-
open: true,
|
|
25
|
-
hot: true,
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
module: {
|
|
29
|
-
rules: [
|
|
30
|
-
{
|
|
31
|
-
test: /\.css$/i,
|
|
32
|
-
use: [
|
|
33
|
-
isProduction ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
34
|
-
'css-loader'
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
test: /\.js$/,
|
|
39
|
-
enforce: 'pre',
|
|
40
|
-
use: ['source-map-loader'],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
44
|
-
type: 'asset/resource',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
48
|
-
type: 'asset/resource',
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
plugins: [
|
|
54
|
-
new HtmlWebpackPlugin({
|
|
55
|
-
template: './admin.html',
|
|
56
|
-
filename: 'index.html'
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
new CopyWebpackPlugin({
|
|
60
|
-
patterns: [
|
|
61
|
-
// 移除CSS文件的复制,因为现在使用MiniCssExtractPlugin处理
|
|
62
|
-
{ from: 'css/codemirror.css', to: 'css/' },
|
|
63
|
-
{ from: 'css/codemirror-theme_xq-light.css', to: 'css/' },
|
|
64
|
-
],
|
|
65
|
-
}),
|
|
66
|
-
|
|
67
|
-
new MiniCssExtractPlugin({
|
|
68
|
-
filename: 'css/[name].[contenthash].css',
|
|
69
|
-
}),
|
|
70
|
-
],
|
|
71
|
-
|
|
72
|
-
optimization: {
|
|
73
|
-
minimize: isProduction
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
};
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 工具系统测试文件
|
|
3
|
-
*
|
|
4
|
-
* 用于验证工具加载、工具管理等功能是否正常工作
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { toolLoaderService } from './tool-loader.service.js';
|
|
8
|
-
import { handleToolM } from './tool-manager.handler.js';
|
|
9
|
-
import { logger } from '../utils/logger.js';
|
|
10
|
-
|
|
11
|
-
// 测试工具加载服务
|
|
12
|
-
async function testToolLoader() {
|
|
13
|
-
console.log('\n========== 测试工具加载服务 ==========\n');
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
// 初始化工具加载器
|
|
17
|
-
console.log('1. 初始化工具加载器...');
|
|
18
|
-
await toolLoaderService.initialize();
|
|
19
|
-
console.log('✓ 工具加载器初始化成功');
|
|
20
|
-
|
|
21
|
-
// 获取所有工具列表
|
|
22
|
-
console.log('\n2. 获取所有工具列表...');
|
|
23
|
-
const tools = toolLoaderService.getAllTools();
|
|
24
|
-
console.log(`✓ 共加载 ${tools.length} 个工具:`);
|
|
25
|
-
tools.forEach(tool => {
|
|
26
|
-
console.log(` - ${tool.name}: ${tool.metadata.description || '无描述'}`);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// 检查 filesystem 工具是否存在
|
|
30
|
-
console.log('\n3. 检查 filesystem 工具是否存在...');
|
|
31
|
-
const hasFilesystem = toolLoaderService.hasTool('filesystem');
|
|
32
|
-
if (hasFilesystem) {
|
|
33
|
-
console.log('✓ filesystem 工具已加载');
|
|
34
|
-
|
|
35
|
-
// 获取 filesystem 工具详情
|
|
36
|
-
const filesystemTool = toolLoaderService.getTool('filesystem');
|
|
37
|
-
console.log(` - 元数据:`, filesystemTool.metadata);
|
|
38
|
-
} else {
|
|
39
|
-
console.log('✗ filesystem 工具未找到');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return true;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error('✗ 测试失败:', error.message);
|
|
45
|
-
console.error(error.stack);
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// 测试手册模式
|
|
51
|
-
async function testManualMode() {
|
|
52
|
-
console.log('\n========== 测试手册模式 (manual) ==========\n');
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const yamlInput = `tool: tool://filesystem
|
|
56
|
-
mode: manual`;
|
|
57
|
-
|
|
58
|
-
console.log('YAML 输入:');
|
|
59
|
-
console.log(yamlInput);
|
|
60
|
-
console.log('\n执行 handleToolM...');
|
|
61
|
-
|
|
62
|
-
const result = await handleToolM({ yaml: yamlInput });
|
|
63
|
-
|
|
64
|
-
console.log('\n✓ 手册模式执行成功');
|
|
65
|
-
console.log('返回结果类型:', result.content[0].type);
|
|
66
|
-
console.log('手册内容长度:', result.content[0].text.length, '字符');
|
|
67
|
-
console.log('\n手册内容预览(前 500 字符):');
|
|
68
|
-
console.log(result.content[0].text.substring(0, 500));
|
|
69
|
-
console.log('...\n');
|
|
70
|
-
|
|
71
|
-
return true;
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error('✗ 测试失败:', error.message);
|
|
74
|
-
console.error(error.stack);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 测试执行模式
|
|
80
|
-
async function testExecuteMode() {
|
|
81
|
-
console.log('\n========== 测试执行模式 (execute) ==========\n');
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const yamlInput = `tool: tool://filesystem
|
|
85
|
-
mode: execute
|
|
86
|
-
parameters:
|
|
87
|
-
method: list_allowed_directories`;
|
|
88
|
-
|
|
89
|
-
console.log('YAML 输入:');
|
|
90
|
-
console.log(yamlInput);
|
|
91
|
-
console.log('\n执行 handleToolM...');
|
|
92
|
-
|
|
93
|
-
const result = await handleToolM({ yaml: yamlInput });
|
|
94
|
-
|
|
95
|
-
console.log('\n✓ 执行模式测试成功');
|
|
96
|
-
console.log('返回结果:');
|
|
97
|
-
console.log(result.content[0].text);
|
|
98
|
-
|
|
99
|
-
return true;
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error('✗ 测试失败:', error.message);
|
|
102
|
-
console.error(error.stack);
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 测试配置模式
|
|
108
|
-
async function testConfigureMode() {
|
|
109
|
-
console.log('\n========== 测试配置模式 (configure) ==========\n');
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const yamlInput = `tool: tool://filesystem
|
|
113
|
-
mode: configure
|
|
114
|
-
parameters:
|
|
115
|
-
ALLOWED_DIRECTORIES: '["~/.prompt-manager", "/tmp"]'`;
|
|
116
|
-
|
|
117
|
-
console.log('YAML 输入:');
|
|
118
|
-
console.log(yamlInput);
|
|
119
|
-
console.log('\n执行 handleToolM...');
|
|
120
|
-
|
|
121
|
-
const result = await handleToolM({ yaml: yamlInput });
|
|
122
|
-
|
|
123
|
-
console.log('\n✓ 配置模式测试成功');
|
|
124
|
-
console.log('返回结果:');
|
|
125
|
-
console.log(result.content[0].text);
|
|
126
|
-
|
|
127
|
-
return true;
|
|
128
|
-
} catch (error) {
|
|
129
|
-
console.error('✗ 测试失败:', error.message);
|
|
130
|
-
console.error(error.stack);
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// 测试日志模式
|
|
136
|
-
async function testLogMode() {
|
|
137
|
-
console.log('\n========== 测试日志模式 (log) ==========\n');
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
const yamlInput = `tool: tool://filesystem
|
|
141
|
-
mode: log
|
|
142
|
-
parameters:
|
|
143
|
-
action: tail
|
|
144
|
-
lines: 50`;
|
|
145
|
-
|
|
146
|
-
console.log('YAML 输入:');
|
|
147
|
-
console.log(yamlInput);
|
|
148
|
-
console.log('\n执行 handleToolM...');
|
|
149
|
-
|
|
150
|
-
const result = await handleToolM({ yaml: yamlInput });
|
|
151
|
-
|
|
152
|
-
console.log('\n✓ 日志模式测试成功');
|
|
153
|
-
console.log('返回结果:');
|
|
154
|
-
console.log(result.content[0].text);
|
|
155
|
-
|
|
156
|
-
return true;
|
|
157
|
-
} catch (error) {
|
|
158
|
-
console.error('✗ 测试失败:', error.message);
|
|
159
|
-
console.error(error.stack);
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 测试错误处理
|
|
165
|
-
async function testErrorHandling() {
|
|
166
|
-
console.log('\n========== 测试错误处理 ==========\n');
|
|
167
|
-
|
|
168
|
-
try {
|
|
169
|
-
console.log('1. 测试不存在的工具...');
|
|
170
|
-
try {
|
|
171
|
-
const yamlInput = `tool: tool://nonexistent
|
|
172
|
-
mode: execute`;
|
|
173
|
-
await handleToolM({ yaml: yamlInput });
|
|
174
|
-
console.log('✗ 应该抛出错误但没有');
|
|
175
|
-
return false;
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.log('✓ 正确抛出错误:', error.message.split('\n')[0]);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
console.log('\n2. 测试缺少必需参数...');
|
|
181
|
-
try {
|
|
182
|
-
await handleToolM({});
|
|
183
|
-
console.log('✗ 应该抛出错误但没有');
|
|
184
|
-
return false;
|
|
185
|
-
} catch (error) {
|
|
186
|
-
console.log('✓ 正确抛出错误:', error.message);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
console.log('\n3. 测试无效的工具格式...');
|
|
190
|
-
try {
|
|
191
|
-
const yamlInput = `tool: filesystem
|
|
192
|
-
mode: execute`;
|
|
193
|
-
await handleToolM({ yaml: yamlInput });
|
|
194
|
-
console.log('✗ 应该抛出错误但没有');
|
|
195
|
-
return false;
|
|
196
|
-
} catch (error) {
|
|
197
|
-
console.log('✓ 正确抛出错误:', error.message.split('\n')[0]);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return true;
|
|
201
|
-
} catch (error) {
|
|
202
|
-
console.error('✗ 测试失败:', error.message);
|
|
203
|
-
console.error(error.stack);
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// 主测试函数
|
|
209
|
-
async function runAllTests() {
|
|
210
|
-
console.log('\n');
|
|
211
|
-
console.log('╔════════════════════════════════════════════════╗');
|
|
212
|
-
console.log('║ Prompt Manager 工具系统测试套件 ║');
|
|
213
|
-
console.log('╚════════════════════════════════════════════════╝');
|
|
214
|
-
|
|
215
|
-
const results = [];
|
|
216
|
-
|
|
217
|
-
// 运行所有测试
|
|
218
|
-
results.push({ name: '工具加载服务', passed: await testToolLoader() });
|
|
219
|
-
results.push({ name: '手册模式', passed: await testManualMode() });
|
|
220
|
-
results.push({ name: '执行模式', passed: await testExecuteMode() });
|
|
221
|
-
results.push({ name: '配置模式', passed: await testConfigureMode() });
|
|
222
|
-
results.push({ name: '日志模式', passed: await testLogMode() });
|
|
223
|
-
results.push({ name: '错误处理', passed: await testErrorHandling() });
|
|
224
|
-
|
|
225
|
-
// 输出测试总结
|
|
226
|
-
console.log('\n');
|
|
227
|
-
console.log('╔════════════════════════════════════════════════╗');
|
|
228
|
-
console.log('║ 测试结果总结 ║');
|
|
229
|
-
console.log('╚════════════════════════════════════════════════╝');
|
|
230
|
-
console.log('\n');
|
|
231
|
-
|
|
232
|
-
const passed = results.filter(r => r.passed).length;
|
|
233
|
-
const failed = results.filter(r => !r.passed).length;
|
|
234
|
-
|
|
235
|
-
results.forEach(result => {
|
|
236
|
-
const status = result.passed ? '✓ PASS' : '✗ FAIL';
|
|
237
|
-
console.log(`${status} - ${result.name}`);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
console.log('\n');
|
|
241
|
-
console.log(`总计: ${results.length} 个测试`);
|
|
242
|
-
console.log(`通过: ${passed} 个`);
|
|
243
|
-
console.log(`失败: ${failed} 个`);
|
|
244
|
-
console.log('\n');
|
|
245
|
-
|
|
246
|
-
if (failed === 0) {
|
|
247
|
-
console.log('🎉 所有测试通过!工具系统运行正常。');
|
|
248
|
-
} else {
|
|
249
|
-
console.log('⚠️ 部分测试失败,请检查错误信息。');
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return failed === 0;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// 运行测试
|
|
256
|
-
runAllTests()
|
|
257
|
-
.then(success => {
|
|
258
|
-
process.exit(success ? 0 : 1);
|
|
259
|
-
})
|
|
260
|
-
.catch(error => {
|
|
261
|
-
console.error('测试运行失败:', error);
|
|
262
|
-
process.exit(1);
|
|
263
|
-
});
|
|
264
|
-
|
package/scripts/build-icons.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import { spawn } from 'child_process';
|
|
7
|
-
import sharp from 'sharp';
|
|
8
|
-
import toIco from 'to-ico';
|
|
9
|
-
|
|
10
|
-
// 获取当前文件的目录
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
-
const __dirname = path.dirname(__filename);
|
|
13
|
-
|
|
14
|
-
// 图标源文件路径
|
|
15
|
-
const appSourceIcon = path.join(__dirname, '..', 'app', 'desktop', 'assets', 'app.png');
|
|
16
|
-
const traySourceIcon = path.join(__dirname, '..', 'app', 'desktop', 'assets', 'tray.png');
|
|
17
|
-
const assetsDir = path.join(__dirname, '..', 'app', 'desktop', 'assets', 'icons');
|
|
18
|
-
|
|
19
|
-
// 确保 assets 目录存在
|
|
20
|
-
if (!fs.existsSync(assetsDir)) {
|
|
21
|
-
fs.mkdirSync(assetsDir, { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// 检查源文件是否存在
|
|
25
|
-
if (!fs.existsSync(appSourceIcon)) {
|
|
26
|
-
console.error(`Error: App source icon not found at ${appSourceIcon}`);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!fs.existsSync(traySourceIcon)) {
|
|
31
|
-
console.error(`Error: Tray source icon not found at ${traySourceIcon}`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
|
|
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 });
|
|
65
|
-
}
|
|
66
|
-
|
|
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);
|
|
74
|
-
}
|
|
75
|
-
|
|
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);
|
|
121
|
-
const icoPath = path.join(assetsDir, 'icon.ico');
|
|
122
|
-
fs.writeFileSync(icoPath, icoBuffer);
|
|
123
|
-
} else {
|
|
124
|
-
console.log(' - No valid buffers for ICO creation');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
console.log('Icon preparation completed.');
|
|
129
|
-
} catch (error) {
|
|
130
|
-
console.error('Error building icons:', error);
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
buildIcons();
|
package/scripts/build.sh
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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')"
|
package/scripts/postinstall.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = path.dirname(__filename);
|
|
8
|
-
const projectRoot = path.resolve(__dirname, '..');
|
|
9
|
-
const exampleEnvPath = path.join(projectRoot, 'env.example');
|
|
10
|
-
const homeDir = os.homedir();
|
|
11
|
-
const configRoot = path.join(homeDir, '.prompt-manager');
|
|
12
|
-
const targetEnvPath = path.join(configRoot, '.env');
|
|
13
|
-
|
|
14
|
-
async function syncEnvExample() {
|
|
15
|
-
try {
|
|
16
|
-
const exampleContent = await fs.readFile(exampleEnvPath, 'utf8');
|
|
17
|
-
await fs.mkdir(configRoot, { recursive: true });
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
await fs.access(targetEnvPath);
|
|
21
|
-
// 如果用户已经有自定义配置,则不覆盖
|
|
22
|
-
return;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
// 文件不存在,继续写入
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
await fs.writeFile(targetEnvPath, exampleContent, 'utf8');
|
|
28
|
-
console.log(`已将默认环境变量写入 ${targetEnvPath}`);
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.warn('同步 env.example 到 ~/.prompt-manager/.env 失败:', error.message);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
syncEnvExample();
|
package/scripts/surge/CNAME
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
becrafter.surge.sh
|
package/scripts/surge/README.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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格式的提示词文件
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|