foliko 2.0.5 → 2.0.6

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 (65) hide show
  1. package/.claude/settings.local.json +4 -1
  2. package/.cli_default_systemPrompt.md +291 -0
  3. package/.editorconfig +56 -56
  4. package/.lintstagedrc +7 -7
  5. package/.prettierignore +29 -29
  6. package/.prettierrc +11 -11
  7. package/CLAUDE.md +3 -0
  8. package/Dockerfile +63 -63
  9. package/README.md +20 -3
  10. package/docs/architecture.md +34 -2
  11. package/docs/extensions.md +199 -0
  12. package/docs/migration.md +100 -0
  13. package/docs/public-api.md +280 -24
  14. package/docs/usage.md +122 -30
  15. package/install.ps1 +129 -129
  16. package/install.sh +121 -121
  17. package/package.json +1 -1
  18. package/plugins/core/audit/index.js +1 -1
  19. package/plugins/core/default/bootstrap.js +44 -19
  20. package/plugins/core/python-loader/index.js +43 -25
  21. package/plugins/core/skill-manager/PROMPT.md +6 -0
  22. package/plugins/core/skill-manager/index.js +402 -115
  23. package/plugins/core/sub-agent/PROMPT.md +10 -0
  24. package/plugins/core/sub-agent/index.js +36 -3
  25. package/plugins/core/think/index.js +1 -0
  26. package/plugins/core/workflow/index.js +82 -22
  27. package/plugins/executors/data-splitter/PROMPT.md +13 -0
  28. package/plugins/executors/data-splitter/index.js +5 -4
  29. package/plugins/executors/extension/extension-registry.js +145 -0
  30. package/plugins/executors/extension/index.js +405 -437
  31. package/plugins/executors/extension/prompt-builder.js +359 -0
  32. package/plugins/executors/extension/skill-helper.js +143 -0
  33. package/plugins/messaging/feishu/index.js +5 -3
  34. package/plugins/messaging/qq/index.js +6 -4
  35. package/plugins/messaging/telegram/index.js +6 -3
  36. package/plugins/messaging/weixin/index.js +5 -3
  37. package/plugins/tools/PROMPT.md +26 -0
  38. package/plugins/tools/index.js +6 -5
  39. package/skills/find-skills/SKILL.md +133 -133
  40. package/skills/foliko/AGENTS.md +196 -43
  41. package/skills/foliko/SKILL.md +157 -28
  42. package/skills/mcp/SKILL.md +77 -118
  43. package/skills/plugins/SKILL.md +89 -3
  44. package/skills/python/SKILL.md +57 -39
  45. package/skills/skill-guide/SKILL.md +42 -34
  46. package/skills/workflows/SKILL.md +224 -9
  47. package/skills/workflows/workflow-troubleshooting/SKILL.md +221 -281
  48. package/src/agent/chat.js +48 -27
  49. package/src/agent/main.js +34 -13
  50. package/src/agent/prompt-registry.js +56 -16
  51. package/src/agent/prompts/PROMPT.md +3 -0
  52. package/src/agent/sub.js +1 -1
  53. package/src/cli/ui/chat-ui-old.js +5 -2
  54. package/src/cli/ui/chat-ui.js +5 -2
  55. package/src/common/constants.js +12 -0
  56. package/src/common/error-capture.js +91 -0
  57. package/src/common/logger.js +2 -2
  58. package/src/context/compressor.js +6 -2
  59. package/src/executors/mcp-executor.js +105 -125
  60. package/src/framework/framework.js +23 -11
  61. package/src/index.js +4 -0
  62. package/src/plugin/base.js +908 -5
  63. package/src/plugin/manager.js +29 -8
  64. package/src/tool/schema.js +32 -9
  65. package/website/index.html +821 -0
@@ -53,15 +53,14 @@ class PythonPluginLoader extends Plugin {
53
53
  }
54
54
 
55
55
  let desc = '## 【Python 插件】\n\n'
56
- desc += 'Python 插件工具通过 `ext_call` 调用:\n\n'
56
+ desc += '每个 Python 插件自动注册为 `python:<插件名>` 扩展,通过 `ext_skill` + `ext_call` 统一调用:\n\n'
57
57
 
58
58
  for (const [name, plugin] of this._pythonPlugins) {
59
- desc += `### ${plugin.info.name}\n`
59
+ desc += `### python:${plugin.info.name}\n`
60
60
  desc += `${plugin.info.description || ''}\n\n`
61
61
  if (plugin.info.tools && Array.isArray(plugin.info.tools)) {
62
62
  for (const tool of plugin.info.tools) {
63
- const fullName = `${name}_${tool.name}`
64
- desc += `- **${fullName}**: ${tool.description || '无描述'}\n`
63
+ desc += `- **${tool.name}**: ${tool.description || '无描述'}\n`
65
64
  // 使用 zodSchemaToMarkdown 生成参数描述
66
65
  const params = tool.params || {}
67
66
  if (Object.keys(params).length > 0) {
@@ -82,7 +81,9 @@ class PythonPluginLoader extends Plugin {
82
81
  }
83
82
 
84
83
  desc += '**调用格式:**\n'
85
- desc += '```\next_call({ plugin: "python", tool: "插件名_工具名", args: {...} })\n'
84
+ desc += '```\n'
85
+ desc += '// 1. 查询参数\next_skill({ plugin: "python:<插件名>" })\n'
86
+ desc += '// 2. 调用\next_call({ plugin: "python:<插件名>", tool: "<工具名>", args: {...} })\n'
86
87
  desc += '```\n'
87
88
  return desc.trim()
88
89
  }
@@ -151,7 +152,7 @@ class PythonPluginLoader extends Plugin {
151
152
  // 注册插件的每个工具
152
153
  if (pluginInfo.tools && Array.isArray(pluginInfo.tools)) {
153
154
  for (const tool of pluginInfo.tools) {
154
- this._registerPythonTool(pluginName, tool)
155
+ this._registerPythonTool(pluginName, tool, pluginInfo);
155
156
  }
156
157
  }
157
158
  }
@@ -160,22 +161,32 @@ class PythonPluginLoader extends Plugin {
160
161
  }
161
162
  }
162
163
 
164
+ // 所有 Python 插件注册完毕后,强制失效 prompt 缓存,让 LLM 看到新的扩展
165
+ this._extensionExecutor?._invalidatePromptCaches?.(this._framework);
166
+
163
167
  //log.info(` Total Python plugins: ${this._pythonPlugins.size}`)
164
168
  }
165
169
 
166
170
  /**
167
- * 注册 Python 插件的工具
168
- * 工具名格式:插件名_工具名(如 stock_get_price)
169
- * 直接注册到 ExtensionExecutor,使用 ext_call({ plugin: "python", tool: "插件名_工具名", args: {...} }) 调用
171
+ * 注册 Python 插件的单个工具到 ExtensionExecutor
172
+ *
173
+ * 每个 Python 插件注册为独立扩展 `python:<插件名>`,工具名是原始名(不带前缀)。
174
+ * LLM 通过以下方式调用:
175
+ * 1. 查询参数:ext_skill({ plugin: "python:<插件名>" })
176
+ * 2. 调用:ext_call({ plugin: "python:<插件名>", tool: "<工具名>", args: {...} })
177
+ *
178
+ * @param {string} pluginName Python 插件名(PLUGIN.name,例如 'stock')
179
+ * @param {Object} tool 工具定义对象
180
+ * @param {string} tool.name 工具名(PLUGIN.TOOLS[].name,例如 'get_price')
181
+ * @param {string} [tool.description] 工具描述(用于提示词)
182
+ * @param {Object} [tool.params] 工具参数定义(key → 类型占位符或 JSON Schema)
183
+ * @param {Object} [pluginMeta] 插件元信息(含 description),用于丰富扩展描述
170
184
  */
171
- _registerPythonTool(pluginName, tool) {
185
+ _registerPythonTool(pluginName, tool, pluginMeta = null) {
172
186
  if (!tool.name) return
173
187
 
174
- // 格式:pluginname_toolname
175
- const fullToolName = `${pluginName}_${tool.name}`
176
-
177
188
  const toolDef = {
178
- name: fullToolName,
189
+ name: tool.name, // 工具原始名(如 get_price),不带 pluginName_ 前缀
179
190
  description: tool.description || `${pluginName} 的 ${tool.name} 工具`,
180
191
  inputSchema: this._parseToolParams(tool.params || {}),
181
192
  execute: async (args) => {
@@ -183,26 +194,33 @@ class PythonPluginLoader extends Plugin {
183
194
  }
184
195
  }
185
196
 
197
+ // 每个 Python 插件注册为独立扩展 `python:<pluginName>`
198
+ // 优先用 PLUGIN.description,fallback 到默认描述
199
+ const extName = `python:${pluginName}`;
200
+ const extDescription = pluginMeta?.description
201
+ ? pluginMeta.description
202
+ : `Python 插件 ${pluginName}`;
203
+ const pluginInfo = {
204
+ name: extName,
205
+ description: extDescription,
206
+ version: pluginMeta?.version || '1.0.0',
207
+ };
208
+
186
209
  try {
187
- // 直接注册到 ExtensionExecutor(如果可用)
188
210
  if (this._extensionExecutor) {
189
- this._extensionExecutor.registerTool(
190
- 'python', // 插件名,用于 ext_call 的 plugin 参数
191
- { name: 'python', description: 'Python 插件工具', version: '1.0.0' },
192
- toolDef
193
- )
211
+ this._extensionExecutor.registerTool(extName, pluginInfo, toolDef);
194
212
  } else {
195
- // 回退到基类的 registerTool
213
+ // 回退到基类的 registerTool(带 pluginName 前缀以避免冲突)
196
214
  this.registerTool({
197
- name: fullToolName,
198
- description: `[${pluginName}] ${tool.description || ''}`,
215
+ name: `${pluginName}_${tool.name}`,
216
+ description: tool.description || `${pluginName} ${tool.name} 工具`,
199
217
  pluginName: pluginName,
200
218
  inputSchema: this._parseToolParams(tool.params || {}),
201
219
  execute: toolDef.execute
202
- })
220
+ });
203
221
  }
204
222
  } catch (err) {
205
- log.error(` Failed to register tool ${fullToolName}:`, err.message)
223
+ log.error(` Failed to register tool ${tool.name} for ${extName}:`, err.message)
206
224
  }
207
225
  }
208
226
 
@@ -0,0 +1,6 @@
1
+ ## 可用技能
2
+
3
+ > 命令详情(参数、调用方式)请查看上方【Extensions】扩展插件段落。
4
+ > 详细使用指南用 `skill_load("技能名")` 加载。
5
+
6
+ {{skills}}