@becrafter/prompt-manager 0.0.18 → 0.0.19

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 (50) hide show
  1. package/IFLOW.md +175 -0
  2. package/README.md +1 -1
  3. package/app/desktop/assets/icons/icon.icns +0 -0
  4. package/app/desktop/assets/icons/icon.ico +0 -0
  5. package/app/desktop/assets/icons/icon_1024x1024.png +0 -0
  6. package/app/desktop/assets/icons/icon_128x128.png +0 -0
  7. package/app/desktop/assets/icons/icon_16x16.png +0 -0
  8. package/app/desktop/assets/icons/icon_24x24.png +0 -0
  9. package/app/desktop/assets/icons/icon_256x256.png +0 -0
  10. package/app/desktop/assets/icons/icon_32x32.png +0 -0
  11. package/app/desktop/assets/icons/icon_48x48.png +0 -0
  12. package/app/desktop/assets/icons/icon_512x512.png +0 -0
  13. package/app/desktop/assets/icons/icon_64x64.png +0 -0
  14. package/app/desktop/assets/icons/icon_96x96.png +0 -0
  15. package/app/desktop/assets/templates/about.html +147 -0
  16. package/app/desktop/main.js +160 -732
  17. package/app/desktop/package-lock.json +567 -534
  18. package/app/desktop/package.json +45 -10
  19. package/app/desktop/preload.js +7 -0
  20. package/app/desktop/src/core/error-handler.js +108 -0
  21. package/app/desktop/src/core/event-emitter.js +84 -0
  22. package/app/desktop/src/core/logger.js +108 -0
  23. package/app/desktop/src/core/state-manager.js +125 -0
  24. package/app/desktop/src/services/module-loader.js +193 -0
  25. package/app/desktop/src/services/runtime-manager.js +152 -0
  26. package/app/desktop/src/services/service-manager.js +169 -0
  27. package/app/desktop/src/services/update-manager.js +268 -0
  28. package/app/desktop/src/ui/about-dialog-manager.js +208 -0
  29. package/app/desktop/src/ui/tray-manager.js +202 -0
  30. package/app/desktop/src/utils/icon-manager.js +141 -0
  31. package/app/desktop/src/utils/path-utils.js +58 -0
  32. package/app/desktop/src/utils/resource-paths.js +72 -0
  33. package/app/desktop/src/utils/template-renderer.js +284 -0
  34. package/app/desktop/src/utils/version-utils.js +59 -0
  35. package/examples/prompts/engineer/engineer-professional.yaml +92 -0
  36. package/examples/prompts/engineer/laowang-engineer.yaml +132 -0
  37. package/examples/prompts/engineer/nekomata-engineer.yaml +123 -0
  38. package/examples/prompts/engineer/ojousama-engineer.yaml +124 -0
  39. package/examples/prompts/workflow/sixstep-workflow.yaml +192 -0
  40. package/package.json +9 -3
  41. package/packages/admin-ui/admin.html +1 -1
  42. package/packages/resources/tools/filesystem/filesystem.tool.js +184 -0
  43. package/packages/resources/tools/index.js +16 -0
  44. package/packages/server/mcp/mcp.handler.js +108 -9
  45. package/packages/server/mcp/mcp.server.js +126 -27
  46. package/packages/server/mcp/toolx.handler.js +131 -0
  47. package/packages/server/utils/config.js +1 -1
  48. package/scripts/build-icons.js +105 -0
  49. package/scripts/icns-builder/package.json +12 -0
  50. /package/app/desktop/assets/{icon.png → icons/icon.png} +0 -0
package/IFLOW.md ADDED
@@ -0,0 +1,175 @@
1
+ # Prompt Manager 项目概述
2
+
3
+ ## 项目简介
4
+
5
+ Prompt Manager 是一个基于 MCP(Model Context Protocol)协议的 Prompt 管理服务。它支持 HTTP 流式传输、提供 Web 管理界面和桌面应用,能够将静态提示词模板转换为可通过 API 调用的动态服务。
6
+
7
+ 核心特性包括:
8
+ - 完全兼容模型上下文协议(MCP)
9
+ - 基于 StreamableHTTP 协议优化的 HTTP 流式传输
10
+ - 自动发现子目录中的 prompt 文件
11
+ - 支持命令行参数和环境变量配置
12
+ - 内置 Electron 菜单应用,可一键启动/停止服务
13
+ - 提供 Web 管理界面,方便创建、编辑和管理提示词
14
+
15
+ ## 技术栈
16
+
17
+ - **后端**: Node.js (>=18.0.0), Express.js
18
+ - **前端**: 内置管理界面使用原生 JavaScript 和 Codemirror
19
+ - **协议**: MCP (Model Context Protocol)
20
+ - **桌面应用**: Electron
21
+ - **包管理**: npm/pnpm
22
+
23
+ ## 项目结构
24
+
25
+ ```
26
+ prompt-manager/
27
+ ├── app/
28
+ │ ├── cli/ # 命令行命令分发与共享工具
29
+ │ └── desktop/ # Electron 菜单应用
30
+ ├── packages/
31
+ │ ├── admin-ui/ # 内置管理后台静态资源
32
+ │ └── server/ # 服务端核心逻辑
33
+ ├── examples/
34
+ │ └── prompts/ # 随包示例提示词(首次启动会同步到 ~/.prompt-manager/prompts)
35
+ ├── scripts/ # 安装/维护脚本(如 env 同步)
36
+ ├── bin/ # 可执行入口
37
+ └── package.json
38
+ ```
39
+
40
+ ## 构建和运行
41
+
42
+ ### 安装依赖
43
+
44
+ 在项目根目录运行:
45
+
46
+ ```bash
47
+ npm install
48
+ ```
49
+
50
+ ### 启动开发服务器
51
+
52
+ ```bash
53
+ # 启动服务端开发服务器
54
+ npm run dev
55
+
56
+ # 启动桌面应用开发环境
57
+ npm run desktop:dev
58
+ ```
59
+
60
+ ### 构建桌面应用
61
+
62
+ ```bash
63
+ # 构建桌面应用安装包
64
+ npm run desktop:build
65
+ ```
66
+
67
+ ### 命令行使用
68
+
69
+ ```bash
70
+ # 使用默认配置启动
71
+ prompt-manager
72
+
73
+ # 指定提示词目录
74
+ prompt-manager --prompts-dir ./my-prompts
75
+
76
+ # 指定端口
77
+ prompt-manager --port 5621
78
+
79
+ # 显式使用 start/run 命令
80
+ prompt-manager start --port 6000
81
+ prompt-manager run --prompts-dir ./examples/prompts
82
+
83
+ # 获取帮助/版本信息
84
+ prompt-manager --help
85
+ prompt-manager --version
86
+ ```
87
+
88
+ ## 开发约定
89
+
90
+ 1. **代码风格**: 项目使用 ES6 模块系统,遵循标准的 JavaScript 编码规范。
91
+ 2. **目录结构**:
92
+ - `app/` 目录包含客户端相关代码(CLI 和桌面应用)
93
+ - `packages/` 目录包含服务端核心逻辑和管理界面
94
+ - `examples/` 目录包含示例提示词文件
95
+ 3. **配置管理**: 支持通过命令行参数、环境变量和配置文件进行配置。
96
+ 4. **日志记录**: 使用自定义 logger 模块进行日志记录。
97
+ 5. **错误处理**: 统一的错误处理机制,关键操作都有适当的错误捕获和处理。
98
+
99
+ ## API 接口
100
+
101
+ ### MCP 协议接口
102
+
103
+ 服务器实现了 MCP 协议,支持以下工具:
104
+
105
+ - `search_prompts`: 搜索提示词
106
+ - `get_prompt`: 获取指定提示词的完整内容
107
+ - `reload_prompts`: 重新加载所有提示词(暂未启用)
108
+
109
+ ### Web 管理接口
110
+
111
+ 1. **获取提示词列表**
112
+ ```
113
+ GET /prompts[?search=关键词]
114
+ ```
115
+
116
+ 2. **获取单个提示词详情**
117
+ ```
118
+ GET /api/prompts/:name[?path=文件路径]
119
+ ```
120
+
121
+ 3. **创建/更新提示词**
122
+ ```
123
+ POST /api/prompts
124
+ ```
125
+
126
+ 4. **删除提示词**
127
+ ```
128
+ DELETE /api/prompts/:name[?path=文件路径]
129
+ ```
130
+
131
+ 5. **切换提示词启用状态**
132
+ ```
133
+ POST /api/prompts/:name/toggle[?path=文件路径]
134
+ ```
135
+
136
+ 6. **处理提示词**
137
+ ```
138
+ POST /process
139
+ ```
140
+
141
+ 7. **分组管理**
142
+ - 获取所有分组列表: `GET /api/groups`
143
+ - 创建新分组: `POST /api/groups`
144
+ - 重命名分组: `PATCH /api/groups/rename`
145
+ - 更新分组启用状态: `PATCH /api/groups/status`
146
+ - 删除分组: `DELETE /api/groups?path=分组路径`
147
+
148
+ ## 桌面应用
149
+
150
+ 位于 `app/desktop` 目录,使用 Electron 构建的菜单栏应用,提供以下功能:
151
+
152
+ - 启/停服务
153
+ - 复制服务地址
154
+ - 打开管理后台
155
+ - 检查更新
156
+ - 关于服务信息
157
+
158
+ ## 提示词格式
159
+
160
+ 提示词文件使用 YAML 格式,需要包含以下基本结构:
161
+
162
+ ```yaml
163
+ name: prompt-name
164
+ description: 提示词描述
165
+ messages:
166
+ - role: user
167
+ content:
168
+ text: 提示词内容,支持 {{参数名}} 格式的参数替换
169
+ arguments:
170
+ - name: 参数名
171
+ description: 参数描述
172
+ type: string|number|boolean
173
+ required: true|false
174
+ enabled: true|false # 是否启用该提示词
175
+ ```
package/README.md CHANGED
@@ -132,7 +132,7 @@ npm run desktop:build
132
132
  | `MCP_SERVER_NAME` | 服务器名称 | `prompt-manager` |
133
133
  | `SERVER_PORT` | 服务器端口 | `5621` |
134
134
  | `PROMPTS_DIR` | Prompts目录路径 | `~/.prompt-manager/prompts` |
135
- | `MCP_SERVER_VERSION` | 服务器版本 | `0.0.18` |
135
+ | `MCP_SERVER_VERSION` | 服务器版本 | `0.0.19` |
136
136
  | `LOG_LEVEL` | 日志级别 (error, warn, info, debug) | `info` |
137
137
  | `MAX_PROMPTS` | 最大prompt数量限制 | `100` |
138
138
  | `RECURSIVE_SCAN` | 是否启用递归扫描子目录 | `true` |
@@ -0,0 +1,147 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>关于 Prompt Manager</title>
6
+ <style>
7
+ /* 支持纵向滚动但隐藏滚动条 */
8
+ body {
9
+ margin: 0;
10
+ padding: 0;
11
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
12
+ background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
13
+ color: #333;
14
+ min-height: 100vh;
15
+ display: flex;
16
+ flex-direction: column;
17
+ align-items: center;
18
+ justify-content: center;
19
+ /* 支持纵向滚动 */
20
+ overflow-x: hidden;
21
+ overflow-y: auto;
22
+ }
23
+
24
+ /* 针对WebKit浏览器隐藏滚动条 */
25
+ body::-webkit-scrollbar {
26
+ display: none;
27
+ }
28
+
29
+ /* 针对Firefox浏览器隐藏滚动条 */
30
+ body {
31
+ scrollbar-width: none;
32
+ -ms-overflow-style: none;
33
+ }
34
+
35
+ .container {
36
+ background: white;
37
+ border-radius: 12px;
38
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
39
+ padding: 30px;
40
+ width: 320px;
41
+ text-align: center;
42
+ transition: transform 0.3s ease;
43
+ /* 防止容器内容溢出 */
44
+ max-width: 100%;
45
+ }
46
+
47
+ .container:hover {
48
+ transform: translateY(-2px);
49
+ }
50
+
51
+ .logo {
52
+ width: 64px;
53
+ height: 64px;
54
+ /* background: linear-gradient(135deg, #dcdbdb 0%, #dcdbdb 100%); */
55
+ border-radius: 6px;
56
+ border: 1px solid #ccc;
57
+ margin: 0 auto 15px;
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ font-size: 28px;
62
+ color: white;
63
+ font-weight: bold;
64
+ }
65
+
66
+ .version-info {
67
+ background: #f8f9fa;
68
+ border-radius: 8px;
69
+ padding: 15px;
70
+ margin-bottom: 20px;
71
+ text-align: left;
72
+ }
73
+
74
+ .version-item {
75
+ display: flex;
76
+ justify-content: space-between;
77
+ margin-bottom: 8px;
78
+ font-size: 14px;
79
+ }
80
+
81
+ .version-item:last-child {
82
+ margin-bottom: 0;
83
+ }
84
+
85
+ .label {
86
+ color: #7f8c8d;
87
+ font-weight: 500;
88
+ }
89
+
90
+ .value {
91
+ color: #2c3e50;
92
+ font-weight: 500;
93
+ }
94
+
95
+ .notification {
96
+ background: #e3f2fd;
97
+ border-left: 4px solid #2196f3;
98
+ padding: 12px;
99
+ border-radius: 0 8px 8px 0;
100
+ margin: 15px 0;
101
+ text-align: left;
102
+ }
103
+
104
+ .notification-title {
105
+ font-weight: 600;
106
+ color: #1976d2;
107
+ margin: 0 0 5px 0;
108
+ font-size: 13px;
109
+ }
110
+
111
+ .notification-content {
112
+ font-size: 12px;
113
+ color: #555;
114
+ margin: 0;
115
+ }
116
+ </style>
117
+ </head>
118
+ <body>
119
+ <div class="container">
120
+ <div class="logo">
121
+ <img src="data:image/png;base64,{{logoData}}" alt="Prompt Server Logo" width="64" height="64">
122
+ </div>
123
+
124
+ <div class="version-info">
125
+ <div class="version-item">
126
+ <span class="label">服务版本:</span>
127
+ <span class="value">{{version}}</span>
128
+ </div>
129
+ <div class="version-item">
130
+ <span class="label">Electron:</span>
131
+ <span class="value">{{electronVersion}}</span>
132
+ </div>
133
+ <div class="version-item">
134
+ <span class="label">Node.js:</span>
135
+ <span class="value">{{nodeVersion}}</span>
136
+ </div>
137
+ </div>
138
+
139
+ {{#if debugLogEnabled}}
140
+ <div class="notification">
141
+ <div class="notification-title">调试日志已开启</div>
142
+ <div class="notification-content">日志文件路径: {{logFilePath}}</div>
143
+ </div>
144
+ {{/if}}
145
+ </div>
146
+ </body>
147
+ </html>