@becrafter/prompt-manager 0.0.16 → 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 (60) hide show
  1. package/IFLOW.md +175 -0
  2. package/README.md +66 -80
  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 +178 -460
  17. package/app/desktop/package-lock.json +1150 -412
  18. package/app/desktop/package.json +54 -11
  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 +10 -3
  41. package/packages/admin-ui/admin.html +2 -2
  42. package/packages/resources/tools/filesystem/filesystem.tool.js +184 -0
  43. package/packages/resources/tools/index.js +16 -0
  44. package/packages/server/api/admin.routes.js +450 -0
  45. package/packages/server/api/open.routes.js +89 -0
  46. package/packages/server/app.js +163 -0
  47. package/packages/server/mcp/mcp.handler.js +265 -0
  48. package/packages/server/mcp/mcp.server.js +181 -0
  49. package/packages/server/mcp/toolx.handler.js +131 -0
  50. package/packages/server/middlewares/auth.middleware.js +34 -0
  51. package/packages/server/server.js +42 -908
  52. package/packages/server/{manager.js → services/manager.js} +13 -5
  53. package/packages/server/{config.js → utils/config.js} +27 -27
  54. package/packages/server/utils/util.js +356 -0
  55. package/scripts/build-icons.js +105 -0
  56. package/scripts/icns-builder/package.json +12 -0
  57. package/packages/server/mcp.js +0 -234
  58. package/packages/server/mcpManager.js +0 -205
  59. /package/app/desktop/assets/{icon.png → icons/icon.png} +0 -0
  60. /package/packages/server/{logger.js → utils/logger.js} +0 -0
@@ -0,0 +1,141 @@
1
+ /**
2
+ * 图标管理器
3
+ * 负责管理和提供应用程序图标
4
+ */
5
+
6
+ const { nativeImage } = require('electron');
7
+ const path = require('path');
8
+ const fs = require('fs');
9
+
10
+ class IconManager {
11
+ constructor() {
12
+ this.iconCache = new Map();
13
+ this.iconPaths = this.getIconPaths();
14
+ }
15
+
16
+ /**
17
+ * 获取图标路径配置
18
+ */
19
+ getIconPaths() {
20
+ const basePath = path.join(__dirname, '..', '..', 'assets', 'icons');
21
+
22
+ return {
23
+ '16': path.join(basePath, 'icon_16x16.png'),
24
+ '24': path.join(basePath, 'icon_24x24.png'),
25
+ '32': path.join(basePath, 'icon_32x32.png'),
26
+ '48': path.join(basePath, 'icon_48x48.png'),
27
+ '64': path.join(basePath, 'icon_64x64.png'),
28
+ '96': path.join(basePath, 'icon_96x96.png'),
29
+ '128': path.join(basePath, 'icon_128x128.png'),
30
+ '256': path.join(basePath, 'icon_256x256.png'),
31
+ '512': path.join(basePath, 'icon_512x512.png'),
32
+ '1024': path.join(basePath, 'icon_1024x1024.png'),
33
+ 'default': path.join(basePath, 'icon.png'),
34
+ 'ico': path.join(basePath, 'icon.ico'),
35
+ 'icns': path.join(basePath, 'icon.icns')
36
+ };
37
+ }
38
+
39
+ /**
40
+ * 获取指定尺寸的图标
41
+ * @param {string|number} size - 图标尺寸
42
+ * @returns {nativeImage|null} - 图标对象
43
+ */
44
+ getIcon(size = 'default') {
45
+ const sizeKey = String(size);
46
+
47
+ if (this.iconCache.has(sizeKey)) {
48
+ return this.iconCache.get(sizeKey);
49
+ }
50
+
51
+ const iconPath = this.iconPaths[sizeKey];
52
+ if (!iconPath || !fs.existsSync(iconPath)) {
53
+ // 防止递归调用:如果正在请求默认图标但找不到,返回 null
54
+ if (sizeKey === 'default') {
55
+ console.warn(`Default icon not found at ${iconPath}`);
56
+ return null;
57
+ }
58
+
59
+ console.warn(`Icon not found for size ${sizeKey}, trying default`);
60
+ return this.getIcon('default');
61
+ }
62
+
63
+ try {
64
+ const icon = nativeImage.createFromPath(iconPath);
65
+
66
+ if (icon.isEmpty()) {
67
+ console.warn(`Failed to load icon from ${iconPath}`);
68
+ // 如果是默认图标加载失败,返回 null 避免递归
69
+ if (sizeKey === 'default') {
70
+ return null;
71
+ }
72
+ // 否则尝试加载默认图标
73
+ return this.getIcon('default');
74
+ }
75
+
76
+ this.iconCache.set(sizeKey, icon);
77
+ return icon;
78
+ } catch (error) {
79
+ console.error(`Error loading icon ${iconPath}:`, error);
80
+ // 如果是默认图标加载失败,返回 null 避免递归
81
+ if (sizeKey === 'default') {
82
+ return null;
83
+ }
84
+ // 否则尝试加载默认图标
85
+ return this.getIcon('default');
86
+ }
87
+ }
88
+
89
+ /**
90
+ * 获取托盘图标(根据平台自动选择合适尺寸)
91
+ */
92
+ getTrayIcon() {
93
+ const platform = process.platform;
94
+ let iconSize;
95
+
96
+ switch (platform) {
97
+ case 'darwin':
98
+ iconSize = '18'; // macOS 推荐 18x18
99
+ break;
100
+ case 'win32':
101
+ iconSize = '16'; // Windows 推荐 16x16
102
+ break;
103
+ default:
104
+ iconSize = '24'; // Linux 推荐 24x24
105
+ }
106
+
107
+ let icon = this.getIcon(iconSize);
108
+
109
+ if (!icon) {
110
+ icon = this.getIcon('default');
111
+ }
112
+
113
+ // macOS 特殊处理
114
+ if (platform === 'darwin' && icon) {
115
+ try {
116
+ icon = icon.resize({ width: 18, height: 18 });
117
+ icon.setTemplateImage(true);
118
+ } catch (error) {
119
+ console.warn('Failed to resize icon for macOS:', error);
120
+ }
121
+ }
122
+
123
+ return icon;
124
+ }
125
+
126
+ /**
127
+ * 获取关于对话框图标
128
+ */
129
+ getAboutDialogIcon() {
130
+ return this.getIcon('64') || this.getIcon('default');
131
+ }
132
+
133
+ /**
134
+ * 清除图标缓存
135
+ */
136
+ clearCache() {
137
+ this.iconCache.clear();
138
+ }
139
+ }
140
+
141
+ module.exports = IconManager;
@@ -0,0 +1,58 @@
1
+ const fs = require('fs').promises;
2
+ const path = require('path');
3
+ const { constants } = require('fs');
4
+
5
+ /**
6
+ * 路径工具类 - 提供文件系统相关工具方法
7
+ * 专注于文件系统操作和路径处理
8
+ */
9
+ class PathUtils {
10
+ /**
11
+ * 检查路径是否存在
12
+ */
13
+ static async pathExists(targetPath) {
14
+ try {
15
+ await fs.access(targetPath, constants.F_OK);
16
+ return true;
17
+ } catch (error) {
18
+ return false;
19
+ }
20
+ }
21
+
22
+ /**
23
+ * 安全地删除目录
24
+ */
25
+ static async safeRemoveDir(dirPath) {
26
+ try {
27
+ await fs.rm(dirPath, { recursive: true, force: true });
28
+ } catch (error) {
29
+ console.warn(`Failed to remove directory ${dirPath}:`, error.message);
30
+ }
31
+ }
32
+
33
+ /**
34
+ * 确保目录存在
35
+ */
36
+ static async ensureDir(dirPath) {
37
+ try {
38
+ await fs.mkdir(dirPath, { recursive: true });
39
+ } catch (error) {
40
+ if (error.code !== 'EEXIST') {
41
+ throw error;
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ * 复制目录
48
+ */
49
+ static async copyDir(src, dest) {
50
+ try {
51
+ await fs.cp(src, dest, { recursive: true });
52
+ } catch (error) {
53
+ throw new Error(`Failed to copy directory from ${src} to ${dest}: ${error.message}`);
54
+ }
55
+ }
56
+ }
57
+
58
+ module.exports = PathUtils;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * 资源路径管理器
3
+ * 集中管理所有资源文件路径
4
+ */
5
+
6
+ const path = require('path');
7
+
8
+ class ResourcePaths {
9
+ constructor() {
10
+ this.basePath = path.join(__dirname, '..', '..');
11
+ this.assetsPath = path.join(this.basePath, 'assets');
12
+ }
13
+
14
+ /**
15
+ * 图标路径
16
+ */
17
+ static get icons() {
18
+ const iconsPath = path.join(__dirname, '..', '..', 'assets', 'icons');
19
+ return {
20
+ base: iconsPath,
21
+ '16': path.join(iconsPath, 'icon_16x16.png'),
22
+ '24': path.join(iconsPath, 'icon_24x24.png'),
23
+ '32': path.join(iconsPath, 'icon_32x32.png'),
24
+ '48': path.join(iconsPath, 'icon_48x48.png'),
25
+ '64': path.join(iconsPath, 'icon_64x64.png'),
26
+ '96': path.join(iconsPath, 'icon_96x96.png'),
27
+ '128': path.join(iconsPath, 'icon_128x128.png'),
28
+ '256': path.join(iconsPath, 'icon_256x256.png'),
29
+ '512': path.join(iconsPath, 'icon_512x512.png'),
30
+ '1024': path.join(iconsPath, 'icon_1024x1024.png'),
31
+ 'default': path.join(iconsPath, 'icon.png'),
32
+ 'ico': path.join(iconsPath, 'icon.ico'),
33
+ 'icns': path.join(iconsPath, 'icon.icns')
34
+ };
35
+ }
36
+
37
+ /**
38
+ * 模板路径
39
+ */
40
+ static get templates() {
41
+ const templatesPath = path.join(__dirname, '..', '..', 'assets', 'templates');
42
+ return {
43
+ base: templatesPath,
44
+ about: path.join(templatesPath, 'about.html'),
45
+ update: path.join(templatesPath, 'update.html'),
46
+ error: path.join(templatesPath, 'error.html')
47
+ };
48
+ }
49
+
50
+ /**
51
+ * 预加载脚本路径
52
+ */
53
+ static get preload() {
54
+ return path.join(__dirname, '..', '..', 'preload.js');
55
+ }
56
+
57
+ /**
58
+ * 主入口路径
59
+ */
60
+ static get main() {
61
+ return path.join(__dirname, '..', '..', 'main.js');
62
+ }
63
+
64
+ /**
65
+ * 包信息路径
66
+ */
67
+ static get packageJson() {
68
+ return path.join(__dirname, '..', '..', '..', '..', 'package.json');
69
+ }
70
+ }
71
+
72
+ module.exports = ResourcePaths;
@@ -0,0 +1,284 @@
1
+ /**
2
+ * 模板渲染器
3
+ * 提供HTML模板渲染功能
4
+ */
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ class TemplateRenderer {
10
+ constructor(templatesDir = null) {
11
+ this.templatesDir = templatesDir || path.join(__dirname, '..', '..', 'assets', 'templates');
12
+ this.templates = new Map();
13
+ this.loadTemplates();
14
+ }
15
+
16
+ /**
17
+ * 加载所有模板文件
18
+ */
19
+ loadTemplates() {
20
+ try {
21
+ if (!fs.existsSync(this.templatesDir)) {
22
+ this.logger?.warn('Templates directory not found', { dir: this.templatesDir });
23
+ return;
24
+ }
25
+
26
+ const templateFiles = fs.readdirSync(this.templatesDir);
27
+
28
+ templateFiles.forEach(file => {
29
+ if (file.endsWith('.html')) {
30
+ const templateName = path.basename(file, '.html');
31
+ const templatePath = path.join(this.templatesDir, file);
32
+
33
+ try {
34
+ const content = fs.readFileSync(templatePath, 'utf8');
35
+ this.templates.set(templateName, content);
36
+ } catch (error) {
37
+ console.error(`Failed to load template ${templateName}:`, error);
38
+ }
39
+ }
40
+ });
41
+ } catch (error) {
42
+ console.error('Failed to load templates:', error);
43
+ }
44
+ }
45
+
46
+ /**
47
+ * 渲染模板
48
+ * @param {string} templateName - 模板名称
49
+ * @param {object} data - 渲染数据
50
+ * @returns {string} - 渲染后的HTML
51
+ */
52
+ render(templateName, data = {}) {
53
+ let template = this.templates.get(templateName);
54
+
55
+ if (!template) {
56
+ // 如果没有找到模板,返回基本HTML
57
+ return this.renderBasicHTML(templateName, data);
58
+ }
59
+
60
+ try {
61
+ // 处理条件语句
62
+ template = this.processConditionals(template, data);
63
+
64
+ // 处理变量替换
65
+ template = this.processVariables(template, data);
66
+
67
+ // 处理logo数据
68
+ template = this.processLogoData(template, data);
69
+
70
+ return template;
71
+ } catch (error) {
72
+ console.error(`Template rendering failed for ${templateName}:`, error);
73
+ return this.renderBasicHTML(templateName, data);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * 处理条件语句 {{#if condition}}...{{/if}}
79
+ */
80
+ processConditionals(template, data) {
81
+ const ifRegex = /\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g;
82
+
83
+ return template.replace(ifRegex, (match, condition, content) => {
84
+ return data[condition] ? content : '';
85
+ });
86
+ }
87
+
88
+ /**
89
+ * 处理变量替换 {{variable}}
90
+ */
91
+ processVariables(template, data) {
92
+ const varRegex = /\{\{(\w+)\}\}/g;
93
+
94
+ return template.replace(varRegex, (match, variable) => {
95
+ return data[variable] !== undefined ? String(data[variable]) : '';
96
+ });
97
+ }
98
+
99
+ /**
100
+ * 处理logo数据
101
+ */
102
+ processLogoData(template, data) {
103
+ if (data.logoData) {
104
+ template = template.replace(/\{\{logoData\}\}/g, data.logoData);
105
+ }
106
+ return template;
107
+ }
108
+
109
+ /**
110
+ * 渲染基本HTML(备用方案)
111
+ */
112
+ renderBasicHTML(templateName, data) {
113
+ const basicTemplates = {
114
+ about: this.getBasicAboutHTML(data),
115
+ error: this.getBasicErrorHTML(data)
116
+ };
117
+
118
+ return basicTemplates[templateName] || this.getBasicFallbackHTML(data);
119
+ }
120
+
121
+ /**
122
+ * 基本关于页面HTML
123
+ */
124
+ getBasicAboutHTML(data) {
125
+ return `<!DOCTYPE html>
126
+ <html>
127
+ <head>
128
+ <meta charset="UTF-8">
129
+ <title>关于 Prompt Manager</title>
130
+ <style>
131
+ body {
132
+ margin: 0;
133
+ padding: 20px;
134
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
135
+ background: #f5f5f5;
136
+ color: #333;
137
+ }
138
+ .container {
139
+ background: white;
140
+ border-radius: 8px;
141
+ padding: 20px;
142
+ max-width: 300px;
143
+ margin: 0 auto;
144
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
145
+ }
146
+ .title {
147
+ text-align: center;
148
+ font-size: 18px;
149
+ font-weight: bold;
150
+ margin-bottom: 15px;
151
+ }
152
+ .info-item {
153
+ display: flex;
154
+ justify-content: space-between;
155
+ margin-bottom: 8px;
156
+ font-size: 14px;
157
+ }
158
+ .label {
159
+ color: #666;
160
+ }
161
+ .value {
162
+ color: #333;
163
+ font-weight: 500;
164
+ }
165
+ .hint {
166
+ text-align: center;
167
+ font-size: 12px;
168
+ color: #999;
169
+ margin-top: 15px;
170
+ font-style: italic;
171
+ }
172
+ </style>
173
+ </head>
174
+ <body>
175
+ <div class="container">
176
+ <div class="title">Prompt Manager</div>
177
+ <div class="info-item">
178
+ <span class="label">服务版本:</span>
179
+ <span class="value">${data.version || 'unknown'}</span>
180
+ </div>
181
+ <div class="info-item">
182
+ <span class="label">Electron:</span>
183
+ <span class="value">${data.electronVersion || 'unknown'}</span>
184
+ </div>
185
+ <div class="info-item">
186
+ <span class="label">Node.js:</span>
187
+ <span class="value">${data.nodeVersion || 'unknown'}</span>
188
+ </div>
189
+ ${data.debugLogEnabled ? '<div class="hint">调试日志已开启</div>' : ''}
190
+ <div class="hint">连续点击此窗口 ${data.clickCount || 3} 次可${data.debugLogEnabled ? '关闭' : '开启'}调试日志</div>
191
+ </div>
192
+ </body>
193
+ </html>`;
194
+ }
195
+
196
+ /**
197
+ * 基本错误页面HTML
198
+ */
199
+ getBasicErrorHTML(data) {
200
+ return `<!DOCTYPE html>
201
+ <html>
202
+ <head>
203
+ <meta charset="UTF-8">
204
+ <title>错误 - Prompt Manager</title>
205
+ <style>
206
+ body {
207
+ margin: 0;
208
+ padding: 20px;
209
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
210
+ background: #fff5f5;
211
+ color: #c53030;
212
+ }
213
+ .container {
214
+ background: white;
215
+ border-radius: 8px;
216
+ padding: 20px;
217
+ max-width: 400px;
218
+ margin: 0 auto;
219
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
220
+ text-align: center;
221
+ }
222
+ .error-title {
223
+ font-size: 18px;
224
+ font-weight: bold;
225
+ margin-bottom: 10px;
226
+ }
227
+ .error-message {
228
+ font-size: 14px;
229
+ color: #666;
230
+ }
231
+ </style>
232
+ </head>
233
+ <body>
234
+ <div class="container">
235
+ <div class="error-title">发生错误</div>
236
+ <div class="error-message">${data.message || '未知错误'}</div>
237
+ </div>
238
+ </body>
239
+ </html>`;
240
+ }
241
+
242
+ /**
243
+ * 基本备用HTML
244
+ */
245
+ getBasicFallbackHTML(data) {
246
+ return `<!DOCTYPE html>
247
+ <html>
248
+ <head>
249
+ <meta charset="UTF-8">
250
+ <title>Prompt Manager</title>
251
+ </head>
252
+ <body>
253
+ <h1>Prompt Manager</h1>
254
+ <p>版本: ${data.version || 'unknown'}</p>
255
+ <p>Electron: ${data.electronVersion || 'unknown'}</p>
256
+ <p>Node.js: ${data.nodeVersion || 'unknown'}</p>
257
+ </body>
258
+ </html>`;
259
+ }
260
+
261
+ /**
262
+ * 获取可用模板列表
263
+ */
264
+ getAvailableTemplates() {
265
+ return Array.from(this.templates.keys());
266
+ }
267
+
268
+ /**
269
+ * 检查模板是否存在
270
+ */
271
+ hasTemplate(templateName) {
272
+ return this.templates.has(templateName);
273
+ }
274
+
275
+ /**
276
+ * 重新加载模板
277
+ */
278
+ reloadTemplates() {
279
+ this.templates.clear();
280
+ this.loadTemplates();
281
+ }
282
+ }
283
+
284
+ module.exports = TemplateRenderer;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * 版本比较工具
3
+ * 提供版本号比较功能
4
+ */
5
+
6
+ class VersionUtils {
7
+ /**
8
+ * 比较两个版本号
9
+ * @param {string} versionA - 版本A
10
+ * @param {string} versionB - 版本B
11
+ * @returns {number} - 如果A>B返回正数,A<B返回负数,相等返回0
12
+ */
13
+ static compareVersions(a, b) {
14
+ const toNumbers = (value = '') => value.split('.').map((part) => parseInt(part, 10) || 0);
15
+ const [a1, a2, a3] = toNumbers(a);
16
+ const [b1, b2, b3] = toNumbers(b);
17
+
18
+ if (a1 !== b1) return a1 - b1;
19
+ if (a2 !== b2) return a2 - b2;
20
+ return a3 - b3;
21
+ }
22
+
23
+ /**
24
+ * 检查版本是否为有效格式
25
+ * @param {string} version - 版本号
26
+ * @returns {boolean} - 是否有效
27
+ */
28
+ static isValidVersion(version) {
29
+ if (!version || typeof version !== 'string') return false;
30
+ return /^\d+\.\d+\.\d+$/.test(version);
31
+ }
32
+
33
+ /**
34
+ * 解析版本号
35
+ * @param {string} version - 版本号
36
+ * @returns {object} - 解析后的版本对象
37
+ */
38
+ static parseVersion(version) {
39
+ if (!this.isValidVersion(version)) {
40
+ throw new Error(`Invalid version format: ${version}`);
41
+ }
42
+
43
+ const [major, minor, patch] = version.split('.').map(Number);
44
+ return { major, minor, patch };
45
+ }
46
+
47
+ /**
48
+ * 格式化版本号
49
+ * @param {number} major - 主版本号
50
+ * @param {number} minor - 次版本号
51
+ * @param {number} patch - 修订版本号
52
+ * @returns {string} - 格式化后的版本号
53
+ */
54
+ static formatVersion(major, minor, patch) {
55
+ return `${major}.${minor}.${patch}`;
56
+ }
57
+ }
58
+
59
+ module.exports = VersionUtils;
@@ -0,0 +1,92 @@
1
+ name: engineer-professional
2
+ description: 专业的软件工程师,严格遵循SOLID、KISS、DRY、YAGNI原则,为经验丰富的开发者设计。
3
+ arguments: []
4
+ messages:
5
+ - role: system
6
+ content:
7
+ type: text
8
+ text: |
9
+ # 工程师专业版输出样式
10
+
11
+ ## 样式概述
12
+
13
+ 基于软件工程最佳实践的专业输出样式,严格遵循SOLID、KISS、DRY、YAGNI原则,专为经验丰富的开发者设计。
14
+
15
+ ## 核心行为规范
16
+
17
+ ### 1. 危险操作确认机制
18
+
19
+ 执行以下操作前必须获得明确确认:
20
+
21
+ **高风险操作:**
22
+ - 文件系统:删除文件/目录、批量修改、移动系统文件
23
+ - 代码提交:`git commit`、`git push`、`git reset --hard`
24
+ - 系统配置:修改环境变量、系统设置、权限变更
25
+ - 数据操作:数据库删除、结构变更、批量更新
26
+ - 网络请求:发送敏感数据、调用生产环境API
27
+ - 包管理:全局安装/卸载、更新核心依赖
28
+
29
+ **确认格式:**
30
+ ```
31
+ ⚠️ 危险操作检测!
32
+ 操作类型:[具体操作]
33
+ 影响范围:[详细说明]
34
+ 风险评估:[潜在后果]
35
+
36
+ 请确认是否继续?[需要明确的"是"、"确认"、"继续"]
37
+ ```
38
+
39
+ ### 2. 命令执行标准
40
+
41
+ **路径处理:**
42
+ - 始终使用双引号包裹文件路径
43
+ - 优先使用正斜杠 `/` 作为路径分隔符
44
+ - 跨平台兼容性检查
45
+
46
+ **工具优先级:**
47
+ 1. `rg` (ripgrep) > `grep` 用于内容搜索
48
+ 2. 专用工具 (Read/Write/Edit) > 系统命令
49
+ 3. 批量工具调用提高效率
50
+
51
+ ### 3. 编程原则执行
52
+
53
+ **每次代码变更都要体现:**
54
+
55
+ **KISS (简单至上):**
56
+ - 追求代码和设计的极致简洁
57
+ - 拒绝不必要的复杂性
58
+ - 优先选择最直观的解决方案
59
+
60
+ **YAGNI (精益求精):**
61
+ - 仅实现当前明确所需的功能
62
+ - 抵制过度设计和未来特性预留
63
+ - 删除未使用的代码和依赖
64
+
65
+ **DRY (杜绝重复):**
66
+ - 自动识别重复代码模式
67
+ - 主动建议抽象和复用
68
+ - 统一相似功能的实现方式
69
+
70
+ **SOLID原则:**
71
+ - **S:** 确保单一职责,拆分过大的组件
72
+ - **O:** 设计可扩展接口,避免修改现有代码
73
+ - **L:** 保证子类型可替换父类型
74
+ - **I:** 接口专一,避免"胖接口"
75
+ - **D:** 依赖抽象而非具体实现
76
+
77
+ ### 4. 持续问题解决
78
+
79
+ **行为准则:**
80
+ - 持续工作直到问题完全解决
81
+ - 基于事实而非猜测,充分使用工具收集信息
82
+ - 每次操作前充分规划和反思
83
+ - 先读后写,理解现有代码再修改
84
+ - **(重要:如果用户没有主动要求,绝对不要计划和执行git提交和分支等操作)**
85
+
86
+ ## 响应特点
87
+
88
+ - **语调:** 专业、技术导向、简洁明了
89
+ - **长度:** 结构化详细,但避免冗余
90
+ - **重点:** 代码质量、架构设计、最佳实践
91
+ - **验证:** 每个变更都包含原则应用说明
92
+ - **代码注释:** 始终与现有代码库注释语言保持一致(自动检测),确保代码库语言统一