@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
@@ -5,8 +5,13 @@ import {
5
5
  handleGetPrompt,
6
6
  handleSearchPrompts,
7
7
  handleReloadPrompts
8
- } from './mcp.handler.js';
9
- import { handleToolX } from './toolx.handler.js';
8
+ } from './prompt.handler.js';
9
+ import { handleToolM } from '../toolm/index.js';
10
+ import { handleSequentialThinking } from './sequential-thinking.handler.js';
11
+ import { handleThinkPlan } from './think-plan.handler.js';
12
+ // import { generateToolmDescription } from '../toolm/tool-description-generator.service.js';
13
+ import { generateToolmDescription } from '../toolm/tool-description-generator-optimized.service.js';
14
+ import { toolLoaderService } from '../toolm/tool-loader.service.js';
10
15
 
11
16
  class Server {
12
17
  constructor() {
@@ -36,8 +41,22 @@ class Server {
36
41
  }
37
42
  }
38
43
 
39
- export const getMcpServer = () => {
44
+ export const getMcpServer = async () => {
40
45
  const mcpServer = new Server();
46
+
47
+ // 确保工具加载器已初始化(用于生成动态描述)
48
+ if (!toolLoaderService.initialized) {
49
+ try {
50
+ await toolLoaderService.initialize();
51
+ } catch (error) {
52
+ // 如果初始化失败,继续使用默认描述
53
+ console.warn('工具加载器初始化失败,使用默认描述:', error.message);
54
+ }
55
+ }
56
+
57
+ // 动态生成 toolm 工具的描述
58
+ const toolmDescription = generateToolmDescription();
59
+
41
60
  mcpServer.registerTools([
42
61
  {
43
62
  name: 'search_prompts',
@@ -60,112 +79,312 @@ export const getMcpServer = () => {
60
79
  }
61
80
  },
62
81
  {
63
- name: 'toolx',
64
- description: `ToolX is the Prompt Manager tool runtime for loading and executing various tools.
65
-
66
- ## Why ToolX Exists
67
-
68
- ToolX is your gateway to the Prompt Manager tool ecosystem. Think of it as:
69
- - A **universal remote control** for all Prompt Manager tools
70
- - Your **interface** to specialized capabilities (file operations, etc.)
71
- - The **bridge** between you (AI agent) and powerful system tools
72
-
73
- Without ToolX, you cannot access any Prompt Manager ecosystem tools.
74
-
75
- ## When to Use ToolX
76
-
77
- ### Common Scenarios (IF-THEN rules):
78
- - IF user needs file operations → USE tool://filesystem via toolx
79
- - IF you see tool:// in any context → USE toolx to call it
80
-
81
- ### First Time Using Any Tool
82
- ⚠️ **MUST run mode: manual first** to read the tool's documentation
83
- ⚠️ Example: toolx with mode: manual for tool://filesystem
84
-
85
- ## How to Use ToolX (Copy These Patterns)
86
-
87
- ### Pattern 1: Read Tool Manual (First Time)
88
-
89
- **Exact code to use:**
90
- \`\`\`javascript
91
- // Call the toolx function with this exact structure:
92
- toolx({
93
- yaml: \`tool: tool://filesystem\nmode: manual\`
94
- })
95
- \`\`\`
96
-
97
- **What this does:** Shows you how to use the filesystem tool
98
-
99
- ### Pattern 2: Execute Tool with Parameters
100
-
101
- **Exact code to use:**
102
- \`\`\`javascript
103
- toolx({
104
- yaml: \`tool: tool://filesystem\nmode: execute\nparameters:\n path: /path/to/file.txt\n action: read\`
105
- })
106
- \`\`\`
107
-
108
- **What this does:** Reads a file at the specified path
109
-
110
- ### Pattern 3: Configure Tool Environment
111
-
112
- **Exact code to use:**
113
- \`\`\`javascript
114
- toolx({
115
- yaml: \`tool: tool://my-tool\nmode: configure\nparameters:\n API_KEY: sk-xxx123\n TIMEOUT: 30000\`
116
- })
117
- \`\`\`
118
-
119
- **What this does:** Sets environment variables for the tool
120
-
121
- ## Critical Rules (Must Follow)
122
-
123
- ### ✅ Correct Format
124
- The yaml parameter MUST be a complete YAML document:
125
- - Start with \`tool: tool://tool-name\`
126
- - Add \`mode: execute\` (or manual/configure)
127
- - If needed, add \`parameters:\` section with proper indentation
128
-
129
- ### ❌ Common Mistakes to Avoid
130
- - DON'T pass just "tool://filesystem" (missing YAML structure)
131
- - DON'T add @ prefix like "@tool://filesystem" (system handles it)
132
- - DON'T forget "tool://" prefix (not "tool: filesystem")
133
- - DON'T forget to read manual first for new tools
134
-
135
- ## Available System Tools
136
-
137
- Quick reference of built-in tools:
138
- - **tool://filesystem** - File operations (read/write/list/delete)
139
-
140
- To see all available tools: check the tools directory
141
-
142
- ## Step-by-Step Workflow
143
-
144
- ### Step 1: Discover Available Tools
145
- Check the tools directory to see what tools exist
146
-
147
- ### Step 2: Read Tool Manual
148
- \`\`\`javascript
149
- toolx({
150
- yaml: \`tool: tool://TOOLNAME\nmode: manual\`
151
- })
152
- \`\`\`
153
-
154
- ### Step 3: Execute Tool
155
- Copy the example from manual, modify parameters for your needs
156
-
157
- ### Step 4: Handle Errors
158
- If execution fails, check:
159
- - Is the tool name correct?
160
- - Are parameters properly indented?
161
- - Did you read the manual first?
162
-
163
- `,
82
+ name: 'toolm',
83
+ description: toolmDescription,
164
84
  inputSchema: {
165
85
  yaml: z.string().describe('YAML 格式的工具调用配置')
166
86
  },
167
87
  handler: async (args) => {
168
- return handleToolX(args);
88
+ return handleToolM(args);
89
+ }
90
+ },
91
+ {
92
+ name: 'sequentialthinking',
93
+ description: `🧠 **顺序思考工具 (Sequential Thinking)** - 动态反思性思维工具
94
+
95
+ ## 🎯 工具定位
96
+ 这是一个用于**探索性、分析性、不确定性**问题的动态思考工具。支持非线性思维、修订和分支,适合需要深入分析和反复验证的场景。
97
+
98
+ **重要说明:** 此工具支持 MCP 工具协调功能。模型会分析可用工具及其描述,智能推荐合适的工具,并由服务器跟踪和组织这些推荐。
99
+
100
+ ## 🔍 场景识别 - 何时使用此工具?
101
+
102
+ ### ✅ 优先使用 sequentialthinking 的场景:
103
+
104
+ **1. 探索性问题(问题不明确)**
105
+ - ❓ "为什么系统性能下降?" → 需要分析原因
106
+ - ❓ "用户流失率高的原因是什么?" → 需要诊断问题
107
+ - ❓ "这个bug的根本原因是什么?" → 需要深入调查
108
+
109
+ **2. 分析性任务(需要假设验证)**
110
+ - 📊 复杂数据分析
111
+ - 🔬 问题诊断和根因分析
112
+ - 🧪 假设生成和验证
113
+ - 📈 趋势分析和预测
114
+
115
+ **3. 创意性工作(需要多路径探索)**
116
+ - 💡 产品功能设计
117
+ - 🎨 方案设计
118
+ - 🚀 创新思路探索
119
+ - 🔄 需要对比多个方案
120
+
121
+ **4. 需要修订和分支的场景**
122
+ - 发现之前的思考有误,需要修正
123
+ - 需要探索多个可能的解决方案
124
+ - 需要回溯和重新评估
125
+
126
+ **5. 需要工具指导的场景**
127
+ - 不确定应该使用哪些工具
128
+ - 需要了解工具的执行顺序
129
+ - 需要工具使用的参数建议
130
+ - 需要工具推荐的合理性说明
131
+
132
+ ### ❌ 不适合使用 sequentialthinking 的场景:
133
+ - ✅ 目标明确,只需要执行 → 使用 think_and_plan
134
+ - ✅ 需要具体的行动步骤 → 使用 think_and_plan
135
+ - ✅ 任务分解和执行规划 → 使用 think_and_plan
136
+
137
+ ## 🆚 工具对比决策树
138
+
139
+ 决策流程:
140
+ 问题是否明确?
141
+ - 不明确/需要探索 → sequentialthinking
142
+ - 明确 + 需要执行 → think_and_plan
143
+ - 明确 + 只需分析 → sequentialthinking
144
+ - 需要工具推荐和指导 → sequentialthinking
145
+
146
+ ## ✨ 核心特性
147
+
148
+ **1. 非线性思维**
149
+ - 支持分支(branch):从某个思考点探索多个方向
150
+ - 支持修订(revision):修正之前的思考
151
+ - 支持回溯:重新评估之前的步骤
152
+
153
+ **2. 动态调整**
154
+ - 可以调整总思考步骤数(total_thoughts)
155
+ - 可以中途添加更多思考
156
+ - 可以表达不确定性
157
+ - 可以探索替代方案
158
+
159
+ **3. 进度追踪**
160
+ - 显示思考进度(当前/总数/百分比)
161
+ - 自动生成最终总结
162
+ - 提取关键洞察和结论
163
+ - 跟踪已推荐的步骤和剩余步骤
164
+
165
+ **4. 灵活性强**
166
+ - 单一 thought 字段,内容自由
167
+ - 支持假设生成和验证
168
+ - 支持问题分解和重构
169
+ - 支持工具推荐和参数建议
170
+
171
+ **5. MCP 工具协调(核心特性)**
172
+ - 🔧 为每个步骤推荐合适的工具
173
+ - 📝 提供工具推荐的合理性说明
174
+ - 📋 建议工具执行顺序和参数
175
+ - 📊 跟踪之前的推荐和剩余步骤
176
+ - 🎯 分析可用工具并做出智能推荐
177
+
178
+ ## 📋 使用指南
179
+
180
+ **参数说明:**
181
+
182
+ **基础参数:**
183
+ - \`thought\`(必需):当前思考步骤,可以包括:
184
+ * 常规分析步骤
185
+ * 对之前思考的修订
186
+ * 对之前决策的质疑
187
+ * 意识到需要更多分析
188
+ * 方法的改变
189
+ * 假设生成
190
+ * 假设验证
191
+ * 工具推荐和合理性说明
192
+ - \`thoughtNumber\`(可选):当前思考编号(可以从初始总数继续增加)
193
+ - \`totalThoughts\`(可选):当前估计所需思考数(可动态调整)
194
+ - \`nextThoughtNeeded\`(可选):是否需要继续思考(即使看似已到终点)
195
+
196
+ **修订和分支参数:**
197
+ - \`isRevision\`(可选):布尔值,表示此思考是否修订了之前的思考
198
+ - \`revisesThought\`(可选):如果 isRevision 为 true,指定要重新考虑的思考编号
199
+ - \`branchFromThought\`(可选):如果创建分支,指定分支起点的思考编号
200
+ - \`branchId\`(可选):当前分支的标识符(如果有)
201
+ - \`needsMoreThoughts\`(可选):如果到达终点但意识到需要更多思考
202
+
203
+ **MCP 工具协调参数:**
204
+ - \`available_mcp_tools\`(可选):可用 MCP 工具名称数组(例如:["mcp-omnisearch", "mcp-turso-cloud"])
205
+ - \`current_step\`(可选):当前步骤推荐,包括:
206
+ * \`step_description\`:需要做什么
207
+ * \`recommended_tools\`:此步骤推荐的工具
208
+ * \`expected_outcome\`:此步骤的预期结果
209
+ * \`next_step_conditions\`:下一步需要考虑的条件
210
+ - \`previous_steps\`(可选):已推荐的步骤
211
+ - \`remaining_steps\`(可选):后续步骤的高级描述
212
+
213
+ **使用流程:**
214
+ 1. 从初始估计开始,但准备随时调整
215
+ 2. 自由质疑和修订之前的思考
216
+ 3. 即使到达"终点"也可以继续添加思考
217
+ 4. 表达不确定性,探索替代方案
218
+ 5. 标记修订和分支
219
+ 6. 生成假设并验证
220
+ 7. **考虑可用工具,为当前步骤推荐合适的工具**
221
+ 8. **提供工具推荐的清晰合理性说明**
222
+ 9. **在适当时建议具体的工具参数**
223
+ 10. **考虑每个步骤的替代工具**
224
+ 11. **跟踪推荐步骤的进度**
225
+ 12. 忽略与当前步骤无关的信息
226
+ 13. 重复直到满意
227
+ 14. 只在真正完成且得到满意答案时设置 nextThoughtNeeded=false
228
+ 15. 提供单一、理想情况下正确的答案作为最终输出
229
+
230
+ ## 💡 典型使用示例
231
+
232
+ **示例1:问题诊断(带工具推荐)**
233
+ - Thought 1: "分析系统性能下降的可能原因"
234
+ - current_step: { step_description: "检查系统日志", recommended_tools: ["mcp-log-reader"], expected_outcome: "发现错误模式" }
235
+ - Thought 2: "检查数据库查询性能"
236
+ - current_step: { step_description: "分析慢查询", recommended_tools: ["mcp-db-profiler"], expected_outcome: "识别性能瓶颈" }
237
+ - Thought 3: "发现查询慢,需要进一步分析"(可能需要修订或分支)
238
+
239
+ **示例2:方案设计(带工具协调)**
240
+ - Thought 1: "设计用户登录功能"
241
+ - current_step: { step_description: "设计认证流程", recommended_tools: ["mcp-diagram-tool"], expected_outcome: "流程图" }
242
+ - Thought 2: "考虑安全性要求"
243
+ - Thought 3: "修订:需要添加双因素认证"(revision)
244
+ - current_step: { step_description: "实现2FA", recommended_tools: ["mcp-auth-library"], expected_outcome: "安全登录方案" }
245
+
246
+ **示例3:多方案探索(带工具推荐)**
247
+ - Thought 1: "评估三种架构方案"
248
+ - Branch A: "方案A:微服务架构"
249
+ - current_step: { step_description: "评估微服务方案", recommended_tools: ["mcp-architecture-analyzer"], expected_outcome: "方案A评估报告" }
250
+ - Branch B: "方案B:单体架构"
251
+ - current_step: { step_description: "评估单体方案", recommended_tools: ["mcp-architecture-analyzer"], expected_outcome: "方案B评估报告" }`,
252
+ inputSchema: {
253
+ thought: z.string().describe('Your current thinking step'),
254
+ nextThoughtNeeded: z.boolean().optional().describe('Whether another thought step is needed'),
255
+ thoughtNumber: z.number().int().min(1).optional().describe('Current thought number'),
256
+ totalThoughts: z.number().int().min(1).optional().describe('Estimated total thoughts needed'),
257
+ isRevision: z.boolean().optional().describe('Whether this revises previous thinking'),
258
+ revisesThought: z.number().int().min(1).optional().describe('Which thought is being reconsidered'),
259
+ branchFromThought: z.number().int().min(1).optional().describe('Branching point thought number'),
260
+ branchId: z.string().optional().describe('Branch identifier'),
261
+ needsMoreThoughts: z.boolean().optional().describe('If more thoughts are needed')
262
+ },
263
+ handler: async (args) => {
264
+ return handleSequentialThinking(args);
265
+ }
266
+ },
267
+ {
268
+ name: 'think_and_plan',
269
+ description: `📋 **思考规划工具 (Think & Plan)** - 结构化执行导向工具
270
+
271
+ ## 🎯 工具定位
272
+ 这是一个用于**目标明确、需要执行**的结构化规划工具。强调思考-计划-行动的三元结构,适合将复杂任务分解为可执行步骤并追踪执行过程。
273
+
274
+ ## 🔍 场景识别 - 何时使用此工具?
275
+
276
+ ### ✅ 优先使用 think_and_plan 的场景:
277
+
278
+ **1. 任务执行(目标明确)**
279
+ - ✅ "实现用户登录功能" → 需要具体实现步骤
280
+ - ✅ "部署新版本到生产环境" → 需要执行计划
281
+ - ✅ "完成月度报告" → 需要任务分解
282
+ - ✅ "重构某个模块" → 需要实施步骤
283
+
284
+ **2. 项目管理(需要行动追踪)**
285
+ - 📝 任务分解和步骤规划
286
+ - 📅 项目里程碑规划
287
+ - ✅ 行动项追踪
288
+ - 🎯 目标达成路径
289
+
290
+ **3. 结构化问题(需要明确步骤)**
291
+ - 🔧 流程设计和实施
292
+ - 📊 方案执行计划
293
+ - 🚀 功能开发规划
294
+ - 🔄 系统迁移计划
295
+
296
+ **4. 需要可执行行动的场景**
297
+ - 每个步骤都需要明确的下一步行动
298
+ - 需要调用具体工具或执行具体操作
299
+ - 需要验证和检查点
300
+
301
+ ### ❌ 不适合使用 think_and_plan 的场景:
302
+ - ❓ 问题不明确,需要探索 → 使用 sequentialthinking
303
+ - ❓ 需要分析原因或诊断问题 → 使用 sequentialthinking
304
+ - ❓ 需要多方案对比或修订 → 使用 sequentialthinking
305
+ - ❓ 创意性工作,需要发散思维 → 使用 sequentialthinking
306
+
307
+ ## 🆚 工具对比决策树
308
+
309
+ 决策流程:
310
+ 问题是否明确?
311
+ - 明确 + 需要执行 → think_and_plan (优先选择)
312
+ - 明确 + 只需分析 → sequentialthinking
313
+ - 不明确/需要探索 → sequentialthinking
314
+
315
+ ## ✨ 核心特性
316
+
317
+ **1. 三元结构(思考-计划-行动)**
318
+ - 🤔 Thought(思考):分析、假设、洞见
319
+ - 📋 Plan(计划):分解为可执行步骤
320
+ - 🎯 Action(行动):具体、可执行、可验证的下一步
321
+
322
+ **2. 执行导向**
323
+ - 强制要求 action 字段
324
+ - 每个步骤都有明确的下一步
325
+ - 支持工具调用建议
326
+
327
+ **3. 会话隔离**
328
+ - 支持 sessionId 区分不同会话
329
+ - 多任务并行管理
330
+ - 独立记录和追踪
331
+
332
+ **4. 结构化强**
333
+ - 固定结构,使用简单
334
+ - 便于复盘和优化
335
+ - 适合团队协作
336
+
337
+ ## 📋 使用指南
338
+
339
+ **参数说明:**
340
+ - thought(必需):当前思考内容,分析、假设、洞见、反思
341
+ - plan(必需):针对当前任务的计划或方案,分解为可执行步骤
342
+ - action(必需):下一步行动,必须具体、可执行、可验证,可以是工具调用
343
+ - thoughtNumber(必需):思考步骤编号,用于追踪和回溯
344
+ - sessionId(可选):会话标识符,默认为 'default'
345
+
346
+ **使用流程:**
347
+ 1. 明确任务目标
348
+ 2. 思考当前步骤的核心问题
349
+ 3. 制定具体的执行计划
350
+ 4. 定义明确的下一步行动(可包含工具调用)
351
+ 5. 按编号顺序记录每个步骤
352
+ 6. 完成后可获取摘要和回顾
353
+
354
+ ## 💡 典型使用示例
355
+
356
+ **示例1:功能开发**
357
+ - Thought: "需要实现用户登录功能,考虑安全性和用户体验"
358
+ - Plan: "1. 设计登录接口 2. 实现密码加密 3. 添加验证码 4. 编写测试"
359
+ - Action: "调用代码生成工具创建登录接口框架"
360
+
361
+ **示例2:部署任务**
362
+ - Thought: "需要将新版本安全部署到生产环境"
363
+ - Plan: "1. 备份当前版本 2. 执行数据库迁移 3. 部署新代码 4. 验证功能"
364
+ - Action: "执行备份脚本,检查备份是否成功"
365
+
366
+ **示例3:报告编写**
367
+ - Thought: "需要完成月度业务分析报告"
368
+ - Plan: "1. 收集数据 2. 分析趋势 3. 编写报告 4. 审核发布"
369
+ - Action: "调用数据分析工具提取本月业务数据"
370
+
371
+ ## 🔄 与 sequentialthinking 的配合使用
372
+
373
+ **推荐工作流:**
374
+ 1. **探索阶段** → 使用 sequentialthinking
375
+ - 分析问题、探索方案、验证假设
376
+ 2. **执行阶段** → 使用 think_and_plan
377
+ - 将确定的方案转化为可执行步骤
378
+ - 追踪执行进度和结果`,
379
+ inputSchema: {
380
+ thought: z.string().describe('当前的思考内容,可以是对问题的分析、假设、洞见、反思或对前一步骤的总结。强调深度思考和逻辑推演,是每一步的核心。'),
381
+ plan: z.string().describe('针对当前任务拟定的计划或方案,将复杂问题分解为多个可执行步骤。'),
382
+ action: z.string().describe('基于当前思考和计划,建议下一步采取的行动步骤,要求具体、可执行、可验证,可以是下一步需要调用的一个或多个工具。'),
383
+ thoughtNumber: z.string().describe('当前思考步骤的编号,用于追踪和回溯整个思考与规划过程,便于后续复盘与优化。'),
384
+ sessionId: z.string().optional().describe('会话标识符,用于区分不同会话的记录,默认为 \'default\'')
385
+ },
386
+ handler: async (args) => {
387
+ return handleThinkPlan(args);
169
388
  }
170
389
  }
171
390
  // {